summaryrefslogtreecommitdiff
path: root/util/xcompile
diff options
context:
space:
mode:
authorStefan Reinauer <stefan.reinauer@coreboot.org>2017-06-21 16:28:46 -0700
committerStefan Reinauer <stefan.reinauer@coreboot.org>2017-06-25 01:38:13 +0000
commit72dc21cb7c93a25d2b0a473a65bb02462eeef163 (patch)
treea2770c5499c102a714524e3af70ccb9b07ed5002 /util/xcompile
parenta6381d63d539e9485ad48970369b85633efeb847 (diff)
downloadcoreboot-72dc21cb7c93a25d2b0a473a65bb02462eeef163.tar.xz
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 <stefan.reinauer@coreboot.org> Reviewed-on: https://review.coreboot.org/20303 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin Roth <martinroth@google.com>
Diffstat (limited to 'util/xcompile')
-rwxr-xr-xutil/xcompile/xcompile18
1 files changed, 15 insertions, 3 deletions
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
}