Messages in this thread | | | Date | Tue, 9 Sep 2008 22:05:17 +0200 | From | Andi Kleen <> | Subject | Re: Building Kernel with -O0 |
| |
> > 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.
-Andi
| |