xcompile: Detect clang compilers
This uses the availability of CONFIG_* variables in .xcompile and tests for compilers in xcompile so that the build system doesn't need to probe them. Change-Id: I359ad6245d2527efa7e848a9b38f5f194744c827 Signed-off-by: Patrick Georgi <patrick@georgi-clan.de> Signed-off-by: Edward O'Callaghan <eocallaghan@alterapraxis.com> Reviewed-on: http://review.coreboot.org/10424 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
parent
532df293da
commit
8b5a051c3e
|
@ -124,21 +124,21 @@ detect_special_flags() {
|
||||||
local architecture="$1"
|
local architecture="$1"
|
||||||
# GCC 4.6 is much more picky about unused variables.
|
# GCC 4.6 is much more picky about unused variables.
|
||||||
# Turn off it's warnings for now:
|
# Turn off it's warnings for now:
|
||||||
testcc "$CC" "$CFLAGS_GCC -Wno-unused-but-set-variable " &&
|
testcc "$GCC" "$CFLAGS_GCC -Wno-unused-but-set-variable " &&
|
||||||
CFLAGS_GCC="$CFLAGS_GCC -Wno-unused-but-set-variable "
|
CFLAGS_GCC="$CFLAGS_GCC -Wno-unused-but-set-variable "
|
||||||
|
|
||||||
# Use bfd linker instead of gold if available:
|
# Use bfd linker instead of gold if available:
|
||||||
testcc "$CC" "$CFLAGS_GCC -fuse-ld=bfd" &&
|
testcc "$GCC" "$CFLAGS_GCC -fuse-ld=bfd" &&
|
||||||
CFLAGS_GCC="$CFLAGS_GCC -fuse-ld=bfd" && LINKER_SUFFIX='.bfd'
|
CFLAGS_GCC="$CFLAGS_GCC -fuse-ld=bfd" && LINKER_SUFFIX='.bfd'
|
||||||
|
|
||||||
testcc "$CC" "$CFLAGS_GCC -fno-stack-protector"&&
|
testcc "$GCC" "$CFLAGS_GCC -fno-stack-protector"&&
|
||||||
CFLAGS_GCC="$CFLAGS_GCC -fno-stack-protector"
|
CFLAGS_GCC="$CFLAGS_GCC -fno-stack-protector"
|
||||||
testcc "$CC" "$CFLAGS_GCC -Wl,--build-id=none" &&
|
testcc "$GCC" "$CFLAGS_GCC -Wl,--build-id=none" &&
|
||||||
CFLAGS_GCC="$CFLAGS_GCC -Wl,--build-id=none"
|
CFLAGS_GCC="$CFLAGS_GCC -Wl,--build-id=none"
|
||||||
|
|
||||||
case "$architecture" in
|
case "$architecture" in
|
||||||
x86)
|
x86)
|
||||||
testcc "$CC" "$CFLAGS_GCC -Wa,--divide" &&
|
testcc "$GCC" "$CFLAGS_GCC -Wa,--divide" &&
|
||||||
CFLAGS_GCC="$CFLAGS_GCC -Wa,--divide"
|
CFLAGS_GCC="$CFLAGS_GCC -Wa,--divide"
|
||||||
# Always build for i686 -- no sse/mmx instructions since SMM
|
# Always build for i686 -- no sse/mmx instructions since SMM
|
||||||
# modules are compiled using these flags. Note that this
|
# modules are compiled using these flags. Note that this
|
||||||
|
@ -147,11 +147,11 @@ detect_special_flags() {
|
||||||
CFLAGS_GCC="$CFLAGS_GCC -march=i686"
|
CFLAGS_GCC="$CFLAGS_GCC -march=i686"
|
||||||
;;
|
;;
|
||||||
mipsel)
|
mipsel)
|
||||||
testcc "$CC" "$CFLAGS_GCC -mno-abicalls -fno-pic" && \
|
testcc "$GCC" "$CFLAGS_GCC -mno-abicalls -fno-pic" && \
|
||||||
CFLAGS_GCC+=" -mno-abicalls -fno-pic"
|
CFLAGS_GCC+=" -mno-abicalls -fno-pic"
|
||||||
|
|
||||||
# Enforce little endian mode.
|
# Enforce little endian mode.
|
||||||
testcc "$CC" "$CFLAGS_GCC -EL" && \
|
testcc "$GCC" "$CFLAGS_GCC -EL" && \
|
||||||
CFLAGS_GCC+=" -EL"
|
CFLAGS_GCC+=" -EL"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -159,11 +159,15 @@ detect_special_flags() {
|
||||||
|
|
||||||
report_arch_toolchain() {
|
report_arch_toolchain() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
# elf${TWIDTH}-${TBFDARCH} toolchain (${GCCPREFIX}gcc)
|
# elf${TWIDTH}-${TBFDARCH} toolchain (${GCC})
|
||||||
ARCH_SUPPORTED+=${TARCH}
|
ARCH_SUPPORTED+=${TARCH}
|
||||||
SUBARCH_SUPPORTED+=${TSUPP-${TARCH}}
|
SUBARCH_SUPPORTED+=${TSUPP-${TARCH}}
|
||||||
CC_${TARCH}:=${GCCPREFIX}gcc
|
ifeq (\$(CONFIG_COMPILER_GCC),y)
|
||||||
|
CC_${TARCH}:=${GCC}
|
||||||
CFLAGS_${TARCH}:=${CFLAGS_GCC}
|
CFLAGS_${TARCH}:=${CFLAGS_GCC}
|
||||||
|
else
|
||||||
|
CC_${TARCH}:=${CLANG}
|
||||||
|
endif
|
||||||
CPP_${TARCH}:=${GCCPREFIX}cpp
|
CPP_${TARCH}:=${GCCPREFIX}cpp
|
||||||
AS_${TARCH}:=${GCCPREFIX}as ${ASFLAGS}
|
AS_${TARCH}:=${GCCPREFIX}as ${ASFLAGS}
|
||||||
LD_${TARCH}:=${GCCPREFIX}ld${LINKER_SUFFIX} ${LDFLAGS}
|
LD_${TARCH}:=${GCCPREFIX}ld${LINKER_SUFFIX} ${LDFLAGS}
|
||||||
|
@ -231,6 +235,7 @@ test_architecture() {
|
||||||
|
|
||||||
GCCPREFIX="invalid"
|
GCCPREFIX="invalid"
|
||||||
unset TABI TARCH TBFDARCH TCLIST TENDIAN TSUPP TWIDTH
|
unset TABI TARCH TBFDARCH TCLIST TENDIAN TSUPP TWIDTH
|
||||||
|
unset GCC CLANG
|
||||||
if type arch_config_$architecture > /dev/null; then
|
if type arch_config_$architecture > /dev/null; then
|
||||||
arch_config_$architecture
|
arch_config_$architecture
|
||||||
else
|
else
|
||||||
|
@ -257,21 +262,36 @@ test_architecture() {
|
||||||
program_exists "${gccprefix}as" || continue
|
program_exists "${gccprefix}as" || continue
|
||||||
for endian in $TENDIAN ""; do
|
for endian in $TENDIAN ""; do
|
||||||
testas "$gccprefix" "$TWIDTH" "$TBFDARCH" \
|
testas "$gccprefix" "$TWIDTH" "$TBFDARCH" \
|
||||||
"" "$endian" && return 0
|
"" "$endian" && break 3
|
||||||
testas "$gccprefix" "$TWIDTH" "$TBFDARCH" \
|
testas "$gccprefix" "$TWIDTH" "$TBFDARCH" \
|
||||||
"TRUE" "$endian" && return 0
|
"TRUE" "$endian" && break 3
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
if [ "invalid" != "$GCCPREFIX" ]; then
|
||||||
|
GCC="${GCCPREFIX}gcc"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Warning: no suitable GCC for $architecture." >&2
|
for clang_arch in $TCLIST invalid; do
|
||||||
return 1
|
testcc "clang" "-target ${clang_arch}-$TABI -c" && break
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "invalid" != "$clang_arch" ]; then
|
||||||
|
# FIXME: this may break in a clang && !gcc configuration,
|
||||||
|
# but that's more of a clang limitation. Let's be optimistic
|
||||||
|
# that this will change in the future.
|
||||||
|
CLANG="clang -target ${clang_arch}-${TABI} -ccc-gcc-name ${GCC}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$GCC" -a -z "$CLANG" ]; then
|
||||||
|
echo "Warning: no suitable compiler for $architecture." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This loops over all supported architectures.
|
# This loops over all supported architectures.
|
||||||
for architecture in $SUPPORTED_ARCHITECTURES; do
|
for architecture in $SUPPORTED_ARCHITECTURES; do
|
||||||
if test_architecture $architecture; then
|
if test_architecture $architecture; then
|
||||||
CC="${GCCPREFIX}"gcc
|
|
||||||
detect_special_flags "$architecture"
|
detect_special_flags "$architecture"
|
||||||
report_arch_toolchain
|
report_arch_toolchain
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue