2015-07-06 15:22:45 +02:00
|
|
|
#!/usr/bin/env bash
|
2010-02-10 21:31:38 +01:00
|
|
|
#
|
util/: Replace GPLv2 boiler plate with SPDX header
Used commands:
perl -i -p0e 's|\/\*[\s*]*.*is free software[:;][\s*]*you[\s*]*can[\s*]*redistribute[\s*]*it[\s*]*and\/or[\s*]*modify[\s*]*it[\s*]*under[\s*]*the[\s*]*terms[\s*]*of[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*as[\s*]*published[\s*]*by[\s*]*the[\s*]*Free[\s*]*Software[\s*]*Foundation[;,][\s*]*version[\s*]*2[\s*]*of[\s*]*the[\s*]*License.[\s*]*This[\s*]*program[\s*]*is[\s*]*distributed[\s*]*in[\s*]*the[\s*]*hope[\s*]*that[\s*]*it[\s*]*will[\s*]*be[\s*]*useful,[\s*]*but[\s*]*WITHOUT[\s*]*ANY[\s*]*WARRANTY;[\s*]*without[\s*]*even[\s*]*the[\s*]*implied[\s*]*warranty[\s*]*of[\s*]*MERCHANTABILITY[\s*]*or[\s*]*FITNESS[\s*]*FOR[\s*]*A[\s*]*PARTICULAR[\s*]*PURPOSE.[\s*]*See[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*for[\s*]*more[\s*]*details.[\s*]*\*\/|/* SPDX-License-Identifier: GPL-2.0-only */|' $(cat filelist)
perl -i -p0e 's|This[\s*]*program[\s*]*is[\s*]*free[\s*]*software[:;][\s*]*you[\s*]*can[\s*]*redistribute[\s*]*it[\s*]*and/or[\s*]*modify[\s*]*it[\s*]*under[\s*]*the[\s*]*terms[\s*]*of[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*as[\s*]*published[\s*]*by[\s*]*the[\s*]*Free[\s*]*Software[\s*]*Foundation[;,][\s*]*either[\s*]*version[\s*]*2[\s*]*of[\s*]*the[\s*]*License,[\s*]*or[\s*]*.at[\s*]*your[\s*]*option.*[\s*]*any[\s*]*later[\s*]*version.[\s*]*This[\s*]*program[\s*]*is[\s*]*distributed[\s*]*in[\s*]*the[\s*]*hope[\s*]*that[\s*]*it[\s*]*will[\s*]*be[\s*]*useful,[\s*]*but[\s*]*WITHOUT[\s*]*ANY[\s*]*WARRANTY;[\s*]*without[\s*]*even[\s*]*the[\s*]*implied[\s*]*warranty[\s*]*of[\s*]*MERCHANTABILITY[\s*]*or[\s*]*FITNESS[\s*]*FOR[\s*]*A[\s*]*PARTICULAR[\s*]*PURPOSE.[\s*]*See[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*for[\s*]*more[\s*]*details.[\s*]*\*\/|/* SPDX-License-Identifier: GPL-2.0-or-later */|' $(cat filelist)
perl -i -p0e 's|\/\*[\s*]*.*This[\s*#]*program[\s*#]*is[\s*#]*free[\s*#]*software[;:,][\s*#]*you[\s*#]*can[\s*#]*redistribute[\s*#]*it[\s*#]*and/or[\s*#]*modify[\s*#]*it[\s*#]*under[\s*#]*the[\s*#]*terms[\s*#]*of[\s*#]*the[\s*#]*GNU[\s*#]*General[\s*#]*Public[\s*#]*License[\s*#]*as[\s*#]*published[\s*#]*by[\s*#]*the[\s*#]*Free[\s*#]*Software[\s*#]*Foundation[;:,][\s*#]*either[\s*#]*version[\s*#]*3[\s*#]*of[\s*#]*the[\s*#]*License[;:,][\s*#]*or[\s*#]*.at[\s*#]*your[\s*#]*option.*[\s*#]*any[\s*#]*later[\s*#]*version.[\s*#]*This[\s*#]*program[\s*#]*is[\s*#]*distributed[\s*#]*in[\s*#]*the[\s*#]*hope[\s*#]*that[\s*#]*it[\s*#]*will[\s*#]*be[\s*#]*useful[;:,][\s*#]*but[\s*#]*WITHOUT[\s*#]*ANY[\s*#]*WARRANTY[;:,][\s*#]*without[\s*#]*even[\s*#]*the[\s*#]*implied[\s*#]*warranty[\s*#]*of[\s*#]*MERCHANTABILITY[\s*#]*or[\s*#]*FITNESS[\s*#]*FOR[\s*#]*A[\s*#]*PARTICULAR[\s*#]*PURPOSE.[\s*#]*See[\s*#]*the[\s*#]*GNU[\s*#]*General[\s*#]*Public[\s*#]*License[\s*#]*for[\s*#]*more[\s*#]*details.[\s*]*\*\/|/* SPDX-License-Identifier: GPL-3.0-or-later */|' $(cat filelist)
perl -i -p0e 's|(\#\#*)[\w]*.*is free software[:;][\#\s]*you[\#\s]*can[\#\s]*redistribute[\#\s]*it[\#\s]*and\/or[\#\s]*modify[\#\s]*it[\s\#]*under[\s \#]*the[\s\#]*terms[\s\#]*of[\s\#]*the[\s\#]*GNU[\s\#]*General[\s\#]*Public[\s\#]*License[\s\#]*as[\s\#]*published[\s\#]*by[\s\#]*the[\s\#]*Free[\s\#]*Software[\s\#]*Foundation[;,][\s\#]*version[\s\#]*2[\s\#]*of[\s\#]*the[\s\#]*License.*[\s\#]*This[\s\#]*program[\s\#]*is[\s\#]*distributed[\s\#]*in[\s\#]*the[\s\#]*hope[\s\#]*that[\s\#]*it[\s\#]*will[\#\s]*be[\#\s]*useful,[\#\s]*but[\#\s]*WITHOUT[\#\s]*ANY[\#\s]*WARRANTY;[\#\s]*without[\#\s]*even[\#\s]*the[\#\s]*implied[\#\s]*warranty[\#\s]*of[\#\s]*MERCHANTABILITY[\#\s]*or[\#\s]*FITNESS[\#\s]*FOR[\#\s]*A[\#\s]*PARTICULAR[\#\s]*PURPOSE.[\#\s]*See[\#\s]*the[\#\s]*GNU[\#\s]*General[\#\s]*Public[\#\s]*License[\#\s]*for[\#\s]*more[\#\s]*details.\s(#* *\n)*|\1 SPDX-License-Identifier: GPL-2.0-only\n\n|' $(cat filelist)
perl -i -p0e 's|(\#\#*)[\w*]*.*is free software[:;][\s*]*you[\s*]*can[\s*]*redistribute[\s*]*it[\s*]*and\/or[\s*]*modify[\s*]*it[\s*]*under[\s*]*the[\s*]*terms[\s*]*of[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*as[\s*]*published[\s*]*by[\s*]*the[\s*]*Free[\s*]*Software[\s*]*Foundation[;,][\s*]*version[\s*]*2[\s*]*of[\s*]*the[\s*]*License.[\s*]*This[\s*]*program[\s*]*is[\s*]*distributed[\s*]*in[\s*]*the[\s*]*hope[\s*]*that[\s*]*it[\s*]*will[\s*]*be[\s*]*useful,[\s*]*but[\s*]*WITHOUT[\s*]*ANY[\s*]*WARRANTY;[\s*]*without[\s*]*even[\s*]*the[\s*]*implied[\s*]*warranty[\s*]*of[\s*]*MERCHANTABILITY[\s*]*or[\s*]*FITNESS[\s*]*FOR[\s*]*A[\s*]*PARTICULAR[\s*]*PURPOSE.[\s*]*See[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*for[\s*]*more[\s*]*details.\s(#* *\n)*|\1 SPDX-License-Identifier: GPL-2.0-only\n\n|' $(cat filelist)
Change-Id: I1008a63b804f355a916221ac994701d7584f60ff
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/41177
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2020-05-08 20:48:04 +02:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
2010-02-10 21:31:38 +01:00
|
|
|
|
2016-01-19 16:50:23 +01:00
|
|
|
# Usage: [--debug] [path to xgcc/bin directory]
|
|
|
|
|
|
|
|
# Enable debug output
|
|
|
|
if [ "$1" = "--debug" ]; then
|
|
|
|
shift
|
|
|
|
set -x
|
|
|
|
fi
|
|
|
|
|
2012-11-26 23:33:09 +01:00
|
|
|
TMPFILE=""
|
2015-08-03 16:46:29 +02:00
|
|
|
XGCCPATH=$1
|
|
|
|
|
2016-04-16 00:27:05 +02:00
|
|
|
# payloads under payloads/external crossgcc path
|
|
|
|
if [ -d "$(pwd)/../../../../util/crossgcc/xgcc/bin/" ]
|
|
|
|
then
|
|
|
|
XGCCPATH=${XGCCPATH:-"$(pwd)/../../../../util/crossgcc/xgcc/bin/"}
|
|
|
|
fi
|
|
|
|
|
2015-08-03 16:46:29 +02:00
|
|
|
# libpayload crossgcc path
|
2016-01-05 23:44:02 +01:00
|
|
|
if [ -d "$(pwd)/../../util/crossgcc/xgcc/bin/" ]
|
2015-08-03 16:46:29 +02:00
|
|
|
then
|
2016-01-05 23:44:02 +01:00
|
|
|
XGCCPATH=${XGCCPATH:-"$(pwd)/../../util/crossgcc/xgcc/bin/"}
|
2015-08-03 16:46:29 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# coreboot crossgcc path
|
2016-01-05 23:44:02 +01:00
|
|
|
if [ -d "$(pwd)/util/crossgcc/xgcc/bin/" ]
|
2015-08-03 16:46:29 +02:00
|
|
|
then
|
2016-01-05 23:44:02 +01:00
|
|
|
XGCCPATH=${XGCCPATH:-"$(pwd)/util/crossgcc/xgcc/bin/"}
|
2015-08-03 16:46:29 +02:00
|
|
|
fi
|
2012-11-26 23:33:09 +01:00
|
|
|
|
|
|
|
die() {
|
|
|
|
echo "ERROR: $*" >&2
|
|
|
|
exit 1
|
2010-02-10 21:31:38 +01:00
|
|
|
}
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2012-11-26 23:33:09 +01:00
|
|
|
clean_up() {
|
|
|
|
if [ -n "$TMPFILE" ]; then
|
|
|
|
rm -f "$TMPFILE" "$TMPFILE.c" "$TMPFILE.o"
|
2009-08-12 17:00:51 +02:00
|
|
|
fi
|
2012-11-26 23:33:09 +01:00
|
|
|
}
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2014-05-14 14:30:08 +02:00
|
|
|
trap clean_up EXIT
|
|
|
|
|
|
|
|
|
2012-11-26 23:33:09 +01:00
|
|
|
program_exists() {
|
|
|
|
type "$1" >/dev/null 2>&1
|
|
|
|
}
|
|
|
|
|
2014-05-14 14:26:07 +02:00
|
|
|
|
2016-01-05 23:55:44 +01:00
|
|
|
if [ "$("${XGCCPATH}/iasl" 2>/dev/null | grep -c ACPI)" -gt 0 ]; then
|
2014-05-14 14:26:07 +02:00
|
|
|
IASL=${XGCCPATH}iasl
|
|
|
|
elif [ "$(iasl 2>/dev/null | grep -c ACPI)" -gt 0 ]; then
|
|
|
|
IASL=iasl
|
|
|
|
fi
|
|
|
|
|
|
|
|
if program_exists gcc; then
|
|
|
|
HOSTCC=gcc
|
|
|
|
elif program_exists cc; then
|
|
|
|
HOSTCC=cc
|
|
|
|
else
|
2014-07-14 15:35:42 +02:00
|
|
|
die "no host compiler found"
|
2014-05-14 14:26:07 +02:00
|
|
|
fi
|
|
|
|
|
2016-01-14 04:52:44 +01:00
|
|
|
# try to find the core count using various methods
|
|
|
|
CORES="$(getconf _NPROCESSORS_ONLN 2>/dev/null)"
|
|
|
|
if [ -z "$CORES" ]; then
|
|
|
|
NPROC=$(command -v nproc)
|
|
|
|
if [ -n "$NPROC" ]; then
|
|
|
|
CORES="$($NPROC)"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ -z "$CORES" ]; then
|
|
|
|
SYSCTL=$(command -v sysctl)
|
|
|
|
if [ -n "$SYSCTL" ]; then
|
|
|
|
CORES="$(${SYSCTL} -n hw.ncpu 2>/dev/null)"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ -z "$CORES" ] && [ -f /proc/cpuinfo ]; then
|
|
|
|
CORES="$(grep 'processor' /proc/cpuinfo 2>/dev/null | wc -l)"
|
|
|
|
fi
|
|
|
|
|
2014-05-14 14:26:07 +02:00
|
|
|
cat <<EOF
|
|
|
|
# platform agnostic and host tools
|
2019-07-24 20:16:00 +02:00
|
|
|
XGCCPATH:=${XGCCPATH}
|
2014-05-14 14:26:07 +02:00
|
|
|
IASL:=${IASL}
|
2015-04-09 18:15:09 +02:00
|
|
|
HOSTCC?=${HOSTCC}
|
2016-01-14 04:52:44 +01:00
|
|
|
CPUS?=${CORES}
|
2014-05-14 14:26:07 +02:00
|
|
|
|
|
|
|
EOF
|
|
|
|
|
2012-11-26 23:33:09 +01:00
|
|
|
testcc() {
|
2016-01-05 23:49:32 +01:00
|
|
|
local cc="$1"
|
|
|
|
local cflags="$2"
|
2012-11-26 23:33:09 +01:00
|
|
|
local tmp_c="$TMPFILE.c"
|
|
|
|
local tmp_o="$TMPFILE.o"
|
|
|
|
rm -f "$tmp_c" "$tmp_o"
|
2012-12-20 23:24:08 +01:00
|
|
|
echo "void _start(void) {}" >"$tmp_c"
|
2016-01-05 23:49:32 +01:00
|
|
|
"$cc" -nostdlib -Werror $cflags -c "$tmp_c" -o "$tmp_o" >/dev/null 2>&1
|
2012-11-26 23:33:09 +01:00
|
|
|
}
|
|
|
|
|
2015-08-20 23:36:34 +02:00
|
|
|
testld() {
|
|
|
|
local gcc="$1"
|
|
|
|
local cflags="$2"
|
|
|
|
local ld="$3"
|
|
|
|
local ldflags="$4"
|
|
|
|
local tmp_o="$TMPFILE.o"
|
|
|
|
local tmp_elf="$TMPFILE.elf"
|
|
|
|
rm -f "$tmp_elf"
|
2016-01-05 23:49:32 +01:00
|
|
|
testcc "$gcc" "$cflags" &&
|
|
|
|
$ld -nostdlib -static $ldflags -o "$tmp_elf" "$tmp_o" >/dev/null 2>&1
|
2015-08-20 23:36:34 +02:00
|
|
|
}
|
|
|
|
|
2012-11-26 23:33:09 +01:00
|
|
|
testas() {
|
2015-04-25 22:15:58 +02:00
|
|
|
local gccprefix="$1"
|
2012-11-26 23:33:09 +01:00
|
|
|
local twidth="$2"
|
|
|
|
local arch="$3"
|
|
|
|
local use_dash_twidth="$4"
|
2015-04-25 22:05:10 +02:00
|
|
|
local endian="$5"
|
2012-11-26 23:33:09 +01:00
|
|
|
local obj_file="$TMPFILE.o"
|
|
|
|
local full_arch="elf$twidth-$arch"
|
|
|
|
|
|
|
|
rm -f "$obj_file"
|
|
|
|
[ -n "$use_dash_twidth" ] && use_dash_twidth="--$twidth"
|
2015-04-25 22:05:10 +02:00
|
|
|
[ -n "$endian" ] && endian="-$endian"
|
2016-01-05 23:55:44 +01:00
|
|
|
"${gccprefix}as" $use_dash_twidth $endian -o "$obj_file" "$TMPFILE" \
|
2015-04-25 22:05:10 +02:00
|
|
|
2>/dev/null || return 1
|
2012-11-26 23:33:09 +01:00
|
|
|
|
|
|
|
# Check output content type.
|
2016-01-05 23:55:44 +01:00
|
|
|
local obj_type="$(LANG=C LC_ALL='' "${gccprefix}"objdump -p "$obj_file" 2>/dev/null)"
|
2012-11-26 23:33:09 +01:00
|
|
|
local obj_arch="$(expr "$obj_type" : '.*format \(.[a-z0-9-]*\)')"
|
|
|
|
[ "$obj_arch" = "$full_arch" ] || return 1
|
|
|
|
|
2015-06-04 13:45:40 +02:00
|
|
|
unset ASFLAGS LDFLAGS
|
2020-03-18 15:40:58 +01:00
|
|
|
unset FLAGS_GCC CFLAGS_GCC CFLAGS_CLANG
|
2015-06-04 13:45:40 +02:00
|
|
|
|
|
|
|
if [ -n "$use_dash_twidth" ]; then
|
2012-11-26 23:33:09 +01:00
|
|
|
ASFLAGS="--$twidth"
|
2020-03-18 15:40:58 +01:00
|
|
|
FLAGS_GCC="-m$twidth"
|
2015-06-04 13:45:40 +02:00
|
|
|
CFLAGS_CLANG="-m$twidth"
|
2012-11-26 23:33:09 +01:00
|
|
|
LDFLAGS="-b $full_arch"
|
2012-02-22 19:46:17 +01:00
|
|
|
|
2009-08-12 17:00:51 +02:00
|
|
|
fi
|
|
|
|
|
2012-11-26 23:33:09 +01:00
|
|
|
# Special parameters only available in dash_twidth mode.
|
|
|
|
[ -n "$use_dash_twidth" ] && case "$full_arch" in
|
|
|
|
"elf32-i386" )
|
|
|
|
LDFLAGS="$LDFLAGS -melf_i386"
|
2020-03-18 15:40:58 +01:00
|
|
|
FLAGS_GCC="$FLAGS_GCC -Wl,-b,elf32-i386 -Wl,-melf_i386"
|
2019-06-18 16:53:22 +02:00
|
|
|
CFLAGS_CLANG="$CFLAGS_CLANG -Wl,-b,elf32-i386 -Wl,-melf_i386"
|
2012-11-26 23:33:09 +01:00
|
|
|
;;
|
|
|
|
esac
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2012-11-26 23:33:09 +01:00
|
|
|
return 0
|
|
|
|
}
|
2010-02-10 21:31:38 +01:00
|
|
|
|
2012-11-26 23:33:09 +01:00
|
|
|
detect_special_flags() {
|
|
|
|
local architecture="$1"
|
2015-03-13 22:52:47 +01:00
|
|
|
# Check for an operational -m32/-m64
|
2020-03-18 15:40:58 +01:00
|
|
|
testcc "$GCC" "$FLAGS_GCC -m$TWIDTH " &&
|
|
|
|
FLAGS_GCC="$FLAGS_GCC -m$TWIDTH "
|
2015-03-13 22:52:47 +01:00
|
|
|
|
2012-11-26 23:33:09 +01:00
|
|
|
# Use bfd linker instead of gold if available:
|
2020-03-18 15:40:58 +01:00
|
|
|
testcc "$GCC" "$FLAGS_GCC -fuse-ld=bfd" &&
|
|
|
|
FLAGS_GCC="$FLAGS_GCC -fuse-ld=bfd" && LINKER_SUFFIX='.bfd'
|
2010-02-10 21:31:38 +01:00
|
|
|
|
2020-03-18 15:40:58 +01:00
|
|
|
testcc "$GCC" "$FLAGS_GCC -fno-stack-protector" &&
|
|
|
|
FLAGS_GCC="$FLAGS_GCC -fno-stack-protector"
|
|
|
|
testcc "$GCC" "$FLAGS_GCC -Wl,--build-id=none" &&
|
|
|
|
FLAGS_GCC="$FLAGS_GCC -Wl,--build-id=none"
|
2012-11-26 23:33:09 +01:00
|
|
|
|
2020-03-18 15:40:58 +01:00
|
|
|
testcc "$GCC" "$CFLAGS_GCC -Wno-address-of-packed-member $FLAGS_GCC" &&
|
2020-03-15 07:29:14 +01:00
|
|
|
CFLAGS_GCC="$CFLAGS_GCC -Wno-address-of-packed-member"
|
2012-11-26 23:33:09 +01:00
|
|
|
case "$architecture" in
|
2014-05-14 14:28:21 +02:00
|
|
|
x86)
|
|
|
|
;;
|
2015-06-18 01:07:38 +02:00
|
|
|
x64)
|
|
|
|
;;
|
2015-08-20 23:36:34 +02:00
|
|
|
arm64)
|
2020-03-18 15:40:58 +01:00
|
|
|
testld "$GCC" "$FLAGS_GCC" "${GCCPREFIX}ld${LINKER_SUFFIX}" \
|
2015-08-20 23:36:34 +02:00
|
|
|
"$LDFLAGS --fix-cortex-a53-843419" && \
|
|
|
|
LDFLAGS_ARM64_A53_ERRATUM_843419+=" --fix-cortex-a53-843419"
|
|
|
|
;;
|
2012-11-26 23:33:09 +01:00
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2015-06-04 13:31:38 +02:00
|
|
|
detect_compiler_runtime() {
|
2015-06-08 19:54:01 +02:00
|
|
|
test -z "$GCC" || \
|
2020-03-18 15:40:58 +01:00
|
|
|
CC_RT_GCC="$(${GCC} ${CFLAGS_GCC} ${FLAGS_GCC} -print-libgcc-file-name)"
|
2017-06-22 01:28:46 +02:00
|
|
|
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
|
2015-06-04 13:31:38 +02:00
|
|
|
}
|
|
|
|
|
2012-11-26 23:33:09 +01:00
|
|
|
report_arch_toolchain() {
|
|
|
|
cat <<EOF
|
2015-06-04 13:44:41 +02:00
|
|
|
# elf${TWIDTH}-${TBFDARCH} toolchain (${GCC})
|
2014-07-10 20:38:21 +02:00
|
|
|
ARCH_SUPPORTED+=${TARCH}
|
2014-10-31 16:48:00 +01:00
|
|
|
SUBARCH_SUPPORTED+=${TSUPP-${TARCH}}
|
2016-01-05 22:47:59 +01:00
|
|
|
|
|
|
|
# GCC
|
|
|
|
GCC_CC_${TARCH}:=${GCC}
|
2020-03-18 15:40:58 +01:00
|
|
|
GCC_CFLAGS_${TARCH}:=${CFLAGS_GCC} ${FLAGS_GCC}
|
2019-06-18 16:38:29 +02:00
|
|
|
# Generally available for GCC's cc1:
|
2020-03-15 07:29:14 +01:00
|
|
|
GCC_CFLAGS_${TARCH}+=-fno-delete-null-pointer-checks -Wlogical-op
|
2020-03-18 15:40:58 +01:00
|
|
|
GCC_ADAFLAGS_${TARCH}:=${FLAGS_GCC}
|
2016-01-05 22:47:59 +01:00
|
|
|
GCC_COMPILER_RT_${TARCH}:=${CC_RT_GCC}
|
|
|
|
GCC_COMPILER_RT_FLAGS_${TARCH}:=${CC_RT_EXTRA_GCC}
|
2019-05-22 03:12:44 +02:00
|
|
|
|
|
|
|
# Clang
|
|
|
|
CLANG_CC_${TARCH}:=${CLANG}
|
|
|
|
CLANG_CFLAGS_${TARCH}:=${CFLAGS_CLANG}
|
|
|
|
CLANG_CFLAGS_${TARCH}+=-Qunused-arguments -m${TWIDTH}
|
|
|
|
# tone down clang compiler warnings
|
|
|
|
CLANG_CFLAGS_${TARCH}+=-Wno-unused-variable -Wno-unused-function -Wno-tautological-compare
|
|
|
|
CLANG_CFLAGS_${TARCH}+=-Wno-shift-overflow -Wno-address-of-packed-member -Wno-initializer-overrides
|
|
|
|
CLANG_COMPILER_RT_${TARCH}:=${CC_RT_CLANG}
|
|
|
|
CLANG_COMPILER_RT_FLAGS_${TARCH}:=${CC_RT_EXTRA_CLANG}
|
|
|
|
|
|
|
|
# GCC/Clang Common
|
|
|
|
ifeq (\$(CONFIG_COMPILER_GCC)\$(CONFIG_LP_COMPILER_GCC),y)
|
|
|
|
CC_${TARCH}:=\$(GCC_CC_${TARCH})
|
|
|
|
CFLAGS_${TARCH}:=\$(GCC_CFLAGS_${TARCH})
|
|
|
|
COMPILER_RT_${TARCH}:=\$(GCC_COMPILER_RT_${TARCH})
|
|
|
|
COMPILER_RT_FLAGS_${TARCH}:=\$(GCC_COMPILER_RT_FLAGS_${TARCH})
|
|
|
|
else
|
|
|
|
CC_${TARCH}:=\$(CLANG_CC_${TARCH})
|
|
|
|
CFLAGS_${TARCH}:=\$(CLANG_CFLAGS_${TARCH})
|
|
|
|
COMPILER_RT_${TARCH}:=\$(CLANG_COMPILER_RT_${TARCH})
|
|
|
|
COMPILER_RT_FLAGS_${TARCH}:=\$(CLANG_COMPILER_RT_FLAGS_${TARCH})
|
|
|
|
endif
|
2016-02-02 01:33:37 +01:00
|
|
|
EOF
|
|
|
|
|
|
|
|
# Generally the x86 should build for i686 -- no sse/mmx
|
|
|
|
# instructions since SMM modules are compiled using these
|
|
|
|
# flags. Note that this doesn't prevent a project using
|
|
|
|
# xcompile to explicitly specify -mmsse, etc flags.
|
|
|
|
# The Quark processor doesn't support the instructions
|
|
|
|
# introduced with the Pentium 6 architecture, so allow it
|
|
|
|
# to use i586 instead.
|
2018-11-28 07:40:45 +01:00
|
|
|
if [ "${TARCH}" = "x86_64" ]; then
|
|
|
|
cat <<EOF
|
2019-05-22 03:12:44 +02:00
|
|
|
CFLAGS_${TARCH} += -march=nocona -malign-data=abi
|
2018-11-28 07:40:45 +01:00
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${TARCH}" = "x86_32" ]; then
|
2016-02-02 01:33:37 +01:00
|
|
|
cat <<EOF
|
|
|
|
|
2017-06-20 23:33:28 +02:00
|
|
|
ifneq (\$(CONFIG_USE_MARCH_586)\$(CONFIG_LP_USE_MARCH_586),)
|
2019-05-22 03:12:44 +02:00
|
|
|
CFLAGS_${TARCH} += -march=i586
|
2016-02-02 01:33:37 +01:00
|
|
|
else
|
2019-05-22 03:12:44 +02:00
|
|
|
CFLAGS_${TARCH} += -march=i686
|
2016-02-02 01:33:37 +01:00
|
|
|
endif
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
|
|
|
|
cat <<EOF
|
2016-01-05 22:47:59 +01:00
|
|
|
|
2013-09-03 14:39:48 +02:00
|
|
|
CPP_${TARCH}:=${GCCPREFIX}cpp
|
2012-11-26 23:33:09 +01:00
|
|
|
AS_${TARCH}:=${GCCPREFIX}as ${ASFLAGS}
|
2013-03-23 01:35:56 +01:00
|
|
|
LD_${TARCH}:=${GCCPREFIX}ld${LINKER_SUFFIX} ${LDFLAGS}
|
2016-01-05 22:56:13 +01:00
|
|
|
EOF
|
|
|
|
|
2016-01-07 22:57:26 +01:00
|
|
|
if [ "${TARCH}" = "arm64" ] && \
|
|
|
|
[ -n "${LDFLAGS_ARM64_A53_ERRATUM_843419}" ]; then
|
|
|
|
cat <<EOF
|
2016-01-05 22:56:13 +01:00
|
|
|
|
2016-01-07 22:57:26 +01:00
|
|
|
ifeq (\$(CONFIG_ARM64_A53_ERRATUM_843419),y)
|
2016-01-05 22:56:13 +01:00
|
|
|
LD_${TARCH}+=${LDFLAGS_ARM64_A53_ERRATUM_843419}
|
2015-08-20 23:36:34 +02:00
|
|
|
endif
|
2016-01-05 22:56:13 +01:00
|
|
|
|
|
|
|
EOF
|
2016-01-07 22:57:26 +01:00
|
|
|
fi # if [ "${TARCH}" = "arm64" ]...
|
2016-01-05 22:56:13 +01:00
|
|
|
|
|
|
|
cat <<EOF
|
2019-10-02 21:37:45 +02:00
|
|
|
ifeq (\$(CONFIG_COMPILER_GCC)\$(CONFIG_LP_COMPILER_GCC),y)
|
|
|
|
NM_${TARCH}:=${GCCPREFIX}gcc-nm
|
|
|
|
AR_${TARCH}:=${GCCPREFIX}gcc-ar
|
|
|
|
else
|
|
|
|
NM_${TARCH}:=${GCCPREFIX}nm
|
|
|
|
AR_${TARCH}:=${GCCPREFIX}ar
|
|
|
|
endif
|
2012-11-26 23:33:09 +01:00
|
|
|
OBJCOPY_${TARCH}:=${GCCPREFIX}objcopy
|
|
|
|
OBJDUMP_${TARCH}:=${GCCPREFIX}objdump
|
|
|
|
READELF_${TARCH}:=${GCCPREFIX}readelf
|
|
|
|
STRIP_${TARCH}:=${GCCPREFIX}strip
|
2016-01-15 00:11:57 +01:00
|
|
|
GNATBIND_${TARCH}:=${GCCPREFIX}gnatbind
|
2015-05-20 19:09:45 +02:00
|
|
|
CROSS_COMPILE_${TARCH}:=${GCCPREFIX}
|
2012-11-26 23:33:09 +01:00
|
|
|
|
2016-01-05 22:21:02 +01:00
|
|
|
|
2012-11-26 23:33:09 +01:00
|
|
|
EOF
|
2016-01-05 22:21:02 +01:00
|
|
|
#The two blank lines above are intentional separators
|
2012-11-26 23:33:09 +01:00
|
|
|
}
|
|
|
|
|
2015-04-25 22:15:58 +02:00
|
|
|
# Architecture definitions
|
2019-08-17 00:35:39 +02:00
|
|
|
SUPPORTED_ARCHITECTURES="arm arm64 riscv x64 x86 ppc64"
|
2012-11-26 23:33:09 +01:00
|
|
|
|
2016-01-25 18:15:08 +01:00
|
|
|
# TARCH: local name for the architecture
|
|
|
|
# (used as CC_${TARCH} in the build system)
|
|
|
|
# TBFDARCHS: architecture name in binutils (eg elf32-${TBFDARCH})
|
|
|
|
# TCLIST: first part of the compiler triplet (eg i386 in i386-elf)
|
|
|
|
# TWIDTH: numerical argument for cpu mode: gcc -m${TWIDTH}
|
|
|
|
# TSUPP: supported subarchs (for -mcpu=...)
|
|
|
|
# TABI: typically elf, eabi or linux
|
|
|
|
|
ARM: Generalize armv7 as arm.
There are ARM systems which are essentially heterogeneous multicores where
some cores implement a different ARM architecture version than other cores. A
specific example is the tegra124 which boots on an ARMv4 coprocessor while
most code, including most of the firmware, runs on the main ARMv7 core. To
support SOCs like this, the plan is to generalize the ARM architecture so that
all versions are available, and an SOC/CPU can then select what architecture
variant should be used for each component of the firmware; bootblock,
romstage, and ramstage.
Old-Change-Id: I22e048c3bc72bd56371e14200942e436c1e312c2
Signed-off-by: Gabe Black <gabeblack@google.com>
Reviewed-on: https://chromium-review.googlesource.com/171338
Reviewed-by: Gabe Black <gabeblack@chromium.org>
Commit-Queue: Gabe Black <gabeblack@chromium.org>
Tested-by: Gabe Black <gabeblack@chromium.org>
(cherry picked from commit 8423a41529da0ff67fb9873be1e2beb30b09ae2d)
Signed-off-by: Isaac Christensen <isaac.christensen@se-eng.com>
ARM: Split out ARMv7 code and make it possible to have other arch versions.
We don't always want to use ARMv7 code when building for ARM, so we should
separate out the ARMv7 code so it can be excluded, and also make it possible
to include code for some other version of the architecture instead, all per
build component for cases where we need more than one architecture version
at a time.
The tegra124 bootblock will ultimately need to be ARMv4, but until we have
some ARMv4 code to switch over to we can leave it set to ARMv7.
Old-Change-Id: Ia982c91057fac9c252397b7c866224f103761cc7
Reviewed-on: https://chromium-review.googlesource.com/171400
Reviewed-by: Gabe Black <gabeblack@chromium.org>
Tested-by: Gabe Black <gabeblack@chromium.org>
Commit-Queue: Gabe Black <gabeblack@chromium.org>
(cherry picked from commit 799514e6060aa97acdcf081b5c48f965be134483)
Squashed two related patches for splitting ARM support into general
ARM support and ARMv7 specific pieces.
Change-Id: Ic6511507953a2223c87c55f90252c4a4e1dd6010
Signed-off-by: Isaac Christensen <isaac.christensen@se-eng.com>
Reviewed-on: http://review.coreboot.org/6782
Tested-by: build bot (Jenkins)
2013-10-01 08:00:33 +02:00
|
|
|
arch_config_arm() {
|
|
|
|
TARCH="arm"
|
2014-08-28 00:30:19 +02:00
|
|
|
TBFDARCHS="littlearm"
|
2016-01-30 02:31:34 +01:00
|
|
|
TCLIST="armv7-a armv7a arm"
|
2014-05-14 14:23:28 +02:00
|
|
|
TWIDTH="32"
|
2016-09-08 19:13:59 +02:00
|
|
|
TSUPP="arm armv4 armv7 armv7_m armv7_r"
|
2014-05-14 14:48:31 +02:00
|
|
|
TABI="eabi"
|
2014-05-14 14:23:28 +02:00
|
|
|
}
|
|
|
|
|
2015-01-16 21:19:04 +01:00
|
|
|
arch_config_arm64() {
|
|
|
|
TARCH="arm64"
|
2014-08-28 00:30:19 +02:00
|
|
|
TBFDARCHS="littleaarch64"
|
2014-05-14 14:23:28 +02:00
|
|
|
TCLIST="aarch64"
|
|
|
|
TWIDTH="64"
|
2015-02-17 11:11:55 +01:00
|
|
|
TSUPP="arm64 armv8_64"
|
2014-11-19 18:36:37 +01:00
|
|
|
TABI="elf"
|
2014-05-14 14:23:28 +02:00
|
|
|
}
|
|
|
|
|
2014-10-07 07:18:51 +02:00
|
|
|
arch_config_riscv() {
|
|
|
|
TARCH="riscv"
|
2014-08-28 00:30:19 +02:00
|
|
|
TBFDARCHS="littleriscv"
|
2018-05-02 17:41:18 +02:00
|
|
|
TCLIST="riscv64 riscv"
|
2014-10-07 07:18:51 +02:00
|
|
|
TWIDTH="64"
|
|
|
|
TABI="elf"
|
|
|
|
}
|
|
|
|
|
2015-03-13 22:52:47 +01:00
|
|
|
arch_config_x64() {
|
|
|
|
TARCH="x86_64"
|
|
|
|
TBFDARCHS="x86-64"
|
|
|
|
TCLIST="x86_64"
|
|
|
|
TWIDTH="64"
|
|
|
|
TABI="elf"
|
|
|
|
}
|
|
|
|
|
2014-05-14 14:23:28 +02:00
|
|
|
arch_config_x86() {
|
2014-05-17 14:20:11 +02:00
|
|
|
TARCH="x86_32"
|
2014-08-28 00:30:19 +02:00
|
|
|
TBFDARCHS="i386"
|
2014-05-14 14:23:28 +02:00
|
|
|
TCLIST="i386 x86_64"
|
|
|
|
TWIDTH="32"
|
2014-05-14 14:48:31 +02:00
|
|
|
TABI="elf"
|
2015-06-04 13:31:38 +02:00
|
|
|
CC_RT_EXTRA_GCC="--wrap __divdi3 --wrap __udivdi3 --wrap __moddi3 --wrap __umoddi3"
|
2014-05-14 14:23:28 +02:00
|
|
|
}
|
|
|
|
|
2018-11-30 00:06:50 +01:00
|
|
|
arch_config_ppc64() {
|
|
|
|
TARCH="ppc64"
|
2016-03-10 00:20:26 +01:00
|
|
|
TBFDARCHS="powerpc"
|
|
|
|
TCLIST="powerpc64"
|
2015-12-02 21:24:15 +01:00
|
|
|
TWIDTH="64"
|
2018-11-30 00:06:50 +01:00
|
|
|
TSUPP="ppc64"
|
2016-03-10 00:20:26 +01:00
|
|
|
TABI="linux-gnu" # there is no generic ABI on ppc64
|
|
|
|
CC_RT_EXTRA_GCC="-mcpu=power8 -mbig-endian"
|
2015-12-02 21:24:15 +01:00
|
|
|
}
|
|
|
|
|
2017-06-22 01:28:46 +02:00
|
|
|
# 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"
|
|
|
|
|
2014-05-14 14:32:11 +02:00
|
|
|
test_architecture() {
|
2015-04-25 22:15:58 +02:00
|
|
|
local architecture=$1
|
2015-04-25 22:05:10 +02:00
|
|
|
local endian gccprefix search
|
2014-05-14 14:32:11 +02:00
|
|
|
|
2012-11-26 23:33:09 +01:00
|
|
|
GCCPREFIX="invalid"
|
2015-04-25 22:05:10 +02:00
|
|
|
unset TABI TARCH TBFDARCH TCLIST TENDIAN TSUPP TWIDTH
|
2015-06-04 13:31:38 +02:00
|
|
|
unset CC_RT_EXTRA_GCC CC_RT_EXTRA_CLANG
|
2015-06-04 13:44:41 +02:00
|
|
|
unset GCC CLANG
|
2016-01-05 23:55:44 +01:00
|
|
|
if type "arch_config_$architecture" > /dev/null; then
|
|
|
|
"arch_config_$architecture"
|
2014-05-14 14:23:28 +02:00
|
|
|
else
|
2014-07-14 15:35:42 +02:00
|
|
|
die "no architecture definition for $architecture"
|
2014-05-14 14:23:28 +02:00
|
|
|
fi
|
2012-11-26 23:33:09 +01:00
|
|
|
|
|
|
|
# To override toolchain, define CROSS_COMPILE_$arch or CROSS_COMPILE as
|
|
|
|
# environment variable.
|
|
|
|
# Ex: CROSS_COMPILE_arm="armv7a-cros-linux-gnueabi-"
|
|
|
|
# CROSS_COMPILE_x86="i686-pc-linux-gnu-"
|
2016-01-05 23:55:44 +01:00
|
|
|
search="$(eval echo "\$CROSS_COMPILE_$architecture" 2>/dev/null)"
|
2012-11-26 23:33:09 +01:00
|
|
|
search="$search $CROSS_COMPILE"
|
|
|
|
for toolchain in $TCLIST; do
|
2014-05-14 14:48:31 +02:00
|
|
|
search="$search $XGCCPATH$toolchain-$TABI-"
|
|
|
|
search="$search $toolchain-$TABI-"
|
2013-11-08 19:13:50 +01:00
|
|
|
search="$search $toolchain-linux-gnu-"
|
2016-01-25 18:15:45 +01:00
|
|
|
search="$search $toolchain-linux-"
|
2014-10-07 07:18:51 +02:00
|
|
|
search="$search $toolchain-"
|
2016-02-18 15:30:53 +01:00
|
|
|
search="$search $toolchain-linux-gnueabi-"
|
2012-11-26 23:33:09 +01:00
|
|
|
done
|
2016-01-05 22:21:02 +01:00
|
|
|
echo "###########################################################################"
|
|
|
|
echo "# $architecture"
|
|
|
|
echo "# TARCH_SEARCH=$search"
|
2012-11-26 23:33:09 +01:00
|
|
|
|
|
|
|
# Search toolchain by checking assembler capability.
|
2014-08-28 00:30:19 +02:00
|
|
|
for TBFDARCH in $TBFDARCHS; do
|
2015-04-25 22:15:58 +02:00
|
|
|
for gccprefix in $search ""; do
|
|
|
|
program_exists "${gccprefix}as" || continue
|
2015-04-25 22:05:10 +02:00
|
|
|
for endian in $TENDIAN ""; do
|
2016-05-01 19:41:28 +02:00
|
|
|
{ testas "$gccprefix" "$TWIDTH" "$TBFDARCH" \
|
|
|
|
"" "$endian" ||
|
2015-04-25 22:05:10 +02:00
|
|
|
testas "$gccprefix" "$TWIDTH" "$TBFDARCH" \
|
2016-05-01 19:41:28 +02:00
|
|
|
"TRUE" "$endian" ; } && \
|
2020-03-18 15:40:58 +01:00
|
|
|
testcc "${gccprefix}gcc" "$CFLAGS_GCC" "$FLAGS_GCC" && \
|
2016-05-01 19:41:28 +02:00
|
|
|
GCCPREFIX="$gccprefix" && \
|
|
|
|
break 3
|
2015-04-25 22:05:10 +02:00
|
|
|
done
|
2014-08-28 00:30:19 +02:00
|
|
|
done
|
2012-11-26 23:33:09 +01:00
|
|
|
done
|
2015-06-04 13:44:41 +02:00
|
|
|
if [ "invalid" != "$GCCPREFIX" ]; then
|
|
|
|
GCC="${GCCPREFIX}gcc"
|
|
|
|
fi
|
|
|
|
|
|
|
|
for clang_arch in $TCLIST invalid; do
|
2017-05-10 22:06:31 +02:00
|
|
|
for clang_prefix in $search $XGCCPATH ""; do
|
|
|
|
testcc "${clang_prefix}clang" "-target ${clang_arch}-$TABI -c" && break 2
|
|
|
|
done
|
2015-06-04 13:44:41 +02:00
|
|
|
done
|
2012-11-26 23:33:09 +01:00
|
|
|
|
2015-06-04 13:44:41 +02:00
|
|
|
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.
|
2017-05-10 22:06:31 +02:00
|
|
|
CLANG="${clang_prefix}clang"
|
2017-09-02 10:28:29 +02:00
|
|
|
CFLAGS_CLANG="-target ${clang_arch}-${TABI} $CFLAGS_CLANG -ccc-gcc-name ${GCC}"
|
2015-06-04 13:44:41 +02:00
|
|
|
fi
|
2014-05-14 14:32:11 +02:00
|
|
|
}
|
|
|
|
|
2017-01-30 15:27:35 +01:00
|
|
|
OUT="$(mktemp /tmp/temp.XXXXXX 2>/dev/null || echo /tmp/temp.coreboot.$RANDOM)"
|
|
|
|
rm -f $OUT
|
|
|
|
|
2015-04-25 22:15:58 +02:00
|
|
|
for architecture in $SUPPORTED_ARCHITECTURES; do
|
2017-01-30 15:27:35 +01:00
|
|
|
(
|
|
|
|
TMPFILE="$(mktemp /tmp/temp.XXXXXX 2>/dev/null || echo /tmp/temp.coreboot.$RANDOM)"
|
|
|
|
touch $TMPFILE
|
2016-01-05 23:55:44 +01:00
|
|
|
test_architecture "$architecture"
|
2015-12-07 22:34:46 +01:00
|
|
|
detect_special_flags "$architecture"
|
|
|
|
detect_compiler_runtime "$architecture"
|
|
|
|
report_arch_toolchain
|
2017-01-30 15:27:35 +01:00
|
|
|
clean_up
|
|
|
|
) > $OUT.$architecture &
|
|
|
|
done
|
|
|
|
wait
|
|
|
|
|
|
|
|
for architecture in $SUPPORTED_ARCHITECTURES; do
|
|
|
|
cat $OUT.$architecture
|
|
|
|
rm -f $OUT.$architecture
|
2012-11-26 23:33:09 +01:00
|
|
|
done
|
2015-11-19 15:15:33 +01:00
|
|
|
echo XCOMPILE_COMPLETE:=1
|