Skip to content

Commit b816b3d

Browse files
committed
kbuild: fix CONFIG_CC_CAN_LINK(_STATIC) for cross-compilation with Clang
scripts/cc-can-link.sh tests if the compiler can link userspace programs. When $(CC) is GCC, it is checked against the target architecture because the toolchain prefix is specified as a part of $(CC). When $(CC) is Clang, it is checked against the host architecture because --target option is missing. Pass $(CLANG_FLAGS) to scripts/cc-can-link.sh to evaluate the link capability for the target architecture. Signed-off-by: Masahiro Yamada <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]>
1 parent 8f8499a commit b816b3d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

init/Kconfig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ config CLANG_VERSION
4949

5050
config CC_CAN_LINK
5151
bool
52-
default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(m64-flag)) if 64BIT
53-
default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(m32-flag))
52+
default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(m64-flag)) if 64BIT
53+
default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(m32-flag))
5454

5555
config CC_CAN_LINK_STATIC
5656
bool
57-
default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) -static $(m64-flag)) if 64BIT
58-
default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) -static $(m32-flag))
57+
default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(m64-flag) -static) if 64BIT
58+
default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(m32-flag) -static)
5959

6060
config CC_HAS_ASM_GOTO
6161
def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC))

0 commit comments

Comments
 (0)