From mboxrd@z Thu Jan 1 00:00:00 1970 From: greg@kroah.com (Greg KH) Date: Sat, 13 Aug 2016 20:35:34 +0200 Subject: How to compile Linux kernel with -O0 flag In-Reply-To: <20160813211516.7a8dace1@e733> References: <20160813211516.7a8dace1@e733> Message-ID: <20160813183534.GA22784@kroah.com> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org On Sat, Aug 13, 2016 at 09:15:16PM +0300, Aleksander Alekseev wrote: > Hello > > I'm currently exploring different ways of debugging Linux kernel. And I > noticed that for many variables gdb displays . Also from > experience of debugging ring3 code I know that sometimes debugger may > act crazy unless -O0 was used. > > Apparently there is no corresponding option in `make menuconfig`. So > how do you solve this problem? Just `CFLAGS=-O0 make ...` or somehow > else? I wonder what is the "right" way of doing it because you know, > it's a kernel, it can accidentally break something unless you are > careful :) The kernel will not run with -O0, sorry, just live with the build optimization levels that is currently used and you should be fine. But why do you want to use a debugger on the kernel? That's not a normal task unless you are bringing up a new hardware platform. best of luck, greg k-h