lkml.org 
[lkml]   [2008]   [Sep]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectre : Building Kernel with -O0
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;
}
static inline __attribute__((always_inline)) int foo()
{
return 0;
}

int main()
{
if (foo())
bar();
}
\
 
 \ /
  Last update: 2008-09-12 22:13    [W:0.029 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site