Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1628422 > unrolled thread

[PATCH v2] kbuild: Add better clang cross build support

Started byMatthias Kaehlcke <mka@chromium.org>
First post2017-04-21 20:30 +0200
Last post2017-04-23 16:30 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v2] kbuild: Add better clang cross build support Matthias Kaehlcke <mka@chromium.org> - 2017-04-21 20:30 +0200
    Re: [PATCH v2] kbuild: Add better clang cross build support Masahiro Yamada <yamada.masahiro@socionext.com> - 2017-04-23 16:30 +0200

#1628422 — [PATCH v2] kbuild: Add better clang cross build support

FromMatthias Kaehlcke <mka@chromium.org>
Date2017-04-21 20:30 +0200
Subject[PATCH v2] kbuild: Add better clang cross build support
Message-ID<tyLtE-Ix-1@gated-at.bofh.it>
Add cross target to CC if using clang. Also add custom gcc toolchain
path for fallback gcc tools.

Clang will fallback to using things like ld, as, and libgcc if
(respectively) one of the llvm linkers isn't available, the integrated
assembler is turned off, or an appropriately cross-compiled version of
compiler-rt isn't available. To this end, you can specify the path to
this fallback gcc toolchain with GCC_TOOLCHAIN.

From: Behan Webster <behanw@converseincode.com>
Signed-off-by: Behan Webster <behanw@converseincode.com>
Reviewed-by: Jan-Simon Möller <dl9pf@gmx.de>
Reviewed-by: Mark Charlebois <charlebm@gmail.com>
Signed-off-by: Greg Hackmann <ghackmann@google.com>
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---
Changes in v2:
- Moved new 'code' into existing ifeq clang block
- Don't add -target and -gcc-toolchain to KBUILD_CPPFLAGS
- Removed intermediate CLANG_FLAGS variable
- Updated commit message, removed paragraph mentioning old COMPILER
  variable

 Makefile | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/Makefile b/Makefile
index 5039b9148d15..11c00bd3ec0c 100644
--- a/Makefile
+++ b/Makefile
@@ -698,6 +698,15 @@ endif
 KBUILD_CFLAGS += $(stackp-flag)
 
 ifeq ($(cc-name),clang)
+ifneq ($(CROSS_COMPILE),)
+CLANG_TARGET	:= -target $(notdir $(CROSS_COMPILE:%-=%))
+GCC_TOOLCHAIN	:= $(realpath $(dir $(shell which $(LD)))/..)
+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_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
 KBUILD_CPPFLAGS += $(call cc-option,-Wno-unknown-warning-option,)
 KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
-- 
2.12.2.816.g2cccc81164-goog

[toc] | [next] | [standalone]


#1629033

FromMasahiro Yamada <yamada.masahiro@socionext.com>
Date2017-04-23 16:30 +0200
Message-ID<tzqGt-1aR-3@gated-at.bofh.it>
In reply to#1628422
2017-04-22 3:20 GMT+09:00 Matthias Kaehlcke <mka@chromium.org>:
> Add cross target to CC if using clang. Also add custom gcc toolchain
> path for fallback gcc tools.
>
> Clang will fallback to using things like ld, as, and libgcc if
> (respectively) one of the llvm linkers isn't available, the integrated
> assembler is turned off, or an appropriately cross-compiled version of
> compiler-rt isn't available. To this end, you can specify the path to
> this fallback gcc toolchain with GCC_TOOLCHAIN.
>
> From: Behan Webster <behanw@converseincode.com>
> Signed-off-by: Behan Webster <behanw@converseincode.com>
> Reviewed-by: Jan-Simon Möller <dl9pf@gmx.de>
> Reviewed-by: Mark Charlebois <charlebm@gmail.com>
> Signed-off-by: Greg Hackmann <ghackmann@google.com>
> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>


Applied to linux-kbuild/kbuild.  Thanks!




-- 
Best Regards
Masahiro Yamada

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web