This should not be too surprising considering some of Linus Torvalds past commentary about compiler optimizations and bad experiences long ago with GCC, but Linus Torvalds is not interested in seeing a tunable Kconfig option for using the -O3 compiler optimization level for building the Linux kernel without substantial justification.
As I wrote about earlier this week there was a proposed patch to allow a Kconfig option for using the compiler’s -O3 optimization level rather than -O2 when compiling the Linux kernel. Such an option actually already exists in the kernel but is just exposed for the ARC CPU port. The proposed patches were to make this “CC_OPTIMIZE_FOR_PERFORMANCE_O3” option available for all architectures albeit with a clearly-marked “experimental” flag. There is interest among some in -O3 kernel builds for better performance and / or for easily tracking down Linux kernel code or compiler troubles when switching to the more aggressive optimization level.
Not all of the upstream developers were onboard with this idea since the -O3 optimization level can already be set using the KCFLAGS environment variable and there is the possibility of the compiler optimizations introducing issues – particularly subtle differences with aggressive compiler optimizations that can sometimes be hard to otherwise track down.
Linus Torvalds this afternoon commented that he is effectively against having such a Kconfig option. He would need to be really convinced by some hard, real-world data to show its benefits but even then as he has cited in the past there has been known compiler issues historically with some optimizations. Those interested can always use “KCFLAGS = -O3” to achieve the same behavior but he again cites the history of GCC compiler optimization troubles.
Honestly, let’s just remove -O3 entirely.
Enabling it, and then not even build-testing the result, is just about the * worst * possible case. That’s just horrible.
The argument that “but ARC uses it” is not an argument. It was always a bad argument, and ARC needs to just fix whatever it is that made it an issue (likely already fixed with a compiler upgrade).
And there is no way I would ever accept this as a “let people try it” when
– as mentioned, just use KCFLAGS = -O3 if you want to
– -O3 has a * loong * history of generating worse code than -O2
so I will * not * be taking these kinds of patches without some very serious explanations of why -O3 has suddenly become acceptable again.
Those explanations had better be more than “let people try”. They should have in-depth actual performance numbers for a real load, not some made-up “bigger is better” logic.