How to compile Linux kernel with -O0 flag

Greg KH greg at kroah.com
Sat Aug 13 15:12:03 EDT 2016


On Sat, Aug 13, 2016 at 09:56:05PM +0300, Aleksander Alekseev wrote:
> > 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?

Yes, it doesn't work :)

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

Try it, it will not work :)

good luck!

greg k-h



More information about the Kernelnewbies mailing list