]> Git Repo - linux.git/commitdiff
kbuild: add $(CLANG_FLAGS) to KBUILD_CPPFLAGS
authorMasahiro Yamada <[email protected]>
Sun, 9 Apr 2023 14:53:57 +0000 (23:53 +0900)
committerMasahiro Yamada <[email protected]>
Mon, 5 Jun 2023 00:50:44 +0000 (09:50 +0900)
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 <[email protected]>
Signed-off-by: Masahiro Yamada <[email protected]>
Reviewed-by: Nathan Chancellor <[email protected]>
Tested-by: Nathan Chancellor <[email protected]>
scripts/Makefile.clang

index 9076cc939e8740bbfd0c51e958f48929213c48f5..058a4c0f864ece2915036cbdf8716508f47ed0e1 100644 (file)
@@ -34,6 +34,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
This page took 0.054443 seconds and 4 git commands to generate.