[Buildroot] [PATCH] linux: allow the user to respect Linux kernel defconfig's CONFIG_WERROR

Quentin Schulz via buildroot
2026-03-25T17:51:42Z

From: Quentin Schulz <quentin.schulz@cherry.de>

Buildroot forcibly disables WERROR (and PPC_WERROR via
PPC_DISABLE_WERROR for PowerPC) for all kernels since commit
6b56e0b4f09b ("linux: disable -Werror") for the former and 1713c3c344be
("linux: disable Werror for powerpc kernels") for the latter.

Some users (me :) ) may only build kernels within Buildroot and may be
required by audit companies to ensure that no warnings are generated
when building them. While we could look at the log manually and report
that indeed no warnings are seen, better not even build if there's a
warning and catch them as early as possible.

Thus, let's allow the user to not override the WERROR state gotten from
the defconfig. It is left as force-disabled by default as upstream
Buildroot likely does not want to fail builds when bumping the
toolchains with newer warnings and no bandwidth to fix or backport fixes
for kernels for upstream Buildroot defconfigs.

Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de>
---
I believe that commit 6b56e0b4f09b ("linux: disable -Werror") should
rather have disabled WERROR from ESP_HOSTED_LINUX_CONFIG_FIXUPS in
package/esp-hosted/esp-hosted.mk instead of disabling it for everybody.

I understand Buildroot not wanting to respect WERROR if in the kernel
defconfig to avoid additional friction when bumping toolchains, hence
why I made this into a Kconfig knob.

I'm assuming we do not want upstream Buildroot defconfigs to have this
set to N. I can add this info to the Kconfig help text. I can also make
sure defconfigs aren't setting this to N by adding a check in
utils/checkpackagelib/lib_defconfig.py. Let me know if this is something
you're interested in.
---
linux/Config.in | 14 ++++++++++++++
linux/linux.mk | 12 +++++++++---
2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/linux/Config.in b/linux/Config.in
index 44f8b08e71..43397d52af 100644
--- a/linux/Config.in
+++ b/linux/Config.in
@@ -223,6 +223,20 @@ config BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES
A space-separated list of kernel configuration fragment files,
that will be merged to the main kernel configuration file.

+config BR2_LINUX_KERNEL_DISABLE_WERROR
+ bool "Force-disable Werror"
+ default y
+ help
+ This allows to force disable CONFIG_WERROR (and force enable
+ CONFIG_PPC_DISABLE_WERROR for PPC) even if set by the kernel
+ defconfig. This is typically wanted for third party kernel
+ trees or old kernel releases when attempting to build with
+ newer toolchains. Since 2019.08 for PPC and since 2024.05 for
+ the other architectures, the default has been Y.
+
+ You may want to set this to N if you want to make sure your
+ kernel builds without warning for your specific setup.
+
config BR2_LINUX_KERNEL_CUSTOM_LOGO_PATH
string "Custom boot logo file path"
help
diff --git a/linux/linux.mk b/linux/linux.mk
index c61089bfe0..f7f2dfe107 100644
--- a/linux/linux.mk
+++ b/linux/linux.mk
@@ -419,6 +419,14 @@ define LINUX_KCONFIG_FIXUP_CMDS_ROOTFS_CPIO
endef
endif

+ifeq ($(BR2_LINUX_KERNEL_DISABLE_WERROR),y)
+define LINUX_FIXUP_CONFIG_DISABLE_WERROR
+ $(if $(BR2_powerpc)$(BR2_powerpc64)$(BR2_powerpc64le),
+ $(call KCONFIG_ENABLE_OPT,CONFIG_PPC_DISABLE_WERROR))
+ $(call KCONFIG_DISABLE_OPT,CONFIG_WERROR)
+endef
+endif
+
define LINUX_KCONFIG_FIXUP_CMDS
@$(call MESSAGE,"Updating kernel config with fixups")
$(if $(LINUX_NEEDS_MODULES),
@@ -431,8 +439,6 @@ define LINUX_KCONFIG_FIXUP_CMDS
$(LINUX_FIXUP_CONFIG_PAHOLE_CHECK)
$(if $(BR2_arm)$(BR2_armeb),
$(call KCONFIG_ENABLE_OPT,CONFIG_AEABI))
- $(if $(BR2_powerpc)$(BR2_powerpc64)$(BR2_powerpc64le),
- $(call KCONFIG_ENABLE_OPT,CONFIG_PPC_DISABLE_WERROR))
$(if $(BR2_ARC_PAGE_SIZE_4K),
$(call KCONFIG_ENABLE_OPT,CONFIG_ARC_PAGE_SIZE_4K)
$(call KCONFIG_DISABLE_OPT,CONFIG_ARC_PAGE_SIZE_8K)
@@ -474,7 +480,7 @@ define LINUX_KCONFIG_FIXUP_CMDS
$(call KCONFIG_ENABLE_OPT,CONFIG_LOGO)
$(call KCONFIG_ENABLE_OPT,CONFIG_LOGO_LINUX_CLUT224))
$(call KCONFIG_DISABLE_OPT,CONFIG_GCC_PLUGINS)
- $(call KCONFIG_DISABLE_OPT,CONFIG_WERROR)
+ $(LINUX_FIXUP_CONFIG_DISABLE_WERROR)
$(PACKAGES_LINUX_CONFIG_FIXUPS)
endef

---
base-commit: c8dd9e9a011f1a5755df62baceb865efc09862fe
change-id: 20260325-linux-werror-9f6e4ad44b0f

Best regards,
--
Quentin Schulz <quentin.schulz@cherry.de>