Skip to content

Commit f5da1f0

Browse files
authored
Make handling of cross-platform emulation for static builds smarter. (netdata#19470)
* Switch to tonistiigi/binfmt for cross-build emulation. It’s actually being actively updated, and it also supports hosts other than x86-64. * Auto-detect existing QEMU user emulation in static build. Instead of relying on the user to explicitly ask for no emulation.
1 parent 42a45b3 commit f5da1f0

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

packaging/makeself/build-static.sh

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,45 +24,47 @@ else
2424
exit 1
2525
fi
2626

27-
DOCKER_IMAGE_NAME="netdata/static-builder:v1"
28-
29-
if [ "${BUILDARCH}" != "$(uname -m)" ] && [ -z "${SKIP_EMULATION}" ]; then
30-
if [ "$(uname -m)" = "x86_64" ]; then
31-
${docker} run --rm --privileged multiarch/qemu-user-static --reset -p yes || exit 1
32-
else
33-
echo "Automatic cross-architecture builds are only supported on x86_64 hosts."
34-
exit 1
35-
fi
36-
fi
37-
3827
case "${BUILDARCH}" in
3928
x86_64) # x86-64-v2 equivalent
29+
QEMU_ARCH="x86_64"
4030
QEMU_CPU="Nehalem-v2"
4131
TUNING_FLAGS="-march=x86-64"
4232
GOAMD64="v1"
4333
;;
4434
armv6l) # Raspberry Pi 1 equivalent
35+
QEMU_ARCH="arm"
4536
QEMU_CPU="arm1176"
4637
TUNING_FLAGS="-march=armv6zk -mtune=arm1176jzf-s"
4738
GOARM="6"
4839
;;
4940
armv7l) # Baseline ARMv7 CPU
41+
QEMU_ARCH="arm"
5042
QEMU_CPU="cortex-a7"
5143
TUNING_FLAGS="-march=armv7-a"
5244
GOARM="7"
5345
;;
5446
aarch64) # Baseline ARMv8 CPU
47+
QEMU_ARCH="aarch64"
5548
QEMU_CPU="cortex-a53"
5649
TUNING_FLAGS="-march=armv8-a"
5750
GOARM64="v8.0"
5851
;;
5952
ppc64le) # Baseline POWER8+ CPU
53+
QEMU_ARCH="ppc64le"
6054
QEMU_CPU="power8nvl"
6155
TUNING_FLAGS="-mcpu=power8 -mtune=power9"
6256
GOPPC64="power8"
6357
;;
6458
esac
6559

60+
[ -f "/proc/sys/fs/binfmt_misc/qemu-${QEMU_ARCH}" ] && SKIP_EMULATION=1
61+
62+
if [ "${BUILDARCH}" != "$(uname -m)" ] && [ -z "${SKIP_EMULATION}" ]; then
63+
${docker} run --rm --privileged tonistiigi/binfmt:master --install "${QEMU_ARCH}" || exit 1
64+
fi
65+
66+
DOCKER_IMAGE_NAME="netdata/static-builder:v1"
67+
6668
if ${docker} inspect "${DOCKER_IMAGE_NAME}" > /dev/null 2>&1; then
6769
if ${docker} image inspect "${DOCKER_IMAGE_NAME}" | grep -q 'Variant'; then
6870
img_platform="$(${docker} image inspect "${DOCKER_IMAGE_NAME}" --format '{{.Os}}/{{.Architecture}}/{{.Variant}}')"

0 commit comments

Comments
 (0)