public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: Masahiro Yamada <masahiroy@kernel.org>,
	Michal Marek <michal.lkml@markovi.net>,
	Nick Desaulniers <ndesaulniers@google.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] kbuild: move -Werror from KBUILD_CFLAGS to KBUILD_CPPFLAGS
Date: Mon,  5 Sep 2022 17:36:18 +0900	[thread overview]
Message-ID: <20220905083619.672091-1-masahiroy@kernel.org> (raw)

CONFIG_WERROR makes warnings into errors, but it only happens for *.c
files because -Werror is added to KBUILD_CFLAGS.

For example, you can put a #warning directive in any preprocessed
source file:

    #warning "blah blah ..."

If it is placed in a *.c file, it emits a warning by default, and it
is promoted to an error when CONFIG_WERROR is enabled:

    error: #warning "blah blah ..." [-Werror=cpp]

If it is placed in a *.S file, it is still a warning.

Move it to KBUILD_CPPFLAGS, so it works in the same way for *.c,
*.S, *.lds.S or whatever needs preprocessing.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index ebcb75442d7f..027d9163eff6 100644
--- a/Makefile
+++ b/Makefile
@@ -788,7 +788,8 @@ stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG)      := -fstack-protector-strong
 
 KBUILD_CFLAGS += $(stackp-flags-y)
 
-KBUILD_CFLAGS-$(CONFIG_WERROR) += -Werror
+KBUILD_CPPFLAGS-$(CONFIG_WERROR) += -Werror
+KBUILD_CPPFLAGS += $(KBUILD_CPPFLAGS-y)
 KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds
 KBUILD_CFLAGS += $(KBUILD_CFLAGS-y) $(CONFIG_CC_IMPLICIT_FALLTHROUGH)
 
-- 
2.34.1


             reply	other threads:[~2022-09-05  8:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-05  8:36 Masahiro Yamada [this message]
2022-09-05  8:36 ` [PATCH 2/2] kbuild: move -Wundef from KBUILD_CFLAGS to KBUILD_CPPFLAGS Masahiro Yamada
2022-09-05 14:22   ` kernel test robot
2022-09-05 15:48   ` kernel test robot
2022-09-05 16:01     ` Masahiro Yamada
2022-09-12  9:56   ` kernel test robot
2022-09-07  5:05 ` [PATCH 1/2] kbuild: move -Werror " Nick Desaulniers
  -- strict thread matches above, loose matches on Subject: below --
2022-12-06  4:07 Masahiro Yamada
2022-12-09 17:47 ` Nathan Chancellor

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=20220905083619.672091-1-masahiroy@kernel.org \
    --to=masahiroy@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=ndesaulniers@google.com \
    /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