Skip to content

Commit a1f68ae

Browse files
agnersR0rt1z2
authored andcommitted
BACKPORT: kbuild: allow to use GCC toolchain not in Clang search path
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. Change-Id: Ib14e7ee036d8ade5d1121c912df8ced66afca0c7 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]> Link: https://git.kernel.org/linus/ef8c4ed9db80261f397f0c0bf723684601ae3b52 Signed-off-by: Nathan Chancellor <[email protected]>
1 parent 1e9b446 commit a1f68ae

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,14 +617,16 @@ all: vmlinux
617617

618618
ifeq ($(cc-name),clang)
619619
ifneq ($(CROSS_COMPILE),)
620-
CLANG_TARGET := --target=$(notdir $(CROSS_COMPILE:%-=%))
621-
GCC_TOOLCHAIN := $(realpath $(dir $(shell which $(LD)))/..)
620+
CLANG_TARGET := --target=$(notdir $(CROSS_COMPILE:%-=%))
621+
GCC_TOOLCHAIN_DIR := $(dir $(shell which $(LD)))
622+
CLANG_PREFIX := --prefix=$(GCC_TOOLCHAIN_DIR)
623+
GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..)
622624
endif
623625
ifneq ($(GCC_TOOLCHAIN),)
624626
CLANG_GCC_TC := --gcc-toolchain=$(GCC_TOOLCHAIN)
625627
endif
626-
KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
627-
KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
628+
KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
629+
KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
628630
KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
629631
KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
630632
endif

0 commit comments

Comments
 (0)