Re: Building Kernel with -O0

From: Andi Kleen
Date: Tue Sep 09 2008 - 16:01:46 EST

> > I think a few more cases crept in where it was common to write
> > build time asserts as
> >
> > if (some condition the compiler evaluates at runtime)
> ^^^^^^^
> buildtime

Thank for the correction.

> > __error_condition_xyz_is_false();
> >
> > and this obviously relies on the optimizer to build. But these
> > are all slowly moving over the BUILD_BUG_ON() which also doesn't
> > rely on the optimizer, so it's also obsolete.
> >...
> The reason why it works for Keith at all seems to be that even with -O0
> gcc already does this kind of optimizations.

What I mean is global optimization over the whole function, like
constant propagation. That is required for some of the more complex
macros like the *_user() ones.

Some expression evaluation is required by the C standard (e.g.
otherwise you couldn't generally declare global arrays with expressions)
While that's technically not required in the body of the function
outside declarations the compiler does it normally. But only inside
a statement.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at