How to compile Linux kernel with -O0 flag

Aleksander Alekseev afiskon at
Sat Aug 13 14:56:05 EDT 2016

> The kernel will not run with -O0, sorry, just live with the build
> optimization levels that is currently used and you should be fine.

Oh, I see. Fortunately I'm not afraid of assembler :) Thanks.

Just out of curiosity - is there a technical reason why -O0 couldn't
be used in Linux kernel? I don't know, spinlocks would not work in this
case because it's how GCC was written or something. Or just nobody
compiles and tests kernel like this so it most likely would not work?

> 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.

It's just something I always do when I learn new things. Trying to
figure out how to debug something in this new environment. No real task
so far.

Best regards,
Aleksander Alekseev

More information about the Kernelnewbies mailing list