Skip to contentSkip to conversation

linux: allow the user to respect Linux kernel defconfig's CONFIG_WERROR

PATCH Superseded Quentin Schulz via buildroot 1 participant 3 messages Mar 25 – Apr 8

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux: allow the user to respect Linux kernel defconfig's CONFIG_WERROR

From: Quentin Schulz <[email protected]>

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.

---
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(-)
linux/Config.in +14 -0
index 44f8b08e71..43397d52af 100644
@@ -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
linux/linux.mk +9 -3
index c61089bfe0..f7f2dfe107 100644
@@ -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,

Signature · 6 lines
Quentin Schulz <[email protected]>

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw
Quoted 19 lines · Quentin Schulz via buildroot

From: Quentin Schulz <[email protected]>

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.

Quoted 5 lines

---
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.

Yeah, I agree with that. And even so, it should only be done if it's really
needed.

Quoted 3 lines

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.

Not really - for the defconfigs, we can easily create
board/linux-disable-werror.fragment and include that as a Kconfig fragment for all problematic defconfigs. Ideally though the error should be resolved in a more recent kernel.

So I'd tend to prefer to revert 6b56e0b4f09b (or perhaps move it to
esp-hosted) rather than adding yet another weird Config.in option.

For 1713c3c344be, it's probably not worth to bother reverting that one (and
trying to find out which defconfigs break due to it). Unless you also need PPC builds to comply?

Regards,
Arnout

Quoted 78 lines

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(-)
linux/Config.in +14 -0
index 44f8b08e71..43397d52af 100644
@@ -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
linux/linux.mk +9 -4
index c61089bfe0..f7f2dfe107 100644
@@ -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

Quoted 8 lines

Best regards,
--
Quentin Schulz <[email protected]>

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#2 lore raw

Hi Arnout,

Quoted 35 lines · Arnout Vandecappelle
Quoted 19 lines · Quentin Schulz via buildroot

From: Quentin Schulz <[email protected]>

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.

Quoted 5 lines

---
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.

 Yeah, I agree with that. And even so, it should only be done if it's
really needed.

Quoted 3 lines

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.

Quoted 6 lines

 Not really - for the defconfigs, we can easily create board/linux-
disable-werror.fragment and include that as a Kconfig fragment for all problematic defconfigs. Ideally though the error should be resolved in a more recent kernel.

 So I'd tend to prefer to revert 6b56e0b4f09b (or perhaps move it to
esp-hosted) rather than adding yet another weird Config.in option.

Works for me. Is there something you want me to check specifically before sending a revert? I'll build esp-hosted with an updated version of the Buildroot defconfigs that triggered the revert commit, to make sure it isn't failing anymore. I'll build the Linux kernel and kernel modules for upstream Buildroot defconfigs. That'll take some time but at least we'll know for sure upstream defconfigs are fine. Looking at the defconfigs, only very few kernel modules are actually part of Buildroot upstream defconfigs:

configs/orangepi_lite_defconfig:BR2_PACKAGE_RTL8189FS=y configs/orangepi_pc_plus_defconfig:BR2_PACKAGE_RTL8189FS=y configs/mangopi_mq1rdw2_defconfig:BR2_PACKAGE_RTL8723DS=y configs/sipeed_lichee_rv_dock_defconfig:BR2_PACKAGE_RTL8723DS=y configs/sipeed_lichee_rv_dock_defconfig:BR2_PACKAGE_RTL8723DS_BT=y configs/orangepi_zero_defconfig:BR2_PACKAGE_XR819_XRADIO=y

So that doesn't cover much of the 34 kernel modules I found with

git grep -l --full-name kernel-module package/ | xargs basename -a | grep '.mk' | xargs basename -a -s .mk | sed 's/-/_/g' | tr '[:lower:]' '[:upper:]' | sed 's/\(.*\)/BR2_PACKAGE_\1/'

BR2_PACKAGE_BATMAN_ADV
BR2_PACKAGE_CRYPTODEV_LINUX
BR2_PACKAGE_DAHDI_LINUX
BR2_PACKAGE_DTBOCFG
BR2_PACKAGE_EMLOG
BR2_PACKAGE_ESP_HOSTED
BR2_PACKAGE_FALCOSECURITY_LIBS
BR2_PACKAGE_KERNEL_MODULE_IMX_GPU_VIV
BR2_PACKAGE_FWTS
BR2_PACKAGE_GCNANO_BINARIES
BR2_PACKAGE_IGH_ETHERCAT
BR2_PACKAGE_LINUX_BACKPORTS
BR2_PACKAGE_LTTNG_MODULES
BR2_PACKAGE_MALI_DRIVER
BR2_PACKAGE_MDIO_TOOLS
BR2_PACKAGE_NVIDIA_DRIVER
BR2_PACKAGE_NXP_MWIFIEX
BR2_PACKAGE_OPENVMTOOLS
BR2_PACKAGE_OWL_LINUX
BR2_PACKAGE_PKG_KERNEL_MODULE
BR2_PACKAGE_RTL8188EU
BR2_PACKAGE_RTL8189ES
BR2_PACKAGE_RTL8189FS
BR2_PACKAGE_RTL8192EU
BR2_PACKAGE_RTL8723BU
BR2_PACKAGE_RTL8723DS
BR2_PACKAGE_RTL8812AU_AIRCRACK_NG
BR2_PACKAGE_RTL8821AU
BR2_PACKAGE_RTL8821CU
BR2_PACKAGE_RTL8822CS
BR2_PACKAGE_V4L2LOOPBACK
BR2_PACKAGE_WILC_DRIVER
BR2_PACKAGE_WIREGUARD_LINUX_COMPAT
BR2_PACKAGE_XR819_XRADIO
BR2_PACKAGE_ZFS

I guess I'll let people figure out which package needs to be patched and how?

Quoted 3 lines

 For 1713c3c344be, it's probably not worth to bother reverting that one
(and trying to find out which defconfigs break due to it). Unless you also need PPC builds to comply?

I don't care about PPC :)

Cheers,
Quentin
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot