From 72dc21cb7c93a25d2b0a473a65bb02462eeef163 Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Wed, 21 Jun 2017 16:28:46 -0700 Subject: xcompile: Fix clang compiler runtime detection clang, like gcc, needs a compiler runtime library. Unlike gcc, it can use either its own runtime library (compiler-rt), or gcc's version (libgcc). Also unlike gcc, the version of clang that is currently part of our reference toolchain does not provide the necessary versions of compiler-rt for all platforms we support. Hence, for now, use libgcc even on clang builds. This patch allows switching between the two, but switching to compiler-rt will break clang builds, unless someone fixes our reference toolchain to provide libclang_rt.builtins-${ARCH}.a for each of our supported platforms. Change-Id: I5001a4b62ed34df19312f980b927ced8cbaf07db Signed-off-by: Stefan Reinauer Reviewed-on: https://review.coreboot.org/20303 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth --- util/xcompile/xcompile | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'util') diff --git a/util/xcompile/xcompile b/util/xcompile/xcompile index 347ae8e2a5..63f1ca9cf5 100755 --- a/util/xcompile/xcompile +++ b/util/xcompile/xcompile @@ -206,10 +206,14 @@ detect_special_flags() { } detect_compiler_runtime() { - test -z "$CLANG" || \ - CC_RT_CLANG="$(${CLANG} -print-libgcc-file-name 2>/dev/null)" test -z "$GCC" || \ CC_RT_GCC="$(${GCC} ${CFLAGS_GCC} -print-libgcc-file-name)" + if [ ${CLANG_RUNTIME} = "libgcc" ]; then + CC_RT_CLANG=${CC_RT_GCC} + else + test -z "$CLANG" || \ + CC_RT_CLANG="$(${CLANG} ${CFLAGS_CLANG} -print-libgcc-file-name 2>/dev/null)" + fi } report_arch_toolchain() { @@ -371,6 +375,14 @@ arch_config_power8() { CC_RT_EXTRA_GCC="-mcpu=power8 -mbig-endian" } +# Right now, the clang reference toolchain is not building compiler-rt builtins +# for any of the cross compile architectures. Hence we use libgcc for now, +# because that is available and lets us proceed with getting coreboot clang +# ready. Toggle CLANG_RUNTIME if you want to experiment with compiler-rt. + +CLANG_RUNTIME="libgcc" +# CLANG_RUNTIME="compiler-rt" + test_architecture() { local architecture=$1 local endian gccprefix search @@ -431,7 +443,7 @@ test_architecture() { # but that's more of a clang limitation. Let's be optimistic # that this will change in the future. CLANG="${XGCCPATH}clang" - CFLAGS_CLANG="-target ${clang_arch}-${TABI} $CFLAGS_CLANG -ccc-gcc-name ${GCC}" + CFLAGS_CLANG="-target ${clang_arch}-${TABI} --rtlib=${CLANG_RUNTIME} $CFLAGS_CLANG -ccc-gcc-name ${GCC}" fi } -- cgit v1.2.3