[PATCH] common: add CONFIG_WERROR option

Ahmad Fatoum a.fatoum at pengutronix.de
Sun Jun 4 23:37:55 PDT 2023

For development, it may be useful to enforce warning-free builds.
Add a Kconfig option for this.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
This can be enabled for CI, once my other series with warning
fixes is merged.
 Makefile       |  4 ++++
 common/Kconfig | 14 ++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/Makefile b/Makefile
index 4fdb8f1b41af..af5c1448b378 100644
--- a/Makefile
+++ b/Makefile
@@ -648,6 +648,8 @@ endif
 # Force gcc to behave correct even for buggy distributions
 KBUILD_CFLAGS          += $(call cc-option, -fno-stack-protector)
 # This warning generated too much noise in a regular build.
 # Use make W=1 to enable this warning (see scripts/Makefile.build)
 KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
@@ -692,6 +694,8 @@ KBUILD_CFLAGS += $(call cc-option,-Wno-pointer-sign,)
 # change __FILE__ to the relative path from the srctree
 KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
 include-y +=scripts/Makefile.ubsan
 include-$(CONFIG_KASAN)         += scripts/Makefile.kasan
diff --git a/common/Kconfig b/common/Kconfig
index 11aabbb509df..5cfe717aa70d 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -1701,6 +1701,20 @@ config COMPILE_TEST
 	  say Y here. If you are a user, say N here to avoid being prompted for
 	  inclusion of unrelated drivers.
+config WERROR
+	bool "Compile barebox with warnings as errors"
+	default COMPILE_TEST
+	help
+	  A barebox build should not cause any compiler warnings, and this
+	  enables the '-Werror' flags to enforce that rule by default.
+	  However, if you have a new (or very old) compiler with odd and
+	  unusual warnings, or you have some architecture with problems,
+	  you may need to disable this config option in order to
+	  successfully build barebox.
+	  If in doubt, say Y.
 source "common/efi/Kconfig"

More information about the barebox mailing list