Skip to content

Commit 009e6e9

Browse files
agnersHuawei-Dev
authored andcommitted
kbuild: allow to use GCC toolchain not in Clang search path
commit ef8c4ed9db80261f397f0c0bf723684601ae3b52 upstream. When using a GCC cross toolchain which is not in a compiled in Clang search path, Clang reverts to the system assembler and linker. This leads to assembler or linker errors, depending on which tool is first used for a given architecture. It seems that Clang is not searching $PATH for a matching assembler or linker. Make sure that Clang picks up the correct assembler or linker by passing the cross compilers bin directory as search path. This allows to use Clang provided by distributions with GCC toolchains not in /usr/bin. Link: ClangBuiltLinux/linux#78 Signed-off-by: Stefan Agner <[email protected]> Reviewed-and-tested-by: Nick Desaulniers <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]> [nc: Adjust context] Signed-off-by: Nathan Chancellor <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7c3da52 commit 009e6e9

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

Makefile

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -540,18 +540,16 @@ endif
540540

541541
ifeq ($(cc-name),clang)
542542
ifneq ($(CROSS_COMPILE),)
543-
CLANG_TRIPLE ?= $(CROSS_COMPILE)
544-
CLANG_TARGET := --target=$(notdir $(CLANG_TRIPLE:%-=%))
545-
ifeq ($(shell $(srctree)/scripts/clang-android.sh $(CC) $(CLANG_TARGET)), y)
546-
$(error "Clang with Android --target detected. Did you specify CLANG_TRIPLE?")
547-
endif
548-
GCC_TOOLCHAIN := $(realpath $(dir $(shell which $(LD)))/..)
543+
CLANG_TARGET := --target=$(notdir $(CROSS_COMPILE:%-=%))
544+
GCC_TOOLCHAIN_DIR := $(dir $(shell which $(LD)))
545+
CLANG_PREFIX := --prefix=$(GCC_TOOLCHAIN_DIR)
546+
GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..)
549547
endif
550548
ifneq ($(GCC_TOOLCHAIN),)
551549
CLANG_GCC_TC := --gcc-toolchain=$(GCC_TOOLCHAIN)
552550
endif
553-
KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
554-
KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
551+
KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
552+
KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
555553
KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
556554
KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
557555
endif

0 commit comments

Comments
 (0)