linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 4.14] kbuild: allow to use GCC toolchain not in Clang search path
@ 2018-11-29  5:35 Nathan Chancellor
  2018-11-29 10:27 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: Nathan Chancellor @ 2018-11-29  5:35 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Sasha Levin
  Cc: stable, linux-kernel, Nick Desaulniers, Stefan Agner,
	Masahiro Yamada, Nathan Chancellor

From: Stefan Agner <stefan@agner.ch>

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: https://github.com/ClangBuiltLinux/linux/issues/78
Signed-off-by: Stefan Agner <stefan@agner.ch>
Reviewed-and-tested-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
[nc: Adjust context]
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 Makefile | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 874d72a3e6a7..cb131e135c42 100644
--- a/Makefile
+++ b/Makefile
@@ -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
-- 
2.20.0.rc1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 4.14] kbuild: allow to use GCC toolchain not in Clang search path
  2018-11-29  5:35 [PATCH 4.14] kbuild: allow to use GCC toolchain not in Clang search path Nathan Chancellor
@ 2018-11-29 10:27 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-29 10:27 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Sasha Levin, stable, linux-kernel, Nick Desaulniers,
	Stefan Agner, Masahiro Yamada

On Wed, Nov 28, 2018 at 10:35:12PM -0700, Nathan Chancellor wrote:
> From: Stefan Agner <stefan@agner.ch>
> 
> 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: https://github.com/ClangBuiltLinux/linux/issues/78
> Signed-off-by: Stefan Agner <stefan@agner.ch>
> Reviewed-and-tested-by: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> [nc: Adjust context]
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>  Makefile | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)

We also need this for 4.9, right?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-11-29 10:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-29  5:35 [PATCH 4.14] kbuild: allow to use GCC toolchain not in Clang search path Nathan Chancellor
2018-11-29 10:27 ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).