public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] kbuild: add $(CLANG_CFLAGS) to KBUILD_CPPFLAGS
@ 2023-04-09 14:53 Masahiro Yamada
  2023-04-09 20:09 ` kernel test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Masahiro Yamada @ 2023-04-09 14:53 UTC (permalink / raw)
  To: linux-kbuild
  Cc: linux-kernel, Masahiro Yamada, Tom Rini, Nathan Chancellor,
	Nick Desaulniers, Nicolas Schier, Tom Rix, llvm

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 $(CFLAGS_CFLAGS) to KBUILD_CPPFLAGS, so that all *.c, *.S, *.lds.S
will be processed with the proper target triple.

Reported-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/Makefile.clang | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/scripts/Makefile.clang b/scripts/Makefile.clang
index 70b354fa1cb4..93ca059cc3b8 100644
--- a/scripts/Makefile.clang
+++ b/scripts/Makefile.clang
@@ -38,6 +38,5 @@ CLANG_FLAGS	+= -Werror=unknown-warning-option
 CLANG_FLAGS	+= -Werror=ignored-optimization-argument
 CLANG_FLAGS	+= -Werror=option-ignored
 CLANG_FLAGS	+= -Werror=unused-command-line-argument
-KBUILD_CFLAGS	+= $(CLANG_FLAGS)
-KBUILD_AFLAGS	+= $(CLANG_FLAGS)
+KBUILD_CPPFLAGS	+= $(CLANG_FLAGS)
 export CLANG_FLAGS
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-06-23  5:41 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-09 14:53 [PATCH] kbuild: add $(CLANG_CFLAGS) to KBUILD_CPPFLAGS Masahiro Yamada
2023-04-09 20:09 ` kernel test robot
2023-04-10 17:17   ` Nathan Chancellor
2023-04-10 17:25 ` Nathan Chancellor
2023-05-31 21:33 ` Nathan Chancellor
2023-06-02 15:25   ` Nathan Chancellor
2023-06-03 16:32     ` Masahiro Yamada
2023-06-05 15:21       ` Nathan Chancellor
2023-06-06  1:29         ` Masahiro Yamada
2023-06-22 17:06       ` Fangrui Song
2023-06-23  5:40         ` Masahiro Yamada
2023-06-03 16:23   ` Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox