Skip to content

Commit 12addde

Browse files
committed
build by musl instead of glibc
1 parent e54cca1 commit 12addde

File tree

1 file changed

+28
-41
lines changed

1 file changed

+28
-41
lines changed

.github/workflows/release.yml

Lines changed: 28 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
branches:
99
- main
1010
paths:
11+
- '.github/workflows/release.yml'
1112
- 'frontend/**'
1213
- '**.sh'
1314
- '**.go'
@@ -27,7 +28,7 @@ jobs:
2728
- armv5
2829
- 386
2930
- s390x
30-
runs-on: ubuntu-22.04
31+
runs-on: ubuntu-latest
3132
steps:
3233
- name: Checkout repository
3334
uses: actions/checkout@v5.0.0
@@ -45,23 +46,6 @@ jobs:
4546
with:
4647
node-version: '22'
4748
registry-url: 'https://registry.npmjs.org'
48-
49-
- name: Install dependencies
50-
run: |
51-
sudo apt-get update
52-
if [ "${{ matrix.platform }}" == "arm64" ]; then
53-
sudo apt install gcc-aarch64-linux-gnu
54-
elif [ "${{ matrix.platform }}" == "armv7" ]; then
55-
sudo apt install gcc-arm-linux-gnueabihf
56-
elif [ "${{ matrix.platform }}" == "armv6" ]; then
57-
sudo apt install gcc-arm-linux-gnueabihf
58-
elif [ "${{ matrix.platform }}" == "armv5" ]; then
59-
sudo apt install gcc-arm-linux-gnueabi
60-
elif [ "${{ matrix.platform }}" == "386" ]; then
61-
sudo apt install gcc-i686-linux-gnu
62-
elif [ "${{ matrix.platform }}" == "s390x" ]; then
63-
sudo apt install gcc-s390x-linux-gnu
64-
fi
6549

6650
- name: Build frontend
6751
run: |
@@ -77,31 +61,34 @@ jobs:
7761
export CGO_ENABLED=1
7862
export GOOS=linux
7963
export GOARCH=${{ matrix.platform }}
80-
if [ "${{ matrix.platform }}" == "arm64" ]; then
81-
export GOARCH=arm64
82-
export CC=aarch64-linux-gnu-gcc
83-
elif [ "${{ matrix.platform }}" == "armv7" ]; then
84-
export GOARCH=arm
85-
export GOARM=7
86-
export CC=arm-linux-gnueabihf-gcc
87-
elif [ "${{ matrix.platform }}" == "armv6" ]; then
88-
export GOARCH=arm
89-
export GOARM=6
90-
export CC=arm-linux-gnueabihf-gcc
91-
elif [ "${{ matrix.platform }}" == "armv5" ]; then
92-
export GOARCH=arm
93-
export GOARM=5
94-
export CC=arm-linux-gnueabi-gcc
95-
elif [ "${{ matrix.platform }}" == "386" ]; then
96-
export GOARCH=386
97-
export CC=i686-linux-gnu-gcc
98-
elif [ "${{ matrix.platform }}" == "s390x" ]; then
99-
export GOARCH=s390x
100-
export CC=s390x-linux-gnu-gcc
101-
fi
64+
# Use Bootlin prebuilt cross-toolchains (musl 1.2.5 in stable series)
65+
case "${{ matrix.platform }}" in
66+
amd64) BOOTLIN_ARCH="x86-64" ;;
67+
arm64) BOOTLIN_ARCH="aarch64" ;;
68+
armv7) BOOTLIN_ARCH="armv7-eabihf"; export GOARCH=arm GOARM=7 ;;
69+
armv6) BOOTLIN_ARCH="armv6-eabihf"; export GOARCH=arm GOARM=6 ;;
70+
armv5) BOOTLIN_ARCH="armv5-eabi"; export GOARCH=arm GOARM=5 ;;
71+
386) BOOTLIN_ARCH="x86-i686" ;;
72+
s390x) BOOTLIN_ARCH="s390x-z13" ;;
73+
esac
74+
echo "Resolving Bootlin musl toolchain for arch=$BOOTLIN_ARCH (platform=${{ matrix.platform }})"
75+
TARBALL_BASE="https://toolchains.bootlin.com/downloads/releases/toolchains/$BOOTLIN_ARCH/tarballs/"
76+
TARBALL_URL=$(curl -fsSL "$TARBALL_BASE" | grep -oE "${BOOTLIN_ARCH}--musl--stable-[^\"]+\\.tar\\.xz" | sort -r | head -n1)
77+
[ -z "$TARBALL_URL" ] && { echo "Failed to locate Bootlin musl toolchain for arch=$BOOTLIN_ARCH" >&2; exit 1; }
78+
echo "Downloading: $TARBALL_URL"
79+
cd /tmp
80+
curl -fL -sS -o "$(basename "$TARBALL_URL")" "$TARBALL_BASE/$TARBALL_URL"
81+
tar -xf "$(basename "$TARBALL_URL")"
82+
TOOLCHAIN_DIR=$(find . -maxdepth 1 -type d -name "${BOOTLIN_ARCH}--musl--stable-*" | head -n1)
83+
export PATH="$(realpath "$TOOLCHAIN_DIR")/bin:$PATH"
84+
export CC=$(realpath "$(find "$TOOLCHAIN_DIR/bin" -name '*-gcc.br_real' -type f -executable | head -n1)")
85+
[ -z "$CC" ] && { echo "No gcc.br_real found in $TOOLCHAIN_DIR/bin" >&2; exit 1; }
86+
cd -
10287
10388
### Build s-ui
104-
go build -ldflags="-w -s" -tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor" -o sui main.go
89+
go build -ldflags="-w -s -linkmode external -extldflags '-static'" -tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor" -o sui main.go
90+
file sui
91+
ldd sui || echo "Static binary confirmed"
10592
10693
mkdir s-ui
10794
cp sui s-ui/

0 commit comments

Comments
 (0)