From: june.tune.sea@gmail.com (ishare) Date: Fri, 22 Mar 2013 22:32:40 +0800 Subject: optimization in kernel compile In-Reply-To: <31616.1363960553@turing-police.cc.vt.edu> References: <20130322054125.GA10919@debian.localdomain> <31616.1363960553@turing-police.cc.vt.edu> Message-ID: <20130322143240.GA1502@debian.localdomain> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org On Fri, Mar 22, 2013 at 09:55:53AM -0400, Valdis.Kletnieks at vt.edu wrote: > On Fri, 22 Mar 2013 13:41:25 +0800, ishare said: > > Is it needed or must to compile fs and driver with -O2 option when compiling kernel ? > > It's not strictly mandatory to use -O2 (for a while, -Os was the default). There > are a few places that for correctness, you *cannot* use -O0. For instance, a > few places where we use builtin_return_address() inside an inline (-O0 > won't inline so builtin_return_address() ends up returning a pointer to > a function when we want the function's parent). So it will cause an error ? > > Since gdb and friends are able to deal with -O2 compiled code just fine, > there's really no reason *not* to optimize the kernel. the debug information will be stripped by -O2 ,for example ,you can not touch the value of some varibles at stack , and debugging will not run line by line, instead , the source jump in unexpectable order .