Skip to content

Commit 0320eca

Browse files
committed
fix build for windows
1 parent 7bc7468 commit 0320eca

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

.github/workflows/windows.yml

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,9 @@ jobs:
2222
platform:
2323
- amd64
2424
- arm64
25-
include:
26-
- platform: amd64
27-
goarch: amd64
28-
suffix: ""
29-
- platform: arm64
30-
goarch: arm64
31-
suffix: "-arm64"
25+
- 386
3226

3327
runs-on: ubuntu-latest
34-
3528
steps:
3629
- name: Checkout repository
3730
uses: actions/checkout@v5.0.0
@@ -60,31 +53,38 @@ jobs:
6053
mv frontend/dist web/html
6154
rm -fr frontend
6255
63-
- name: Build S-UI for Windows
56+
- name: Build s-ui
6457
run: |
6558
export CGO_ENABLED=1
66-
export GOOS=windows
67-
export GOARCH=${{ matrix.goarch }}
68-
69-
# Install MinGW-w64 for Windows cross-compilation
70-
sudo apt-get update
71-
sudo apt-get install -y mingw-w64
72-
73-
# Set CC based on architecture
74-
case "${{ matrix.goarch }}" in
75-
amd64) export CC=x86_64-w64-mingw32-gcc ;;
76-
arm64) export CC=x86_64-w64-mingw32-gcc ;; # MinGW doesn't support ARM64 well, use x86_64
59+
export GOOS=linux
60+
export GOARCH=${{ matrix.platform }}
61+
# Use Bootlin prebuilt cross-toolchains (musl 1.2.5 in stable series)
62+
case "${{ matrix.platform }}" in
63+
amd64) BOOTLIN_ARCH="x86-64" ;;
64+
arm64) BOOTLIN_ARCH="aarch64" ;;
65+
386) BOOTLIN_ARCH="x86-i686" ;;
7766
esac
78-
79-
echo "Using CC: $CC"
80-
echo "GOOS: $GOOS, GOARCH: $GOARCH"
67+
echo "Resolving Bootlin musl toolchain for arch=$BOOTLIN_ARCH (platform=${{ matrix.platform }})"
68+
TARBALL_BASE="https://toolchains.bootlin.com/downloads/releases/toolchains/$BOOTLIN_ARCH/tarballs/"
69+
TARBALL_URL=$(curl -fsSL "$TARBALL_BASE" | grep -oE "${BOOTLIN_ARCH}--musl--stable-[^\"]+\\.tar\\.xz" | sort -r | head -n1)
70+
[ -z "$TARBALL_URL" ] && { echo "Failed to locate Bootlin musl toolchain for arch=$BOOTLIN_ARCH" >&2; exit 1; }
71+
echo "Downloading: $TARBALL_URL"
72+
cd /tmp
73+
curl -fL -sS -o "$(basename "$TARBALL_URL")" "$TARBALL_BASE/$TARBALL_URL"
74+
tar -xf "$(basename "$TARBALL_URL")"
75+
TOOLCHAIN_DIR=$(find . -maxdepth 1 -type d -name "${BOOTLIN_ARCH}--musl--stable-*" | head -n1)
76+
export PATH="$(realpath "$TOOLCHAIN_DIR")/bin:$PATH"
77+
export CC=$(realpath "$(find "$TOOLCHAIN_DIR/bin" -name '*-gcc.br_real' -type f -executable | head -n1)")
78+
[ -z "$CC" ] && { echo "No gcc.br_real found in $TOOLCHAIN_DIR/bin" >&2; exit 1; }
79+
cd -
80+
81+
### Build s-ui
82+
go build -ldflags="-w -s -linkmode external -extldflags '-static'" -tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor" -o sui main.go
83+
file sui
84+
ldd sui || echo "Static binary confirmed"
8185
82-
### Build s-ui for Windows
83-
go build -ldflags="-w -s" -tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor" -o "sui${{ matrix.suffix }}.exe" main.go
84-
file "sui${{ matrix.suffix }}.exe"
85-
8686
mkdir s-ui-windows
87-
cp "sui${{ matrix.suffix }}.exe" s-ui-windows/sui.exe
87+
cp sui s-ui-windows/sui.exe
8888
cp -r windows/* s-ui-windows/
8989
9090
- name: Package

0 commit comments

Comments
 (0)