Upstream Linux Developers Against "-O3" Optimizing The Kernel

Written by Michael Larabel in Linux Kernel on 13 May 2020 at 08:45 AM EDT. 23 Comments
LINUX KERNEL
The upstream Linux kernel developers have come out against a proposal to begin using the "-O3" optimization level when compiling the open-source code-base with the GCC 10 compiler or newer.

Last week a patch was proposed to set the default compiler optimization level to -O3 from -O2 for the kernel when using the newly-released GCC 10 compiler or later. That patch by WireGuard lead developer Jason Donenfeld explained, "GCC 10 appears to have changed -O2 in order to make compilation time faster when using -flto, seemingly at the expense of performance, in particular with regards to how the inliner works. Since -O3 these days shouldn't have the same set of bugs as 10 years ago, this commit defaults new kernel compiles to -O3 when using gcc >= 10."

Some developers expressed interest in potentially supporting a sub-set of -O3 optimization level features or even exploring the -Og optimization level and working to make kernel build times lower for testing. But overall the idea of the Linux kernel defaulting to -O3 was widely panned as not necessarily making the kernel faster but introducing the possibility of optimization peculiarities or areas where the code might even be slower.

Linus Torvalds as well came out to say he isn't convinced that it's a sensible idea, particularly due to the -O3 history in GCC in sometimes having issues.

GCC developer Richard Biener also wrote that he would not recommend using -O3 for the kernel. He did bring up the idea of using feedback/profile-driven data for the compiler to make better optimization decisions, but that would be a big undertaking in collecting enough data for FDO and the like to be universally beneficial.

So for now at least it looks like the Linux kernel will not be pursuing this more aggressive compiler optimization level.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week