Skip to contentSkip to conversation

kbuild: allow to use GCC toolchain not in Clang search path

PATCH In review Nathan Chancellor 2 participants 2 messages Nov 29, 2018 Stable branch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild: allow to use GCC toolchain not in Clang search path

From: Stefan Agner <[email protected]>

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.

---
 Makefile | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
Makefile +5 -3
index 874d72a3e6a7..cb131e135c42 100644
@@ -480,13 +480,15 @@ endif
 ifeq ($(cc-name),clang)
 ifneq ($(CROSS_COMPILE),)
 CLANG_TARGET	:= --target=$(notdir $(CROSS_COMPILE:%-=%))
-GCC_TOOLCHAIN	:= $(realpath $(dir $(shell which $(LD)))/..)
+GCC_TOOLCHAIN_DIR := $(dir $(shell which $(LD)))
+CLANG_PREFIX	:= --prefix=$(GCC_TOOLCHAIN_DIR)
+GCC_TOOLCHAIN	:= $(realpath $(GCC_TOOLCHAIN_DIR)/..)
 endif
 ifneq ($(GCC_TOOLCHAIN),)
 CLANG_GCC_TC	:= --gcc-toolchain=$(GCC_TOOLCHAIN)
 endif
-KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
-KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
+KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
+KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
 KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
 KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
 endif
Signature · 1 line
2.20.0.rc1
#1 lore raw
Quoted 24 lines · Nathan Chancellor

From: Stefan Agner <[email protected]>

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.

Quoted 3 lines
---
 Makefile | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

We also need this for 4.9, right?

thanks,

greg k-h