]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/kbuild-clang-choose-gcc_toolchain_dir-not-on-ld.patch
Linux 4.14.112
[thirdparty/kernel/stable-queue.git] / queue-4.19 / kbuild-clang-choose-gcc_toolchain_dir-not-on-ld.patch
1 From 984ad8ffe86ddf11a19f4104d4e5e15e93607b13 Mon Sep 17 00:00:00 2001
2 From: Nick Desaulniers <ndesaulniers@google.com>
3 Date: Mon, 11 Feb 2019 11:30:04 -0800
4 Subject: kbuild: clang: choose GCC_TOOLCHAIN_DIR not on LD
5
6 commit ad15006cc78459d059af56729c4d9bed7c7fd860 upstream.
7
8 This causes an issue when trying to build with `make LD=ld.lld` if
9 ld.lld and the rest of your cross tools aren't in the same directory
10 (ex. /usr/local/bin) (as is the case for Android's build system), as the
11 GCC_TOOLCHAIN_DIR then gets set based on `which $(LD)` which will point
12 where LLVM tools are, not GCC/binutils tools are located.
13
14 Instead, select the GCC_TOOLCHAIN_DIR based on another tool provided by
15 binutils for which LLVM does not provide a substitute for, such as
16 elfedit.
17
18 Fixes: 785f11aa595b ("kbuild: Add better clang cross build support")
19 Link: https://github.com/ClangBuiltLinux/linux/issues/341
20 Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
21 Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
22 Tested-by: Nathan Chancellor <natechancellor@gmail.com>
23 Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
24 Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
25 Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
26 Signed-off-by: Sasha Levin <sashal@kernel.org>
27 ---
28 Makefile | 2 +-
29 1 file changed, 1 insertion(+), 1 deletion(-)
30
31 diff --git a/Makefile b/Makefile
32 index 8fdfe0af5862..c07f25e2e11b 100644
33 --- a/Makefile
34 +++ b/Makefile
35 @@ -483,7 +483,7 @@ endif
36 ifeq ($(cc-name),clang)
37 ifneq ($(CROSS_COMPILE),)
38 CLANG_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%))
39 -GCC_TOOLCHAIN_DIR := $(dir $(shell which $(LD)))
40 +GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit))
41 CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)
42 GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..)
43 endif
44 --
45 2.19.1
46