Linux 5.15's New "-Werror" Behavior Is Causing A Lot Of Pain

Written by Michael Larabel in Linux Kernel on 7 September 2021 at 08:48 PM EDT. 129 Comments
LINUX KERNEL
Landing this past weekend was the surprise move by Linus Torvalds to enable "-Werror" behavior by default for all kernel builds. That compiler flag addition makes all warnings be treated as errors, which in turn stops the kernel build. As expected, this change has led to quite a mess.

That change to enable "-Werror" by default when building the Linux kernel led to some immediate errors. In particular, build/test farms were quick to hit pain points and quickly finding various areas of the kernel that were emitting warnings not immediately correctable.

Nick Desaulniers of Google who has been involved with the LLVM Clang building of the Linux kernel ended up submitting a patch that reverts the change by Linus Torvalds. Nick noted, "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."

Linus Torvalds rejected the ntion of disabling it by default. "No. It was merged in response of _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...I spent hours yesterday getting rid of some warnings. It shouldn't be on me fixing peoples code. It shouldn't be on me noticing that people send me crap that warns. And it really shouldn't be "Linus cares about warnings, so configurations that Linus doesn't test can continue for years to have them". My "no warnings" policy isn't exactly new, and people shouldn't be shocked when I then say "time to clean up *YOUR* house too"."

Then brought up in this heated conversation by Marco Elver was the idea of just enabling "-Werror" when doing a "COMPILE_TEST" kernel build for wanting to push the warning-as-error reporting to those compile testing the kernels. That path seems to be gaining ground and Linus calling it as "reasonable" change. That COMPILE_TEST approach for -Werror seems to be gaining ground as other upstream developers voice their opinion how they've also had to resort to disabling the new behavior to provide successful kernel builds.

Long story short, that COMPILE_TEST route for -Werror will presumably get through for Linux 5.15 rather than being the default for all kernel builds. However, Linus Torvalds is really pressing on developers to take responsibility and fix compiler warnings.

Update: Linus Torvalds has now landed the patch demoting it to COMPILE_TEST only by default.
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