[PATCH] kbuild, LLVMLinux: Add better clang cross build support

From: behanw
Date: Fri Sep 05 2014 - 20:22:04 EST

From: Behan Webster <behanw@xxxxxxxxxxxxxxxxxx>

Add cross target to CC if using clang. Also add custom gcc toolchain path for
fallback gcc tools.

COMPILER is previously set to "clang" if CC=clang was set from the make command
line. So -target and -gcc-toolchain can be added to CC, since we already know
that it is set.

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

Signed-off-by: Behan Webster <behanw@xxxxxxxxxxxxxxxxxx>
Makefile | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/Makefile b/Makefile
index 2893d7f..c772619 100644
--- a/Makefile
+++ b/Makefile
@@ -360,7 +360,16 @@ include $(srctree)/scripts/Kbuild.include
# Make variables (CC, etc...)
+ifeq ($(COMPILER),clang)
+ifneq ($(CROSS_COMPILE),)
+CC += -target $(CROSS_COMPILE:%-=%)
+ifneq ($(GCC_TOOLCHAIN),)
+CC += -gcc-toolchain $(GCC_TOOLCHAIN)
CPP = $(CC) -E

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/