Skip to contentSkip to conversation

Linux kernel support -O0 optimization flag?

DISCUSSION Ley Foon Tan 3 participants 4 messages Apr 15, 2013 – Apr 24, 2013

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 5 lines · Ley Foon Tan

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

#2 lore raw
Quoted 6 lines · richard -rw- weinberger

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

#3 lore raw
In reply to richard -rw- weinberger
Quoted 7 lines · richard -rw- weinberger
Quoted 5 lines · Ley Foon Tan

Change KBUILD_CFLAGS to -O0 in Makefile and got the compilation error as below.
Is the Linux kernel support -O0 optimization flag?

Quoted 5 lines

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

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