public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* re : Building Kernel with -O0
@ 2008-09-12 20:09 matthieu castet
  0 siblings, 0 replies; only message in thread
From: matthieu castet @ 2008-09-12 20:09 UTC (permalink / raw)
  To: Linux Kernel list, Andi Kleen, Keith A. Prickett

[-- Attachment #1: Type: text/plain, Size: 1879 bytes --]

Hi,

last time I check kernel build for x86 and arm with -O0, there was 
several issues.

First there some code that rely in function inline and code elimination, 
and cause usage of disable symbol at  -O0

#ifdef CONFIG_FOO
int foo()
{
}
static inline int toto()
{
}
#else
static inline int toto()
{
return 0
}
#endif

if (toto())
    foo();

This doesn't work even when using __always_inline (try to build attached 
undec.c at -O0).


Second, I saw problem with swab macro [1].
When using -O0, __OPTIMIZE__ is not defined, and constant initialisation 
of some code fails (I don't remeber exactly the case but removing the 
defined(__OPTIMIZE__) fix the issue).

Next for x86 there a driver with asm optimisation that fail to build 
because gcc fail to allocate register.

And finaly as Andi say there some code doing check if undefined symbol. 
For example slab index_of [2]

In the end I build the kernel at -O instead of -O0.

Matthieu

PS : I am not sure __always_inline always work at -O0...

[1]
#if defined(__GNUC__) && defined(__OPTIMIZE__)
#  define __swab16(x) \
(__builtin_constant_p((__u16)(x)) ? \
  ___constant_swab16((x)) : \
  __fswab16((x)))
#  define __swab32(x) \
(__builtin_constant_p((__u32)(x)) ? \
  ___constant_swab32((x)) : \
  __fswab32((x)))
#  define __swab64(x) \
(__builtin_constant_p((__u64)(x)) ? \
  ___constant_swab64((x)) : \
  __fswab64((x)))
#else
#  define __swab16(x) __fswab16(x)
#  define __swab32(x) __fswab32(x)
#  define __swab64(x) __fswab64(x)
#endif /* OPTIMIZE */

[2]
static __always_inline int index_of(const size_t size)
{
     extern void __bad_size(void);

     if (__builtin_constant_p(size)) {
         int i = 0;

#define CACHE(x) \
     if (size <=x) \
         return i; \
     else \
         i++;
#include <linux/kmalloc_sizes.h>
#undef CACHE
         __bad_size();
     } else
         __bad_size();
     return 0;
}

[-- Attachment #2: undec.c --]
[-- Type: text/x-csrc, Size: 107 bytes --]

static inline __attribute__((always_inline)) int foo()
{
	return 0;
}

int main()
{
	if (foo())
		bar();
}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-09-12 20:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-12 20:09 re : Building Kernel with -O0 matthieu castet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox