[PATCH] common: add CONFIG_WERROR option

Sascha Hauer sha at pengutronix.de
Tue Jun 6 02:41:07 PDT 2023


On Mon, Jun 05, 2023 at 08:37:55AM +0200, Ahmad Fatoum wrote:
> 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(+)

Applied, thanks

Sascha

> 
> 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)
>  
> +KBUILD_CFLAGS-$(CONFIG_WERROR) += -Werror
> +
>  # 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)/=)
>  
> +KBUILD_CFLAGS += $(KBUILD_CFLAGS-y)
> +
>  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.
> +
>  endmenu
>  
>  source "common/efi/Kconfig"
> -- 
> 2.39.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list