Pushback from the Linux kernel community over defaulting to -Werror (make all warnings into errors) for compiling has resulted in a compromise where this default only applies to test builds.
Linux creator and maintainer Linus Torvalds amended the Makefile used to compile the kernel so that -Werror was the default, saying: "We really should always have a clean build." The code was merged into what will be version 5.15 of the kernel.
"I guess the good news is that some builds still pass," said another developer, noting 64 failures out of 153 builds for different platforms. "That sadly proves the point of that patch," Torvalds responded.
"Our Clang builds got bit pretty hard by this," said another, to which Torvalds said: "Clang is clearly doing a *HORRIBLE* job with stack usage."
Google software engineer Nick Desaulniers, who works on compiling the Linux Kernel with Clang and LLVM went further, submitting a patch to revert the change. "While I can appreciate the intent of enabling -Werror, I don't think it is the right tool to address the root cause of developers not testing certain toolchains or configurations, or taking existing reports they're getting serious enough… -Werror is great for preventing new errors from creeping in when a codebase is free of warnings for all configs and all targets and the toolchain is never updated. Unfortunately, none of the above is the case for the Linux kernel at this time," he said. "This change has caused nearly all of our CI to go red."
Desaulniers added that he strongly favoured fixing warnings. "I do recognize the irony of someone who's spent a lot of time cleaning up warnings to be advocating for disabling -Werror."
- GitHub merges 'useless garbage' says Linus Torvalds as new NTFS support added to Linux kernel 5.15
- Tachyum's Prodigy emulator achieves first boot, runs Linux and says 'hello, world'
- When you finish celebrating Linux turning 30, try new Linux 5.14, says Linus Torvalds
- 30 years of Linux: OS was successful because of how it was licensed, says Red Hat
"No," said Torvalds. "It was merged in response [to] years of pain, with the last one just being the final drop… I'm not going to revert that change. I probably will have to limit it (by making that WERROR option depend on certain expectations), but basically any maintainer who has code that causes warnings should expect that they will have to fix those warnings… and I'm most definitely not convinced when the 'let's finally enable -Werror after years of talking about it' people end up going 'but but but I have thousands of warnings'. That's the POINT of that commit."
The arguments continued, with Google software engineer Marco Elver stating: "A single warning in some odd subsystem penalizing the entire kernel's testing progress is inappropriate. The severity of a use-after-free bug found by runtime testing is orders of magnitude more severe than some 'unused variable' warning."
Elver proposed a compromise. "The appropriate usecase for -Werror is therefore compile-test focused builds (often done by developers or CI systems). Reflect this in the Kconfig option by making the default value of WERROR match COMPILE_TEST."
COMPILE_TEST is used to compile the kernel including drivers that will not be loaded. "Developers still, opposing to distributors, might want to build such drivers to compile-test them… If you are a developer and want to build everything available, say Y here," says the comment explaining COMPILE_TEST.
"That seems reasonable. It very much is about build-testing," said Torvalds. He committed Elver's patch yesterday.
Hat tip to Michael Larabel for spotting the discussion, which gives insight into how Torvalds manages the kernel code and his ability to find compromise despite strong opinions. ®