Skip to content

Commit db2ba88

Browse files
committed
fix: build arm64 bridge with GOOS=android for Termux compatibility
Android's Bionic libc requires PT_TLS alignment >= 64 for ARM64, but GOOS=linux produces alignment=8, causing the linker to abort with 'executable's TLS segment is underaligned'. Fix: build linux/arm64 binary with GOOS=android (which omits the TLS segment entirely, since static PIE binaries don't need it). Filename stays cya-bridge-linux-arm64 so the install script works. Verified: ELF shows e_type=3 (PIE), no PT_TLS segment.
1 parent abec1ab commit db2ba88

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

scripts/build-bridge.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,18 @@ build_one() {
3434
wanted "$id" || return 0
3535
echo "Building ${goos}/${goarch} -> ${out}"
3636
pie=""
37-
# Android/Termux requires PIE executables (ET_DYN / e_type=3).
38-
# MIPS does not support PIE, skip it there.
39-
[ "$goos" = "linux" ] && [ "$goarch" != "mips" ] && [ "$goarch" != "mipsle" ] && \
40-
[ "$goarch" != "mips64" ] && [ "$goarch" != "mips64le" ] && pie="-buildmode=pie"
37+
# Android/Termux:
38+
# 1. Requires PIE executables (ET_DYN / e_type=3). MIPS does not support PIE.
39+
# 2. Bionic libc requires PT_TLS alignment >= 64. GOOS=linux produces align=8.
40+
# GOOS=android avoids this by omitting the TLS segment entirely.
41+
# So for arm64 (the common Android architecture), build with GOOS=android.
42+
if [ "$goarch" = "arm64" ] && [ "$goos" = "linux" ]; then
43+
goos=android
44+
fi
45+
# PIE for all Linux/Android targets except MIPS (MIPS doesn't support it)
46+
if [ "$goos" = "linux" ] || [ "$goos" = "android" ]; then
47+
case "$goarch" in mips*|mips64*) ;; *) pie="-buildmode=pie" ;; esac
48+
fi
4149
(
4250
cd "$BRIDGE"
4351
if [ "$gomips" = "softfloat" ]; then

0 commit comments

Comments
 (0)