Torvalds Has It With "-Wstringop-overflow" On GCC Due To Kernel Breakage

Written by Michael Larabel in Linux Kernel on 2 February 2024 at 03:00 AM EST. 26 Comments
LINUX KERNEL
One of the new features for Linux 6.8 that was merged late was enabling the -Wstringop-overflow compiler option to warn about possible buffer overflows in cases where the compiler can detect such possible overflows at compile-time. While it's nice in theory, issues on GCC has led Linus Torvalds to disabling this compiler option as of now Linux 6.8.

As noted in the prior Phoronix article on the topic, the "-Wstringop-overflow" option was being enabled unconditionally for new kernel builds with the exception when using the GCC 11 compiler due to known compiler bugs. But it turns out GCC 11 alone isn't isolated to bad -Wstringop-overflow compiler behavior.

Linus committed a new patch of his own on Thursday and commented:
"It turns out it was never just gcc-11 that was broken. Apparently it just happens to work on x86-64 with other gcc versions.

On arm64, I see warnings with gcc version 13.2.1, and the kernel test robot reports the same problem on s390 with gcc 13.2.0.

Admittedly it seems to be just the new Xe drm driver, but this is keeping me from doing my normal arm64 build testing. So it gets reverted until somebody figures out what causes the problem (and why it doesn't show on x86-64, which is what makes me suspect it was never just about gcc-11, and more about just random happenstance).

This also changes the Kconfig naming a bit - just make the "disable this for GCC" conditional be one simple Kconfig entry, and we can put the gcc version dependencies in that entry once we figure out what the correct rules are.

The version dependency _may_ still end up being "gcc version larger than 11" if the issue is purely in the Xe driver, but even if that ends up the case, let's make that all part of the "GCC_NO_STRINGOP_OVERFLOW" logic.

For now, we just disable it for all gcc versions while the exact cause is unknown."

Torvalds has been using an Apple Silicon MacBook Air as his laptop when testing kernel builds and this is what seems to be hitting the non-x86_64 build issues with this compiler option.

We'll see if this situation gets sorted out in time for the Linux 6.8 stable release in March or if the "-Wstringop-overflow" behavior is more widespread/problematic for non-x86_64 architectures that there may not be a short-term fix.
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