mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yann Droneaud <ydroneaud@opteya.com>
To: Masahiro Yamada <masahiroy@kernel.org>,
	Michal Marek <michal.lkml@markovi.net>,
	Nick Desaulniers <ndesaulniers@google.com>
Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Yann Droneaud <ydroneaud@opteya.com>
Subject: [PATCHv1] kbuild: support W=e to make build abort in case of warning
Date: Fri,  8 Apr 2022 10:46:07 +0200	[thread overview]
Message-ID: <20220408084607.106468-1-ydroneaud@opteya.com> (raw)
In-Reply-To: <1422803720-14723-1-git-send-email-ydroneaud@opteya.com>

When developing new code/feature, CONFIG_WERROR is most
often turned off, especially for people using make W=12 to
get more warnings.

In such case, turning on -Werror temporarily would require
switching on CONFIG_WERROR in the configuration, building,
then switching off CONFIG_WERROR.

For this use case, this patch introduces a new 'e' modifier
to W= as a short hand for KCFLAGS+=-Werror" so that -Werror
got added to the kernel (built-in) and modules' CFLAGS.

Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>
---
 Makefile                   |  1 +
 scripts/Makefile.extrawarn | 13 +++++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

Changes since v0[0]:

 - rebase on top of commit 64a91907c896 ("kbuild: refactor scripts/Makefile.extrawarn")
 - document use case after commit 3fe617ccafd6 ("Enable '-Werror' by default for all kernel builds")

[0] https://lore.kernel.org/all/1422803720-14723-1-git-send-email-ydroneaud@opteya.com/

diff --git a/Makefile b/Makefile
index 8c7de9a72ea2..6dc621af18d1 100644
--- a/Makefile
+++ b/Makefile
@@ -1649,6 +1649,7 @@ help:
 	@echo  '		1: warnings which may be relevant and do not occur too often'
 	@echo  '		2: warnings which occur quite often but may still be relevant'
 	@echo  '		3: more obscure warnings, can most likely be ignored'
+	@echo  '		e: warnings are being treated as errors'
 	@echo  '		Multiple levels can be combined with W=12 or W=123'
 	@echo  ''
 	@echo  'Execute "make" or "make all" to build all targets marked with [*] '
diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 650d0b8ceec3..f5f0d6f09053 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -2,8 +2,8 @@
 # ==========================================================================
 # make W=... settings
 #
-# There are three warning groups enabled by W=1, W=2, W=3.
-# They are independent, and can be combined like W=12 or W=123.
+# There are four warning groups enabled by W=1, W=2, W=3, and W=e
+# They are independent, and can be combined like W=12 or W=123e.
 # ==========================================================================
 
 KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
@@ -94,3 +94,12 @@ KBUILD_CFLAGS += $(call cc-option, -Wpacked-bitfield-compat)
 KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN3
 
 endif
+
+#
+# W=e - error out on warnings
+#
+ifneq ($(findstring e, $(KBUILD_EXTRA_WARN)),)
+
+KBUILD_CFLAGS += -Werror
+
+endif
-- 
2.32.0


  reply	other threads:[~2022-04-08  8:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-01 15:15 [PATCH] " Yann Droneaud
2022-04-08  8:46 ` Yann Droneaud [this message]
2022-04-08 11:05   ` [PATCHv1] " Masahiro Yamada
2022-04-08 20:29     ` Nick Desaulniers
2022-04-08 20:36       ` Randy Dunlap
2022-04-09  1:47         ` Masahiro Yamada
2022-04-09  1:54           ` Randy Dunlap
2022-04-14 13:09           ` Nicolas Schier
2022-04-14 15:15             ` Masahiro Yamada
2022-04-14 17:51               ` Nicolas Schier
2022-04-14 20:14                 ` Nicolas Schier
2022-04-20 16:21   ` Masahiro Yamada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220408084607.106468-1-ydroneaud@opteya.com \
    --to=ydroneaud@opteya.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=ndesaulniers@google.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®