summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2020-02-07 23:06:16 +0200
committerTimo Teräs <timo.teras@iki.fi>2020-02-07 23:14:23 +0200
commitc9d3df08b3d2824e4f2b3b1e901fee08447f5b61 (patch)
tree5c96e2dff1c0f2342c4a3f0fdd2a83db8d538544
parent57185172c502812aa59b3fd28360377477a1a65e (diff)
downloadabuild-c9d3df08b3d2824e4f2b3b1e901fee08447f5b61.tar.bz2
abuild-c9d3df08b3d2824e4f2b3b1e901fee08447f5b61.tar.xz
functions.sh: exclusively use apk --print-arch to detect build arch
Originally "gcc -dumpmachine" was used to detect build gcc triplet. However, abuild does not depend on gcc or build-base (but installs it if needed to build) so gcc might not be there. Additionally abuild-sign can be used standalone, and does not have gcc dependency. Using ${CC:-gcc} is problematic in cross-compile, as CC might be already set for the cross-compiler and would result giving the target host triplet. It was deemed simplest to use "apk --print-arch" exclusively to detect the builder host type, or specify CBUILD manually. If there is need to use abuild/abuild-sign on non-Alpine hosts withou apk, we can later add fallback that uses "uname -m" to detect the architecture and guess Alpine CBUILD from it. Fixes #9974 Fixes: 5adf47c1 "functions.sh: use apk --print-arch for CARCH if gcc is missing" Fixes: 95cd15c0 "functions.sh: dont die if gcc is missing"
-rw-r--r--functions.sh.in13
1 files changed, 5 insertions, 8 deletions
diff --git a/functions.sh.in b/functions.sh.in
index 82ac114..5fef9b0 100644
--- a/functions.sh.in
+++ b/functions.sh.in
@@ -117,21 +117,18 @@ readconfig() {
USE_COLORS=${_USE_COLORS-$USE_COLORS}
USE_CCACHE=${_USE_CCACHE-$USE_CCACHE}
- [ -z "$CBUILD" ] && CBUILD="$(${CC:-gcc} -dumpmachine 2>/dev/null || true)"
+ [ -z "$CBUILD" ] && CBUILD="$(${APK:-apk} --print-arch 2>/dev/null)"
[ -z "$CHOST" ] && CHOST="$CBUILD"
[ -z "$CTARGET" ] && CTARGET="$CHOST"
[ "$(arch_to_hostspec $CBUILD)" != "unknown" ] && CBUILD="$(arch_to_hostspec $CBUILD)"
[ "$(arch_to_hostspec $CHOST)" != "unknown" ] && CHOST="$(arch_to_hostspec $CHOST)"
[ "$(arch_to_hostspec $CTARGET)" != "unknown" ] && CTARGET="$(arch_to_hostspec $CTARGET)"
-
- [ -z "$CARCH" ] && CARCH="$(hostspec_to_arch $CHOST)"
-
- # use apk --print-arch for CARCH if gcc is missing
- if [ "$CARCH" = "unknown" ]; then
- local apk_arch="$(${APK:-apk} --print-arch 2>/dev/null)"
- CARCH=${apk_arch:-unknown}
+ if [ -z "$CBUILD" ]; then
+ echo "Unable to deduce build architecture. Install apk-tools, or set CBUILD."
+ exit 1
fi
+ [ -z "$CARCH" ] && CARCH="$(hostspec_to_arch $CHOST)"
[ -z "$CLIBC" ] && CLIBC="$(hostspec_to_libc $CHOST)"
[ -z "$CBUILD_ARCH" ] && CBUILD_ARCH="$(hostspec_to_arch $CBUILD)"
[ -z "$CTARGET_ARCH" ] && CTARGET_ARCH="$(hostspec_to_arch $CTARGET)"