From: Nathan Chancellor <nathan@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Sasha Levin <sashal@kernel.org>
Cc: stable@vger.kernel.org, llvm@lists.linux.dev
Subject: [PATCH 5.4 5/6] kbuild: add $(CLANG_FLAGS) to KBUILD_CPPFLAGS
Date: Mon, 11 Aug 2025 16:51:50 -0700 [thread overview]
Message-ID: <20250811235151.1108688-6-nathan@kernel.org> (raw)
In-Reply-To: <20250811235151.1108688-1-nathan@kernel.org>
From: Masahiro Yamada <masahiroy@kernel.org>
commit feb843a469fb0ab00d2d23cfb9bcc379791011bb upstream.
When preprocessing arch/*/kernel/vmlinux.lds.S, the target triple is
not passed to $(CPP) because we add it only to KBUILD_{C,A}FLAGS.
As a result, the linker script is preprocessed with predefined macros
for the build host instead of the target.
Assuming you use an x86 build machine, compare the following:
$ clang -dM -E -x c /dev/null
$ clang -dM -E -x c /dev/null -target aarch64-linux-gnu
There is no actual problem presumably because our linker scripts do not
rely on such predefined macros, but it is better to define correct ones.
Move $(CLANG_FLAGS) to KBUILD_CPPFLAGS, so that all *.c, *.S, *.lds.S
will be processed with the proper target triple.
[Note]
After the patch submission, we got an actual problem that needs this
commit. (CBL issue 1859)
Link: https://github.com/ClangBuiltLinux/linux/issues/1859
Reported-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
Makefile | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index f65e282f4a3f..16a23aaaa547 100644
--- a/Makefile
+++ b/Makefile
@@ -568,8 +568,7 @@ ifneq ($(LLVM_IAS),1)
CLANG_FLAGS += -no-integrated-as
endif
CLANG_FLAGS += -Werror=unknown-warning-option
-KBUILD_CFLAGS += $(CLANG_FLAGS)
-KBUILD_AFLAGS += $(CLANG_FLAGS)
+KBUILD_CPPFLAGS += $(CLANG_FLAGS)
export CLANG_FLAGS
endif
--
2.50.1
next prev parent reply other threads:[~2025-08-11 23:52 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-11 23:51 [PATCH 5.4 0/6] Fix build due to clang -Qunused-arguments change Nathan Chancellor
2025-08-11 23:51 ` [PATCH 5.4 1/6] ARM: 9448/1: Use an absolute path to unified.h in KBUILD_AFLAGS Nathan Chancellor
2025-08-12 4:12 ` Sasha Levin
2025-08-11 23:51 ` [PATCH 5.4 2/6] kbuild: Update assembler calls to use proper flags and language target Nathan Chancellor
2025-08-12 4:12 ` Sasha Levin
2025-08-12 21:18 ` Nathan Chancellor
2025-08-11 23:51 ` [PATCH 5.4 3/6] mips: Include KBUILD_CPPFLAGS in CHECKFLAGS invocation Nathan Chancellor
2025-08-12 4:12 ` Sasha Levin
2025-08-11 23:51 ` [PATCH 5.4 4/6] kbuild: Add CLANG_FLAGS to as-instr Nathan Chancellor
2025-08-12 4:12 ` Sasha Levin
2025-08-11 23:51 ` Nathan Chancellor [this message]
2025-08-12 4:12 ` [PATCH 5.4 5/6] kbuild: add $(CLANG_FLAGS) to KBUILD_CPPFLAGS Sasha Levin
2025-08-12 21:11 ` Nathan Chancellor
2025-08-11 23:51 ` [PATCH 5.4 6/6] kbuild: Add KBUILD_CPPFLAGS to as-option invocation Nathan Chancellor
2025-08-12 4:12 ` Sasha Levin
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=20250811235151.1108688-6-nathan@kernel.org \
--to=nathan@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=llvm@lists.linux.dev \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.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