From: Matthias Kaehlcke <mka@chromium.org>
To: Masahiro Yamada <yamada.masahiro@socionext.com>,
Michal Marek <mmarek@suse.com>
Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
Behan Webster <behanw@converseincode.com>,
Grant Grundler <grundler@chromium.org>,
Greg Hackmann <ghackmann@google.com>,
Michael Davidson <md@google.com>,
Peter Foley <pefoley2@pefoley.com>,
Matthias Kaehlcke <mka@chromium.org>
Subject: [PATCH v2] kbuild: Add better clang cross build support
Date: Fri, 21 Apr 2017 11:20:01 -0700 [thread overview]
Message-ID: <20170421182001.139199-1-mka@chromium.org> (raw)
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
next reply other threads:[~2017-04-21 18:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-21 18:20 Matthias Kaehlcke [this message]
2017-04-23 14:26 ` Masahiro Yamada
-- strict thread matches above, loose matches on Subject: below --
2017-04-10 21:09 Matthias Kaehlcke
2017-04-21 8:24 ` Masahiro Yamada
2017-04-21 17:27 ` Matthias Kaehlcke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170421182001.139199-1-mka@chromium.org \
--to=mka@chromium.org \
--cc=behanw@converseincode.com \
--cc=ghackmann@google.com \
--cc=grundler@chromium.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=md@google.com \
--cc=mmarek@suse.com \
--cc=pefoley2@pefoley.com \
--cc=yamada.masahiro@socionext.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®