Files
runc/script/lib.sh
T
Aleksa Sarai 8cdb38cd4e [1.4] build: treat armhf as ARMv7
The intention of commit 531e29e192 ("script/lib.sh: set GOARM=5 for
armel, GOARM=6 for armhf") was to properly support older ARM platforms
with our release builds.

However, we have never been able to support ARMv6 for our builds because
we use the Debian compiler to build the libseccomp we statically compile
into our binaries and (as per the now-deleted comment itself) Debian
treats armhf as being ARMv7 so the final binaries we produced were
always only ever compatible with ARMv7+.

This was a bit of an oddity before but when building libpathrs for
releases we will need to use Rust which makes the target more explicit
(and while it does support armhf, we are using the Debian-packaged Rust
cross-compiler and thus are in the same dilemma with what Debian
considers "armhf" to be).

All-in-all, it's better to just bite the bullet and just follow Debian
here properly.

Fixes: 531e29e192 ("script/lib.sh: set GOARM=5 for armel, GOARM=6 for armhf")
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
(cherry picked from commit 51ae8de054)
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2026-03-12 19:00:13 +09:00

73 lines
1.4 KiB
Bash

#!/bin/bash
# set_cross_vars sets a few environment variables used for cross-compiling,
# based on the architecture specified in $1.
function set_cross_vars() {
GOARCH="$1" # default, may be overridden below
unset GOARM
PLATFORM=linux-gnu
# openSUSE has a custom PLATFORM
if grep -iq "ID_LIKE=.*suse" /etc/os-release; then
PLATFORM=suse-linux
is_suse=1
fi
case $1 in
386)
# Always use the 64-bit compiler to build the 386 binary, which works
# for the more common cross-build method for x86 (namely, the
# equivalent of dpkg --add-architecture).
local cpu_type
if [ -v is_suse ]; then
# There is no x86_64-suse-linux-gcc, so use the native one.
HOST=
cpu_type=i586
else
HOST=x86_64-${PLATFORM}
cpu_type=i686
fi
CFLAGS="-m32 -march=$cpu_type ${CFLAGS[*]}"
;;
amd64)
if [ -n "${is_suse:-}" ]; then
# There is no x86_64-suse-linux-gcc, so use the native one.
HOST=
else
HOST=x86_64-${PLATFORM}
fi
;;
arm64)
HOST=aarch64-${PLATFORM}
;;
armel)
HOST=arm-${PLATFORM}eabi
GOARCH=arm
GOARM=5
;;
armhf)
HOST=arm-${PLATFORM}eabihf
GOARCH=arm
GOARM=7
;;
ppc64le)
HOST=powerpc64le-${PLATFORM}
;;
riscv64)
HOST=riscv64-${PLATFORM}
;;
s390x)
HOST=s390x-${PLATFORM}
;;
*)
echo "set_cross_vars: unsupported architecture: $1" >&2
exit 1
;;
esac
CC="${HOST:+$HOST-}gcc"
STRIP="${HOST:+$HOST-}strip"
export HOST CFLAGS GOARM GOARCH CC STRIP
}