2013-04-15 07:59:12

by Ley Foon Tan

[permalink] [raw]
Subject: Linux kernel support -O0 optimization flag?



Change KBUILD_CFLAGS to -O0 in Makefile and got the compilation error as
below.
Is the Linux kernel support -O0 optimization flag?
Note, I have tried 2 architecture compilers and got the same error.



In function 'zap_pmd_range',

inlined from 'zap_pud_range' at mm/memory.c:1288:8,

inlined from 'unmap_page_range' at mm/memory.c:1313:8:

mm/memory.c:1243:23: error: call to '__build_bug_failed' declared with
attribute error: BUILD_BUG failed

make[1]: *** [mm/memory.o] Error 1


2013-04-15 11:16:39

by Richard Weinberger

[permalink] [raw]
Subject: Re: Linux kernel support -O0 optimization flag?

On Mon, Apr 15, 2013 at 9:58 AM, Ley Foon Tan <[email protected]> wrote:
>
>
> Change KBUILD_CFLAGS to -O0 in Makefile and got the compilation error as
> below.
> Is the Linux kernel support -O0 optimization flag?

No. If I'm not mistaken we need this to make sure that the compiler
inlines some functions.

In your case the compiler failed to compute the BUILD_BUG() macro correctly.
It depends also on optimization.

--
Thanks,
//richard

2013-04-16 06:10:43

by Ley Foon Tan

[permalink] [raw]
Subject: Re: Linux kernel support -O0 optimization flag?

On Mon, 2013-04-15 at 13:16 +0200, richard -rw- weinberger wrote:

> No. If I'm not mistaken we need this to make sure that the compiler
> inlines some functions.
>
> In your case the compiler failed to compute the BUILD_BUG() macro correctly.
> It depends also on optimization.
>
Thank you.
So, the supported optimization flags are -O1, -O2, -O3 and -Os?

Regards
LFTAN

2013-04-24 08:29:42

by Pavel Machek

[permalink] [raw]
Subject: Re: Linux kernel support -O0 optimization flag?

On Mon 2013-04-15 13:16:36, richard -rw- weinberger wrote:
> On Mon, Apr 15, 2013 at 9:58 AM, Ley Foon Tan <[email protected]> wrote:
> >
> >
> > Change KBUILD_CFLAGS to -O0 in Makefile and got the compilation error as
> > below.
> > Is the Linux kernel support -O0 optimization flag?
>
> No. If I'm not mistaken we need this to make sure that the compiler
> inlines some functions.
>
> In your case the compiler failed to compute the BUILD_BUG() macro correctly.
> It depends also on optimization.

Actually... You probably could replace BUILD_BUG() with nop. Bugs are
not expected to happen, right? you'll probably hit something else...

Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html