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>
This commit is contained in:
Stefan Reinauer 2017-06-21 16:28:46 -07:00
parent a6381d63d5
commit 72dc21cb7c
1 changed files with 15 additions and 3 deletions

View File

@ -206,10 +206,14 @@ detect_special_flags() {
} }
detect_compiler_runtime() { detect_compiler_runtime() {
test -z "$CLANG" || \
CC_RT_CLANG="$(${CLANG} -print-libgcc-file-name 2>/dev/null)"
test -z "$GCC" || \ test -z "$GCC" || \
CC_RT_GCC="$(${GCC} ${CFLAGS_GCC} -print-libgcc-file-name)" 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() { report_arch_toolchain() {
@ -371,6 +375,14 @@ arch_config_power8() {
CC_RT_EXTRA_GCC="-mcpu=power8 -mbig-endian" 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() { test_architecture() {
local architecture=$1 local architecture=$1
local endian gccprefix search local endian gccprefix search
@ -431,7 +443,7 @@ test_architecture() {
# but that's more of a clang limitation. Let's be optimistic # but that's more of a clang limitation. Let's be optimistic
# that this will change in the future. # that this will change in the future.
CLANG="${XGCCPATH}clang" 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 fi
} }