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 @@ -874,12 +874,14 @@ stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong
KBUILD_CFLAGS += $(stackp-flags-y)
-KBUILD_CPPFLAGS-$(CONFIG_WERROR) += -Werror -KBUILD_CPPFLAGS += $(KBUILD_CPPFLAGS-y) +# kernel-ark: CONFIG_WERROR is handled in makefile +#KBUILD_CPPFLAGS-$(CONFIG_WERROR) += -Werror +#KBUILD_CPPFLAGS += $(KBUILD_CPPFLAGS-y) KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds
-KBUILD_RUSTFLAGS-$(CONFIG_WERROR) += -Dwarnings -KBUILD_RUSTFLAGS += $(KBUILD_RUSTFLAGS-y) +# kernel-ark: CONFIG_WERROR is handled in makefile +#KBUILD_RUSTFLAGS-$(CONFIG_WERROR) += -Dwarnings +#KBUILD_RUSTFLAGS += $(KBUILD_RUSTFLAGS-y)
ifdef CONFIG_CC_IS_CLANG KBUILD_CPPFLAGS += -Qunused-arguments diff --git a/makefile b/makefile index blahblah..blahblah 100644 --- a/makefile +++ b/makefile @@ -14,3 +14,16 @@ 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) +KBUILD_RUSTFLAGS-$(CONFIG_WERROR) += -Dwarnings +KBUILD_RUSTFLAGS += $(KBUILD_RUSTFLAGS-y) +endif +endif +endif +endif
-- https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2240