Commit 4c219af4 authored by Stefan Agner's avatar Stefan Agner Committed by Greg Kroah-Hartman
Browse files

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.


Signed-off-by: default avatarStefan Agner <>
Reviewed-and-tested-by: default avatarNick Desaulniers <>
Signed-off-by: Masahiro Yamada's avatarMasahiro Yamada <>
[ND: adjusted to context, due to adjusting the context of my previous
backport of upstream's ae6b289a

Signed-off-by: default avatarNick Desaulniers <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent 51d137ca
......@@ -512,13 +512,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)))
ifneq ($(GCC_TOOLCHAIN),)
CLANG_GCC_TC := -gcc-toolchain $(GCC_TOOLCHAIN)
KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment