Re: Building Kernel with -O0

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Adrian Bunk <bunk@...>
Cc: <linux-kernel@...>
Date: Tuesday, September 9, 2008 - 1:10 pm

On Tue, 2008-09-09 at 19:04 +0300, Adrian Bunk wrote:
I am currently running the kernel compiled with -O0.  The final problem
I ran into was some NULL pointer dereference and compiling ONLY files in
the mm directory with -O2 fixed the issue.

To build with -O0 I had to change a few things (for my ARM
architecture):
1. Ensure the __attribute__((always_inline)) was turned off in the
"inline" #define (compiler.h)

2. Fix some inline assembly in kprobes (ARM only) that, due to no
optimization, needed more registers than the compiler had available.
(Similar to this issue:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13850)

3. Implement a fix as described here:
(http://lists.arm.linux.org.uk/lurker/message/20050201.210458.5cc93c10.en.html)

4. Change -O2 to -O0 in the root Makefile

5. Add extra cflags in the mm Makefile so it builds with -O2 only in
that directory.

All of this could, potentially be changed by a configuration parameter
and added into the kernel release.  Does someone have a primer on why
this kind of behavior is not desired or "possible"?

Doing this has given me SO much visibility into stack variables data
values while single-stepping the code.  I feel that the time invested to
make this work is well worth the return.  In the book "Writing Solid
Code" (http://www.amazon.com/Writing-Solid-Code-Microsofts-Programming/dp/1556155514) one technique discussed is: stepping through your code.  In order to be able to do this effectively you need optimizations turned off.  


--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Building Kernel with -O0, Keith A. Prickett, (Thu Sep 4, 1:50 pm)
Re: Building Kernel with -O0, Adrian Bunk, (Tue Sep 9, 12:04 pm)
Re: Building Kernel with -O0, David Howells, (Tue Sep 9, 6:24 pm)
Re: Building Kernel with -O0, Adrian Bunk, (Thu Sep 25, 9:31 am)
Re: Building Kernel with -O0, David Howells, (Thu Sep 25, 9:51 am)
Re: Building Kernel with -O0, Keith A. Prickett, (Tue Sep 9, 1:10 pm)
Re: Building Kernel with -O0, Andi Kleen, (Tue Sep 9, 3:24 pm)
Re: Building Kernel with -O0, Adrian Bunk, (Tue Sep 9, 3:43 pm)
Re: Building Kernel with -O0, Andi Kleen, (Tue Sep 9, 4:05 pm)
Re: Building Kernel with -O0, linux-os (Dick Johnson), (Tue Sep 9, 2:55 pm)