Linux 5.15 Enabling "-Werror" By Default For All Kernel Builds
A change made by Linus Torvalds and merged today for Linux 5.15 is enabling the "-Werror" compiler flag by default for all kernel builds.
The "-Werror" compiler flag treats all warnings as build errors. By promoting all warnings to errors, it enforces the developers to ensure such build warnings that may otherwise go unnoticed or only loosely concerned about by developers to now treat it with priority given that it will interrupt the build process. Many software projects already use "-Werror" by default to enforce better quality control in ensuring warnings get addressed, but most using it tend not to be the size of the Linux kernel.
Linus Torvalds commented with the change, "We really should always have a clean build, and will disable specific over-eager warnings as required, if we can't fix them. But while I fairly religiously enforce that in my own tree, it doesn't get enforced by various build robots that don't necessarily report warnings. So this just makes '-Werror' a default compiler flag."
However, this patch does also add WERROR as a Kconfig switch. This allows for disabling the "-Werror" flag should new compiler versions introduce new warnings that can't be immediately fixed by the kernel or other selective issues where making a warning-free kernel isn't feasible. The WERROR option is enabled by default for all kernel builds.
Linus ended the patch message with, "Hopefully this will mean that I get fewer pull requests that have new warnings that were not noticed by various automation we have in place. Knock wood."
The "-Werror" compiler flag treats all warnings as build errors. By promoting all warnings to errors, it enforces the developers to ensure such build warnings that may otherwise go unnoticed or only loosely concerned about by developers to now treat it with priority given that it will interrupt the build process. Many software projects already use "-Werror" by default to enforce better quality control in ensuring warnings get addressed, but most using it tend not to be the size of the Linux kernel.
Linus Torvalds commented with the change, "We really should always have a clean build, and will disable specific over-eager warnings as required, if we can't fix them. But while I fairly religiously enforce that in my own tree, it doesn't get enforced by various build robots that don't necessarily report warnings. So this just makes '-Werror' a default compiler flag."
However, this patch does also add WERROR as a Kconfig switch. This allows for disabling the "-Werror" flag should new compiler versions introduce new warnings that can't be immediately fixed by the kernel or other selective issues where making a warning-free kernel isn't feasible. The WERROR option is enabled by default for all kernel builds.
Linus ended the patch message with, "Hopefully this will mean that I get fewer pull requests that have new warnings that were not noticed by various automation we have in place. Knock wood."
45 Comments