forked from opencontainers/runc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scripts: add proper 386 and amd64 target triples and builds
We need these to match the Makefile detection of the right gcc for runc-dmz, as well as making sure that everything builds properly for our cross-i386 tests. While we're at it, add x86 to the list of build targets for release builds (presumably nobody will use it, but since we do test builds of this anyway it probably won't hurt). In addition, clean up the handling of the native architecture build by treating it the same as any other build (ensuring that building runc from a different platform will work the same way regardless of the native architecture). In practice, the build works the same way as before. Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
- Loading branch information
Showing
5 changed files
with
83 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,74 @@ | ||
#!/bin/bash | ||
|
||
# NOTE: Make sure you keep this file in sync with cc_platform.mk. | ||
|
||
# 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-linux-gnu | ||
HOST=aarch64-${PLATFORM} | ||
;; | ||
armel) | ||
HOST=arm-linux-gnueabi | ||
HOST=arm-${PLATFORM}eabi | ||
GOARCH=arm | ||
GOARM=6 | ||
;; | ||
armhf) | ||
HOST=arm-linux-gnueabihf | ||
HOST=arm-${PLATFORM}eabihf | ||
GOARCH=arm | ||
GOARM=7 | ||
;; | ||
ppc64le) | ||
HOST=powerpc64le-linux-gnu | ||
HOST=powerpc64le-${PLATFORM} | ||
;; | ||
riscv64) | ||
HOST=riscv64-linux-gnu | ||
HOST=riscv64-${PLATFORM} | ||
;; | ||
s390x) | ||
HOST=s390x-linux-gnu | ||
HOST=s390x-${PLATFORM} | ||
;; | ||
*) | ||
echo "set_cross_vars: unsupported architecture: $1" >&2 | ||
exit 1 | ||
;; | ||
esac | ||
|
||
CC=$HOST-gcc | ||
STRIP=$HOST-strip | ||
CC="${HOST:+$HOST-}gcc" | ||
STRIP="${HOST:+$HOST-}strip" | ||
|
||
export HOST GOARM GOARCH CC STRIP | ||
export HOST CFLAGS GOARM GOARCH CC STRIP | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters