From: Prarit Bhargava prarit@redhat.com
makefile: Add -Werror support for RHEL
The -Werror flag should be enabled for RHEL. In ARK, however, it is a bit tricky to enable -Werror as a build bug occasionally leaks through upstream review and into Linus' tree. As a consequence, CONFIG_WERROR cannot be enabled in ARK but the code to add the flag for RHEL commpiles can be added to the top-level makefile.
This code could be placed in the top-level Makefile, around the -Werror line added by Linus in 3fe617ccafd6 ("Enable '-Werror' by default for all kernel builds"), but given the amount of RHEL Only code here it is best to keep it separated in our top-level makefile. Reviewers should note that there is no harm in calling 'KBUILD_CFLAGS += -Werror' twice and that -Werror only appears once in gcc calls when compiling kernel files.
Signed-off-by: Prarit Bhargava prarit@redhat.com
diff --git a/makefile b/makefile index blahblah..blahblah 100644 --- a/makefile +++ b/makefile @@ -14,3 +14,14 @@ dist-%:: distg-%:: $(MAKE) -C redhat $(@) $(_EXTRA_ARGS)
+# Enable -Werror for RHEL +ifneq ($(DISABLE_WERROR),1) +ifneq ($(WITH_GCOV),1) +ifeq ($(KBUILD_EXTMOD),) +ifneq (,$(filter $(ARCH), x86 x86_64 powerpc s390 aarch64)) +KBUILD_CPPFLAGS-$(CONFIG_WERROR) += -Werror +KBUILD_CPPFLAGS += $(KBUILD_CPPFLAGS-y) +endif +endif +endif +endif
-- https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2240
From: Prarit Bhargava on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2240#note_1230405...
Yeah, I was a bit torn on this too for the same reasons; even with this change we have to 'remember' to set CONFIG_WERROR which is lame. One thing to keep in mind is that it does seem like Linus *wants* CONFIG_WERROR on at some point upstream. He just hit too much push back so he backed off on it. By the time we need to think about turning on CONFIG_WERROR in RHEL it may have already been done so by Linus so that we don't have to worry about it.
I'd like to hear from @jmflinuxtx and @ptalbert about how they feel about your proposal. They're the ones who have to deal with the fallout from CONFIG_WERROR. I'm okay with any choice made here, but I just want to make sure I don't break ARK/Fedora.
From: Justin M. Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2240#note_1230424...
We are already building with `-Werror=format-security` Though we typically do not run across many errors until a new toolchain is introduced. That is where this gets problematic to turn on for ark, and where it is much less of a problem for RHEL. Once a year, we get a new toolchain in Fedora. It is typical that we get a massive number of kernel warnings when a new toolchain is introduced. Over time (usually a couple of release cycles, so months) those warnings are fixed. RHEL never has this problem. Turning on full Werror in ark will result in my having to chase down a whole bunch of fixes to keep the tree building which would just land naturally long before RHEL needs them.
kernel@lists.fedoraproject.org