2015-07-06 15:22:45 +02:00
|
|
|
#!/usr/bin/env bash
|
2010-02-10 21:31:38 +01:00
|
|
|
#
|
|
|
|
# This file is part of the coreboot project.
|
|
|
|
#
|
|
|
|
# Copyright (C) 2007-2010 coresystems GmbH
|
2012-11-26 23:33:09 +01:00
|
|
|
# Copyright (C) 2012 Google Inc
|
2010-02-10 21:31:38 +01:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
2010-03-16 02:17:19 +01:00
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; version 2 of the License.
|
2010-02-10 21:31:38 +01:00
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
Remove address from GPLv2 headers
As per discussion with lawyers[tm], it's not a good idea to
shorten the license header too much - not for legal reasons
but because there are tools that look for them, and giving
them a standard pattern simplifies things.
However, we got confirmation that we don't have to update
every file ever added to coreboot whenever the FSF gets a
new lease, but can drop the address instead.
util/kconfig is excluded because that's imported code that
we may want to synchronize every now and then.
$ find * -type f -exec sed -i "s:Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *MA[, ]*02110-1301[, ]*USA:Foundation, Inc.:" {} +
$ find * -type f -exec sed -i "s:Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA:Foundation, Inc.:" {} +
$ find * -type f -exec sed -i "s:Foundation, Inc., 59 Temple Place[-, ]*Suite 330, Boston, MA *02111-1307[, ]*USA:Foundation, Inc.:" {} +
$ find * -type f -exec sed -i "s:Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.:Foundation, Inc.:" {} +
$ find * -type f
-a \! -name \*.patch \
-a \! -name \*_shipped \
-a \! -name LICENSE_GPL \
-a \! -name LGPL.txt \
-a \! -name COPYING \
-a \! -name DISCLAIMER \
-exec sed -i "/Foundation, Inc./ N;s:Foundation, Inc.* USA\.* *:Foundation, Inc. :;s:Foundation, Inc. $:Foundation, Inc.:" {} +
Change-Id: Icc968a5a5f3a5df8d32b940f9cdb35350654bef9
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-on: http://review.coreboot.org/9233
Tested-by: build bot (Jenkins)
Reviewed-by: Vladimir Serbinenko <phcoder@gmail.com>
2015-03-26 15:17:45 +01:00
|
|
|
# Foundation, Inc.
|
2010-02-10 21:31:38 +01:00
|
|
|
#
|
|
|
|
|
2012-11-26 23:33:09 +01:00
|
|
|
TMPFILE=""
|
2015-08-03 16:46:29 +02:00
|
|
|
XGCCPATH=$1
|
|
|
|
|
|
|
|
# libpayload crossgcc path
|
|
|
|
if [ -d "`pwd`/../../util/crossgcc/xgcc/bin/" ]
|
|
|
|
then
|
|
|
|
XGCCPATH=${XGCCPATH:-"`pwd`/../../util/crossgcc/xgcc/bin/"}
|
|
|
|
fi
|
|
|
|
|
|
|
|
# coreboot crossgcc path
|
|
|
|
if [ -d "`pwd`/util/crossgcc/xgcc/bin/" ]
|
|
|
|
then
|
|
|
|
XGCCPATH=${XGCCPATH:-"`pwd`/util/crossgcc/xgcc/bin/"}
|
|
|
|
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
|
|
|
# Create temporary file(s).
|
|
|
|
TMPFILE="$(mktemp /tmp/temp.XXXX 2>/dev/null || echo /tmp/temp.78gOIUGz)"
|
|
|
|
touch "$TMPFILE"
|
|
|
|
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
|
|
|
|
|
|
|
if [ "$(${XGCCPATH}/iasl 2>/dev/null | grep -c ACPI)" -gt 0 ]; then
|
|
|
|
IASL=${XGCCPATH}iasl
|
|
|
|
elif [ "$(iasl 2>/dev/null | grep -c ACPI)" -gt 0 ]; then
|
|
|
|
IASL=iasl
|
|
|
|
else
|
2014-07-14 15:35:42 +02:00
|
|
|
die "no iasl found"
|
2014-05-14 14:26:07 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
cat <<EOF
|
|
|
|
# platform agnostic and host tools
|
|
|
|
IASL:=${IASL}
|
2015-04-09 18:15:09 +02:00
|
|
|
HOSTCC?=${HOSTCC}
|
2014-05-14 14:26:07 +02:00
|
|
|
|
|
|
|
EOF
|
|
|
|
|
2012-11-26 23:33:09 +01:00
|
|
|
testcc() {
|
|
|
|
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"
|
2015-07-07 00:26:59 +02:00
|
|
|
$1 -nostdlib -Werror $2 -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"
|
|
|
|
testcc $1 $2 &&
|
|
|
|
$3 -nostdlib -static $4 -o "$tmp_elf" "$tmp_o" >/dev/null 2>&1
|
|
|
|
}
|
|
|
|
|
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"
|
|
|
|
${gccprefix}as $use_dash_twidth $endian -o "$obj_file" $TMPFILE \
|
|
|
|
2>/dev/null || return 1
|
2012-11-26 23:33:09 +01:00
|
|
|
|
|
|
|
# Check output content type.
|
2015-08-24 19:26:20 +02:00
|
|
|
local obj_type="$(LANG=C LC_ALL= ${gccprefix}objdump -p $obj_file)"
|
2012-11-26 23:33:09 +01:00
|
|
|
local obj_arch="$(expr "$obj_type" : '.*format \(.[a-z0-9-]*\)')"
|
|
|
|
[ "$obj_arch" = "$full_arch" ] || return 1
|
|
|
|
|
|
|
|
# Architecture matched.
|
2015-04-25 22:15:58 +02:00
|
|
|
GCCPREFIX="$gccprefix"
|
2012-11-26 23:33:09 +01:00
|
|
|
|
2015-06-04 13:45:40 +02:00
|
|
|
unset ASFLAGS LDFLAGS
|
|
|
|
unset CFLAGS_GCC CFLAGS_CLANG
|
|
|
|
|
|
|
|
if [ -n "$use_dash_twidth" ]; then
|
2012-11-26 23:33:09 +01:00
|
|
|
ASFLAGS="--$twidth"
|
2015-06-04 13:20:24 +02:00
|
|
|
CFLAGS_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"
|
2015-06-04 13:20:24 +02:00
|
|
|
CFLAGS_GCC="$CFLAGS_GCC -Wl,-b,elf32-i386 -Wl,-melf_i386"
|
2015-06-04 13:45:40 +02:00
|
|
|
CFLAGS_CLANG="$CFLAGS_GCC -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"
|
|
|
|
# GCC 4.6 is much more picky about unused variables.
|
|
|
|
# Turn off it's warnings for now:
|
2015-06-04 13:44:41 +02:00
|
|
|
testcc "$GCC" "$CFLAGS_GCC -Wno-unused-but-set-variable " &&
|
2015-06-04 13:20:24 +02:00
|
|
|
CFLAGS_GCC="$CFLAGS_GCC -Wno-unused-but-set-variable "
|
2012-11-26 23:33:09 +01:00
|
|
|
|
2015-03-13 22:52:47 +01:00
|
|
|
# Check for an operational -m32/-m64
|
|
|
|
testcc "$GCC" "$CFLAGS_GCC -m$TWIDTH " &&
|
|
|
|
CFLAGS_GCC="$CFLAGS_GCC -m$TWIDTH "
|
|
|
|
|
2012-11-26 23:33:09 +01:00
|
|
|
# Use bfd linker instead of gold if available:
|
2015-06-04 13:44:41 +02:00
|
|
|
testcc "$GCC" "$CFLAGS_GCC -fuse-ld=bfd" &&
|
2015-06-04 13:20:24 +02:00
|
|
|
CFLAGS_GCC="$CFLAGS_GCC -fuse-ld=bfd" && LINKER_SUFFIX='.bfd'
|
2010-02-10 21:31:38 +01:00
|
|
|
|
2015-06-04 13:44:41 +02:00
|
|
|
testcc "$GCC" "$CFLAGS_GCC -fno-stack-protector"&&
|
2015-06-04 13:20:24 +02:00
|
|
|
CFLAGS_GCC="$CFLAGS_GCC -fno-stack-protector"
|
2015-06-04 13:44:41 +02:00
|
|
|
testcc "$GCC" "$CFLAGS_GCC -Wl,--build-id=none" &&
|
2015-06-04 13:20:24 +02:00
|
|
|
CFLAGS_GCC="$CFLAGS_GCC -Wl,--build-id=none"
|
2012-11-26 23:33:09 +01:00
|
|
|
|
|
|
|
case "$architecture" in
|
2014-05-14 14:28:21 +02:00
|
|
|
x86)
|
2013-10-10 19:44:11 +02:00
|
|
|
# Always 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.
|
2015-06-04 13:20:24 +02:00
|
|
|
CFLAGS_GCC="$CFLAGS_GCC -march=i686"
|
2014-05-14 14:28:21 +02:00
|
|
|
;;
|
2015-06-18 01:07:38 +02:00
|
|
|
x64)
|
|
|
|
;;
|
2015-08-20 23:36:34 +02:00
|
|
|
arm64)
|
|
|
|
testld "$GCC" "$CFLAGS_GCC" "${GCCPREFIX}ld${LINKER_SUFFIX}" \
|
|
|
|
"$LDFLAGS --fix-cortex-a53-843419" && \
|
|
|
|
LDFLAGS_ARM64_A53_ERRATUM_843419+=" --fix-cortex-a53-843419"
|
|
|
|
;;
|
2014-08-30 01:00:37 +02:00
|
|
|
mipsel)
|
2015-06-04 13:44:41 +02:00
|
|
|
testcc "$GCC" "$CFLAGS_GCC -mno-abicalls -fno-pic" && \
|
2015-06-04 13:20:24 +02:00
|
|
|
CFLAGS_GCC+=" -mno-abicalls -fno-pic"
|
2015-04-25 22:05:10 +02:00
|
|
|
|
|
|
|
# Enforce little endian mode.
|
2015-06-04 13:44:41 +02:00
|
|
|
testcc "$GCC" "$CFLAGS_GCC -EL" && \
|
2015-06-04 13:20:24 +02:00
|
|
|
CFLAGS_GCC+=" -EL"
|
2014-08-30 01:00:37 +02:00
|
|
|
;;
|
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 "$CLANG" || \
|
2015-07-04 23:28:54 +02:00
|
|
|
CC_RT_CLANG="`${CLANG} ${CFLAGS_CLANG} -print-librt-file-name 2>/dev/null`"
|
2015-06-08 19:54:01 +02:00
|
|
|
test -z "$GCC" || \
|
2015-07-04 23:28:54 +02:00
|
|
|
CC_RT_GCC="`${GCC} ${CFLAGS_GCC} -print-libgcc-file-name`"
|
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}}
|
2015-07-09 00:26:49 +02:00
|
|
|
ifeq (\$(CONFIG_COMPILER_GCC)\$(CONFIG_LP_COMPILER_GCC),y)
|
2015-06-04 13:44:41 +02:00
|
|
|
CC_${TARCH}:=${GCC}
|
2015-06-04 13:20:24 +02:00
|
|
|
CFLAGS_${TARCH}:=${CFLAGS_GCC}
|
2015-06-04 13:31:38 +02:00
|
|
|
COMPILER_RT_${TARCH}:=${CC_RT_GCC}
|
|
|
|
COMPILER_RT_FLAGS_${TARCH}:=${CC_RT_EXTRA_GCC}
|
2015-06-04 13:44:41 +02:00
|
|
|
else
|
|
|
|
CC_${TARCH}:=${CLANG}
|
2015-06-04 13:45:40 +02:00
|
|
|
CFLAGS_${TARCH}:=${CFLAGS_CLANG}
|
|
|
|
CFLAGS_${TARCH}+=-no-integrated-as -Qunused-arguments -m${TWIDTH}
|
|
|
|
# tone down compiler warnings
|
|
|
|
CFLAGS_${TARCH}+=-Wno-unused-variable -Wno-unused-function -Wno-tautological-compare -Wno-shift-overflow
|
2015-06-04 13:31:38 +02:00
|
|
|
COMPILER_RT_${TARCH}:=${CC_RT_CLANG}
|
|
|
|
COMPILER_RT_FLAGS_${TARCH}:=${CC_RT_EXTRA_CLANG}
|
2015-06-04 13:44:41 +02:00
|
|
|
endif
|
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}
|
2015-08-20 23:36:34 +02:00
|
|
|
ifeq (\$(CONFIG_ARM64_A53_ERRATUM_843419)\$(CONFIG_LP_ARM64_A53_ERRATUM_843419),y)
|
|
|
|
LD_${TARCH}+=${LDFLAGS_ARM64_A53_ERRATUM_843419}
|
|
|
|
endif
|
2012-11-26 23:33:09 +01:00
|
|
|
NM_${TARCH}:=${GCCPREFIX}nm
|
|
|
|
OBJCOPY_${TARCH}:=${GCCPREFIX}objcopy
|
|
|
|
OBJDUMP_${TARCH}:=${GCCPREFIX}objdump
|
|
|
|
READELF_${TARCH}:=${GCCPREFIX}readelf
|
|
|
|
STRIP_${TARCH}:=${GCCPREFIX}strip
|
|
|
|
AR_${TARCH}:=${GCCPREFIX}ar
|
2015-05-20 19:09:45 +02:00
|
|
|
CROSS_COMPILE_${TARCH}:=${GCCPREFIX}
|
2012-11-26 23:33:09 +01:00
|
|
|
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2015-04-25 22:15:58 +02:00
|
|
|
# Architecture definitions
|
2015-03-13 22:52:47 +01:00
|
|
|
SUPPORTED_ARCHITECTURES="arm arm64 mipsel riscv x64 x86"
|
2012-11-26 23:33:09 +01:00
|
|
|
|
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"
|
2015-07-07 23:34:30 +02:00
|
|
|
TCLIST="armv7-a armv7a"
|
2014-05-14 14:23:28 +02:00
|
|
|
TWIDTH="32"
|
2014-10-21 20:18:20 +02:00
|
|
|
TSUPP="arm armv4 armv7 armv7_m"
|
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"
|
2014-10-07 07:18:51 +02:00
|
|
|
TCLIST="riscv"
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-05-27 16:18:42 +02:00
|
|
|
arch_config_mipsel() {
|
2015-03-28 15:49:46 +01:00
|
|
|
TARCH="mips"
|
2014-08-28 00:30:19 +02:00
|
|
|
TBFDARCHS="tradlittlemips littlemips"
|
2014-05-27 16:18:42 +02:00
|
|
|
TCLIST="mipsel"
|
|
|
|
TWIDTH="32"
|
2015-03-28 15:49:46 +01:00
|
|
|
TSUPP="mips mipsel"
|
2014-05-27 16:18:42 +02:00
|
|
|
TABI="elf"
|
2015-04-25 22:05:10 +02:00
|
|
|
TENDIAN="EL"
|
2014-05-27 16:18:42 +02:00
|
|
|
}
|
|
|
|
|
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
|
2014-05-14 14:23:28 +02:00
|
|
|
if type arch_config_$architecture > /dev/null; then
|
|
|
|
arch_config_$architecture
|
|
|
|
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-"
|
|
|
|
search="$(eval echo \$CROSS_COMPILE_$architecture 2>/dev/null)"
|
|
|
|
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-"
|
2014-10-07 07:18:51 +02:00
|
|
|
search="$search $toolchain-"
|
2012-11-26 23:33:09 +01:00
|
|
|
done
|
|
|
|
echo "# $architecture TARCH_SEARCH=$search"
|
|
|
|
|
|
|
|
# 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
|
|
|
|
testas "$gccprefix" "$TWIDTH" "$TBFDARCH" \
|
2015-06-04 13:44:41 +02:00
|
|
|
"" "$endian" && break 3
|
2015-04-25 22:05:10 +02:00
|
|
|
testas "$gccprefix" "$TWIDTH" "$TBFDARCH" \
|
2015-06-04 13:44:41 +02:00
|
|
|
"TRUE" "$endian" && 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
|
|
|
|
testcc "clang" "-target ${clang_arch}-$TABI -c" && break
|
|
|
|
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.
|
|
|
|
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
|
2014-05-14 14:32:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# This loops over all supported architectures.
|
2015-04-25 22:15:58 +02:00
|
|
|
for architecture in $SUPPORTED_ARCHITECTURES; do
|
2015-04-25 22:05:10 +02:00
|
|
|
if test_architecture $architecture; then
|
|
|
|
detect_special_flags "$architecture"
|
2015-06-04 13:31:38 +02:00
|
|
|
detect_compiler_runtime "$architecture"
|
2015-04-25 22:05:10 +02:00
|
|
|
report_arch_toolchain
|
|
|
|
fi
|
2012-11-26 23:33:09 +01:00
|
|
|
done
|