From 8fc828d41611f136190ff00bd8d36ec780945907 Mon Sep 17 00:00:00 2001 From: spiritlhl <103393591+spiritLHLS@users.noreply.github.com> Date: Sun, 20 Jul 2025 11:16:35 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B0=9D=E8=AF=95=E4=BD=BF=E7=94=A8musl?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E8=80=8C=E4=B8=8D=E6=98=AFglibc=E7=BC=96?= =?UTF-8?q?=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build_binary.old | 467 ++++++++++++++++++++++++++++ .github/workflows/build_binary.yaml | 96 ++++-- 2 files changed, 538 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/build_binary.old diff --git a/.github/workflows/build_binary.old b/.github/workflows/build_binary.old new file mode 100644 index 00000000..9268e369 --- /dev/null +++ b/.github/workflows/build_binary.old @@ -0,0 +1,467 @@ +name: Build and Release +on: + workflow_dispatch: + tags: + - "v*.*.*" + +jobs: + build: + name: Release Check And Build + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get latest tag + id: tag + run: | + TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.1.0") + echo "tag=$TAG" >> $GITHUB_OUTPUT + echo "version=${TAG#v}" >> $GITHUB_OUTPUT + + - name: Generate changelog + id: changelog + run: | + TAG="${{ steps.tag.outputs.tag }}" + PREV_TAG=$(git describe --tags --abbrev=0 "$TAG^" 2>/dev/null || echo "") + if [ -z "$PREV_TAG" ]; then + CHANGELOG=$(git log --oneline --pretty=format:"* %H %s" "$TAG" | head -20) + else + CHANGELOG=$(git log --oneline --pretty=format:"* %H %s" "$PREV_TAG..$TAG") + fi + FULL_CHANGELOG="## Changelog"$'\n'"$CHANGELOG" + echo "$FULL_CHANGELOG" > changelog.txt + echo "changelog<> $GITHUB_OUTPUT + echo "$FULL_CHANGELOG" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Create or update release + run: | + TAG="${{ steps.tag.outputs.tag }}" + CHANGELOG_BODY=$(cat changelog.txt | jq -Rs .) + RELEASE_EXISTS=$(curl -s -H "Authorization: Bearer ${{ secrets.GHT }}" "https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG" | jq -r '.id // empty') + if [ -z "$RELEASE_EXISTS" ]; then + curl -s -X POST -H "Authorization: Bearer ${{ secrets.GHT }}" \ + -H "Content-Type: application/json" \ + -d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"body\":$CHANGELOG_BODY,\"draft\":false,\"prerelease\":false}" \ + "https://api.github.com/repos/${{ github.repository }}/releases" + else + curl -s -X PATCH -H "Authorization: Bearer ${{ secrets.GHT }}" \ + -H "Content-Type: application/json" \ + -d "{\"body\":$CHANGELOG_BODY}" \ + "https://api.github.com/repos/${{ github.repository }}/releases/$RELEASE_EXISTS" + fi + + - name: Delete existing release assets + run: | + TAG="${{ steps.tag.outputs.tag }}" + RELEASE_ID=$(curl -s -H "Authorization: Bearer ${{ secrets.GHT }}" "https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG" | jq -r '.id') + if [ "$RELEASE_ID" != "null" ]; then + ASSETS=$(curl -s -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID/assets" | jq -r '.[] | .id') + for asset in $ASSETS; do + curl -s -X DELETE -H "Authorization: Bearer ${{ secrets.GHT }}" "https://api.github.com/repos/${{ github.repository }}/releases/assets/$asset" + done + sleep 30 + fi + + release-binary: + name: Release Go Binary + needs: build + strategy: + fail-fast: false + matrix: + include: + - goos: linux + goarch: amd64 + cgo_enabled: "1" + cc: x86_64-linux-gnu-gcc + cflags: "-O2 -static -fno-stack-protector" + ldflags: "-extldflags=-static -s -w" + packages: "build-essential gcc" + runner: ubuntu-latest + + - goos: linux + goarch: 386 + cgo_enabled: "1" + cc: x86_64-linux-gnu-gcc + cflags: "-m32 -O1 -march=i686 -mtune=generic -fno-stack-protector" + ldflags: "-extldflags=-static -s -w" + packages: "build-essential gcc-multilib" + runner: ubuntu-latest + + - goos: linux + goarch: arm64 + cgo_enabled: "1" + cc: aarch64-linux-gnu-gcc + cflags: "-O1 -fno-stack-protector" + ldflags: "-extldflags=-static -s -w" + packages: "build-essential gcc-aarch64-linux-gnu" + runner: ubuntu-latest + + - goos: linux + goarch: riscv64 + cgo_enabled: "1" + cc: riscv64-linux-gnu-gcc + cflags: "-O1 -fno-stack-protector" + ldflags: "-extldflags=-static -s -w" + packages: "build-essential gcc-riscv64-linux-gnu" + runner: ubuntu-latest + + - goos: linux + goarch: mips64 + cgo_enabled: "1" + cc: mips64-linux-gnuabi64-gcc + cflags: "-O1 -fno-stack-protector" + ldflags: "-extldflags=-static -s -w" + packages: "build-essential gcc-mips64-linux-gnuabi64" + runner: ubuntu-latest + + - goos: linux + goarch: mips64le + cgo_enabled: "1" + cc: mips64el-linux-gnuabi64-gcc + cflags: "-O1 -fno-stack-protector" + ldflags: "-extldflags=-static -s -w" + packages: "build-essential gcc-mips64el-linux-gnuabi64" + runner: ubuntu-latest + + - goos: linux + goarch: ppc64le + cgo_enabled: "1" + cc: powerpc64le-linux-gnu-gcc + cflags: "-O1 -fno-stack-protector" + ldflags: "-extldflags=-static -s -w" + packages: "build-essential gcc-powerpc64le-linux-gnu" + runner: ubuntu-latest + + - goos: linux + goarch: arm + # goarm: 7 + cgo_enabled: "1" + cc: arm-linux-gnueabihf-gcc + cflags: "-O1 -fno-stack-protector" + ldflags: "-extldflags=-static -s -w" + packages: "build-essential gcc-arm-linux-gnueabihf" + runner: ubuntu-latest + + - goos: windows + goarch: amd64 + cgo_enabled: "1" + cc: x86_64-w64-mingw32-gcc + cflags: "-O2 -static-libgcc -static-libstdc++" + ldflags: "-extldflags=-static -s -w" + packages: "build-essential gcc-mingw-w64-x86-64" + runner: ubuntu-latest + + - goos: windows + goarch: 386 + cgo_enabled: "1" + cc: i686-w64-mingw32-gcc + cflags: "-O2 -static-libgcc -static-libstdc++" + ldflags: "-extldflags=-static -s -w" + packages: "build-essential gcc-mingw-w64-i686" + runner: ubuntu-latest + + - goos: windows + goarch: arm64 + cgo_enabled: "0" + ldflags: "-extldflags=-static -s -w" + packages: "build-essential" + runner: ubuntu-latest + + - goos: darwin + goarch: amd64 + cgo_enabled: "0" + ldflags: "-s -w" + runner: macos-latest + + - goos: darwin + goarch: arm64 + cgo_enabled: "0" + ldflags: "-s -w" + runner: macos-latest + + - goos: linux + goarch: s390x + cgo_enabled: "0" + ldflags: "-s -w" + runner: ubuntu-latest + + - goos: linux + goarch: mips + cgo_enabled: "0" + ldflags: "-s -w" + runner: ubuntu-latest + + - goos: linux + goarch: mipsle + cgo_enabled: "0" + ldflags: "-s -w" + runner: ubuntu-latest + + - goos: linux + goarch: ppc64 + cgo_enabled: "0" + ldflags: "-s -w" + runner: ubuntu-latest + + - goos: windows + goarch: arm64 + cgo_enabled: "0" + ldflags: "-s -w" + runner: ubuntu-latest + + - goos: freebsd + goarch: amd64 + cgo_enabled: "0" + ldflags: "-s -w" + runner: ubuntu-latest + + - goos: freebsd + goarch: arm64 + cgo_enabled: "0" + ldflags: "-s -w" + runner: ubuntu-latest + + runs-on: ${{ matrix.runner }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.24.5 + + - name: Configure Git for Private Modules + run: | + git config --global url."https://${{ secrets.GHT }}@github.com/".insteadOf "https://github.com/" + git config --global url."git@github.com:".insteadOf "https://github.com/" + env: + GITHUB_TOKEN: ${{ secrets.GHT }} + + - name: Install cross-compilation tools + if: matrix.runner != 'macos-latest' + run: | + sudo apt-get update -qq + case "${{ matrix.goos }}-${{ matrix.goarch }}" in + linux-386) + sudo apt-get install -y build-essential gcc-multilib g++-multilib ;; + linux-arm64) + sudo apt-get install -y build-essential gcc-aarch64-linux-gnu ;; + linux-riscv64) + sudo apt-get install -y build-essential gcc-riscv64-linux-gnu ;; + linux-mips64) + sudo apt-get install -y build-essential gcc-mips64-linux-gnuabi64 ;; + linux-mips64le) + sudo apt-get install -y build-essential gcc-mips64el-linux-gnuabi64 ;; + linux-ppc64le) + sudo apt-get install -y build-essential gcc-powerpc64le-linux-gnu ;; + linux-arm) + sudo apt-get install -y build-essential gcc-arm-linux-gnueabihf ;; + windows-amd64|windows-386) + sudo apt-get install -y build-essential gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 ;; + *) + sudo apt-get install -y build-essential ;; + esac + + - name: Get latest tag + id: tag + run: | + TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.1.0") + echo "tag=$TAG" >> $GITHUB_OUTPUT + echo "version=${TAG#v}" >> $GITHUB_OUTPUT + + - name: Build Binary + env: + CGO_ENABLED: ${{ matrix.cgo_enabled }} + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} + CC: ${{ matrix.cc }} + CGO_CFLAGS: ${{ matrix.cflags }} + CGO_LDFLAGS: ${{ matrix.ldflags }} + run: | + go clean -cache -modcache -testcache + + # 设置额外的环境变量 + if [[ -n "${{ matrix.goarm }}" ]]; then + export GOARM=${{ matrix.goarm }} + fi + if [[ -n "${{ matrix.gomips }}" ]]; then + export GOMIPS=${{ matrix.gomips }} + fi + + # 针对 Darwin 的特殊处理 + if [[ "${{ matrix.cgo_enabled }}" == "1" && "${{ matrix.goos }}" == "darwin" ]]; then + if [[ "${{ matrix.goarch }}" == "amd64" ]]; then + export CC="x86_64-apple-darwin21.4-clang" + export CXX="x86_64-apple-darwin21.4-clang++" + elif [[ "${{ matrix.goarch }}" == "arm64" ]]; then + export CC="aarch64-apple-darwin21.4-clang" + export CXX="aarch64-apple-darwin21.4-clang++" + fi + export OSXCROSS_ROOT="${OSXCROSS_ROOT}" + elif [[ "${{ matrix.cgo_enabled }}" == "1" && "${{ matrix.runner }}" != "macos-latest" ]]; then + # 对于 Windows 的特殊处理 + if [[ "${{ matrix.goos }}" == "windows" ]]; then + export CGO_LDFLAGS="-static-libgcc -static-libstdc++" + fi + fi + + # 测试编译器(仅在启用 CGO 时) + if [[ "${{ matrix.cgo_enabled }}" == "1" && -n "$CC" ]]; then + echo 'int main() { return 0; }' > test.c + $CC $CGO_CFLAGS test.c -o test || exit 1 + rm -f test.c test + fi + + # 清理和准备 + rm -rf vendor/ + go mod download + go mod tidy + mkdir -p bin + + # 设置二进制文件名 + BINARY_NAME="goecs" + if [[ "${{ matrix.goos }}" == "windows" ]]; then + BINARY_NAME="${BINARY_NAME}.exe" + fi + + # 构建 LDFLAGS + LDFLAGS="-s -w -X main.version=${{ steps.tag.outputs.version }} -X main.arch=${{ matrix.goarch }}" + if [[ "${{ matrix.cgo_enabled }}" == "1" ]]; then + LDFLAGS="${LDFLAGS} -checklinkname=0 ${{ matrix.ldflags }}" + else + LDFLAGS="${LDFLAGS} -checklinkname=0 ${{ matrix.ldflags }}" + fi + + # 执行构建 + echo "Building for GOOS=$GOOS GOARCH=$GOARCH CGO_ENABLED=$CGO_ENABLED" + go build -a -o bin/$BINARY_NAME -ldflags="$LDFLAGS" -trimpath ./ + + # 验证文件是否存在 + [[ -f "bin/$BINARY_NAME" ]] || exit 1 + + # 显示构建信息 + echo "Built binary: bin/$BINARY_NAME" + ls -la bin/ + if command -v file >/dev/null 2>&1; then + file bin/$BINARY_NAME + fi + + - name: Create ZIP archive + run: | + cd bin + BINARY_NAME="goecs" + if [[ "${{ matrix.goos }}" == "windows" ]]; then + BINARY_NAME="${BINARY_NAME}.exe" + fi + ZIP_NAME="goecs_${{ matrix.goos }}_${{ matrix.goarch }}" + if [[ -n "${{ matrix.goarm }}" ]]; then + ZIP_NAME="${ZIP_NAME}v${{ matrix.goarm }}" + fi + if [[ -n "${{ matrix.gomips }}" ]]; then + ZIP_NAME="${ZIP_NAME}_${{ matrix.gomips }}" + fi + ZIP_NAME="${ZIP_NAME}.zip" + zip "$ZIP_NAME" "$BINARY_NAME" + + - name: Upload to Release + run: | + TAG="${{ steps.tag.outputs.tag }}" + RELEASE_ID=$(curl -s -H "Authorization: Bearer ${{ secrets.GHT }}" "https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG" | jq -r '.id') + cd bin + for file in *.zip; do + if [[ -f "$file" ]]; then + curl -s -H "Authorization: Bearer ${{ secrets.GHT }}" \ + -H "Content-Type: application/zip" \ + --data-binary @"$file" \ + "https://uploads.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID/assets?name=$file" + fi + done + + checksums: + name: Generate Checksums + runs-on: ubuntu-latest + needs: release-binary + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get latest tag + id: tag + run: | + TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.1.0") + echo "tag=$TAG" >> $GITHUB_OUTPUT + + - name: Download release assets + run: | + TAG="${{ steps.tag.outputs.tag }}" + RELEASE_ID=$(curl -s -H "Authorization: Bearer ${{ secrets.GHT }}" "https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG" | jq -r '.id') + mkdir -p assets + ASSETS=$(curl -s -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID/assets") + echo "$ASSETS" | jq -r '.[] | select(.name | endswith(".zip")) | .browser_download_url' | while read url; do + filename=$(basename "$url") + curl -L -H "Authorization: Bearer ${{ secrets.GHT }}" "$url" -o "assets/$filename" + done + + - name: Generate checksums + run: | + cd assets + sha256sum *.zip > checksums.txt + if [[ -f "../goecs.sh" ]]; then + sha256sum ../goecs.sh >> checksums.txt + fi + + - name: Upload checksums + run: | + TAG="${{ steps.tag.outputs.tag }}" + RELEASE_ID=$(curl -s -H "Authorization: Bearer ${{ secrets.GHT }}" "https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG" | jq -r '.id') + curl -s -H "Authorization: Bearer ${{ secrets.GHT }}" \ + -H "Content-Type: text/plain" \ + --data-binary @assets/checksums.txt \ + "https://uploads.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID/assets?name=checksums.txt" + + update-script: + name: Update Script Version + runs-on: ubuntu-latest + needs: checksums + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get latest tag + id: tag + run: | + TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.1.0") + echo "tag=$TAG" >> $GITHUB_OUTPUT + echo "version=${TAG#v}" >> $GITHUB_OUTPUT + + - name: Update goecs.sh version + run: | + VERSION="${{ steps.tag.outputs.version }}" + BRANCH="master" + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global --unset url."git@github.com:".insteadOf || true + git fetch origin $BRANCH + git checkout $BRANCH + if [ -f "goecs.sh" ]; then + sed -i "s/\(_yellow \"Unable to get version info, using default version \).*\(\".*\)/\1$VERSION\2/" "goecs.sh" + sed -i "s/\(ECS_VERSION=\"\).*\(\"\)/\1$VERSION\2/" "goecs.sh" + if ! git diff --quiet "goecs.sh"; then + git add "goecs.sh" + git commit -m "chore: update ECS_VERSION to $VERSION in goecs.sh" + git push origin $BRANCH + fi + fi + env: + GITHUB_TOKEN: ${{ secrets.GHT }} diff --git a/.github/workflows/build_binary.yaml b/.github/workflows/build_binary.yaml index 24e923c2..98197a1a 100644 --- a/.github/workflows/build_binary.yaml +++ b/.github/workflows/build_binary.yaml @@ -76,74 +76,90 @@ jobs: - goos: linux goarch: amd64 cgo_enabled: "1" - cc: x86_64-linux-gnu-gcc + cc: x86_64-linux-musl-gcc + # cc: x86_64-linux-gnu-gcc cflags: "-O2 -static -fno-stack-protector" ldflags: "-extldflags=-static" # -s -w - packages: "build-essential gcc" + # packages: "build-essential gcc" + packages: "musl-tools" runner: ubuntu-latest - goos: linux goarch: 386 cgo_enabled: "1" - cc: x86_64-linux-gnu-gcc - cflags: "-m32 -O1 -march=i686 -mtune=generic -fno-stack-protector" + # cc: x86_64-linux-gnu-gcc + # cflags: "-m32 -O1 -march=i686 -mtune=generic -fno-stack-protector" + cflags: "-O1 -march=i686 -mtune=generic -fno-stack-protector" ldflags: "-extldflags=-static" # -s -w - packages: "build-essential gcc-multilib" + # packages: "build-essential gcc-multilib" + packages: "musl-tools" runner: ubuntu-latest - goos: linux goarch: arm64 cgo_enabled: "1" - cc: aarch64-linux-gnu-gcc + cc: aarch64-linux-musl-gcc + # cc: aarch64-linux-gnu-gcc cflags: "-O1 -fno-stack-protector" ldflags: "-extldflags=-static" # -s -w - packages: "build-essential gcc-aarch64-linux-gnu" + # packages: "build-essential gcc-aarch64-linux-gnu" + packages: "musl-tools" runner: ubuntu-latest - goos: linux goarch: riscv64 cgo_enabled: "1" - cc: riscv64-linux-gnu-gcc + cc: riscv64-linux-musl-gcc + # cc: riscv64-linux-gnu-gcc cflags: "-O1 -fno-stack-protector" ldflags: "-extldflags=-static" # -s -w - packages: "build-essential gcc-riscv64-linux-gnu" + # packages: "build-essential gcc-riscv64-linux-gnu" + packages: "musl-tools" runner: ubuntu-latest - goos: linux goarch: mips64 cgo_enabled: "1" - cc: mips64-linux-gnuabi64-gcc + cc: mips64-linux-musl-gcc + # cc: mips64-linux-gnuabi64-gcc cflags: "-O1 -fno-stack-protector" ldflags: "-extldflags=-static" # -s -w - packages: "build-essential gcc-mips64-linux-gnuabi64" + # packages: "build-essential gcc-mips64-linux-gnuabi64" + packages: "musl-tools" runner: ubuntu-latest - goos: linux goarch: mips64le cgo_enabled: "1" - cc: mips64el-linux-gnuabi64-gcc + cc: mips64el-linux-musl-gcc + # cc: mips64el-linux-gnuabi64-gcc cflags: "-O1 -fno-stack-protector" ldflags: "-extldflags=-static" # -s -w - packages: "build-essential gcc-mips64el-linux-gnuabi64" + # packages: "build-essential gcc-mips64el-linux-gnuabi64" + packages: "musl-tools" runner: ubuntu-latest - goos: linux goarch: ppc64le cgo_enabled: "1" - cc: powerpc64le-linux-gnu-gcc + cc: powerpc64le-linux-musl-gcc + # cc: powerpc64le-linux-gnu-gcc cflags: "-O1 -fno-stack-protector" ldflags: "-extldflags=-static" # -s -w - packages: "build-essential gcc-powerpc64le-linux-gnu" + # packages: "build-essential gcc-powerpc64le-linux-gnu" + packages: "musl-tools" runner: ubuntu-latest - goos: linux goarch: arm # goarm: 7 cgo_enabled: "1" - cc: arm-linux-gnueabihf-gcc + cc: arm-linux-musleabihf-gcc + # cc: arm-linux-gnueabihf-gcc cflags: "-O1 -fno-stack-protector" ldflags: "-extldflags=-static" # -s -w - packages: "build-essential gcc-arm-linux-gnueabihf" + # packages: "build-essential gcc-arm-linux-gnueabihf" + packages: "musl-tools" runner: ubuntu-latest - goos: windows @@ -250,19 +266,45 @@ jobs: sudo apt-get update -qq case "${{ matrix.goos }}-${{ matrix.goarch }}" in linux-386) - sudo apt-get install -y build-essential gcc-multilib g++-multilib ;; + # sudo apt-get install -y build-essential gcc-multilib g++-multilib ;; + wget -q https://musl.cc/i686-linux-musl-cross.tgz -O /tmp/musl-cross.tgz + sudo tar -xzf /tmp/musl-cross.tgz -C /opt/ + sudo ln -sf /opt/i686-linux-musl-cross/bin/i686-linux-musl-gcc /usr/local/bin/ ;; linux-arm64) - sudo apt-get install -y build-essential gcc-aarch64-linux-gnu ;; + # sudo apt-get install -y build-essential gcc-aarch64-linux-gnu ;; + wget -q https://musl.cc/aarch64-linux-musl-cross.tgz -O /tmp/musl-cross.tgz + sudo tar -xzf /tmp/musl-cross.tgz -C /opt/ + sudo ln -sf /opt/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc /usr/local/bin/ ;; linux-riscv64) - sudo apt-get install -y build-essential gcc-riscv64-linux-gnu ;; + # sudo apt-get install -y build-essential gcc-riscv64-linux-gnu ;; + wget -q https://musl.cc/riscv64-linux-musl-cross.tgz -O /tmp/musl-cross.tgz + sudo tar -xzf /tmp/musl-cross.tgz -C /opt/ + sudo ln -sf /opt/riscv64-linux-musl-cross/bin/riscv64-linux-musl-gcc /usr/local/bin/ ;; linux-mips64) - sudo apt-get install -y build-essential gcc-mips64-linux-gnuabi64 ;; + # sudo apt-get install -y build-essential gcc-mips64-linux-gnuabi64 ;; + wget -q https://musl.cc/mips64-linux-musl-cross.tgz -O /tmp/musl-cross.tgz + sudo tar -xzf /tmp/musl-cross.tgz -C /opt/ + sudo ln -sf /opt/mips64-linux-musl-cross/bin/mips64-linux-musl-gcc /usr/local/bin/ ;; linux-mips64le) - sudo apt-get install -y build-essential gcc-mips64el-linux-gnuabi64 ;; + # sudo apt-get install -y build-essential gcc-mips64el-linux-gnuabi64 ;; + wget -q https://musl.cc/mips64el-linux-musl-cross.tgz -O /tmp/musl-cross.tgz + sudo tar -xzf /tmp/musl-cross.tgz -C /opt/ + sudo ln -sf /opt/mips64el-linux-musl-cross/bin/mips64el-linux-musl-gcc /usr/local/bin/ ;; linux-ppc64le) - sudo apt-get install -y build-essential gcc-powerpc64le-linux-gnu ;; + # sudo apt-get install -y build-essential gcc-powerpc64le-linux-gnu ;; + wget -q https://musl.cc/powerpc64le-linux-musl-cross.tgz -O /tmp/musl-cross.tgz + sudo tar -xzf /tmp/musl-cross.tgz -C /opt/ + sudo ln -sf /opt/powerpc64le-linux-musl-cross/bin/powerpc64le-linux-musl-gcc /usr/local/bin/ ;; linux-arm) - sudo apt-get install -y build-essential gcc-arm-linux-gnueabihf ;; + # sudo apt-get install -y build-essential gcc-arm-linux-gnueabihf ;; + wget -q https://musl.cc/arm-linux-musleabihf-cross.tgz -O /tmp/musl-cross.tgz + sudo tar -xzf /tmp/musl-cross.tgz -C /opt/ + sudo ln -sf /opt/arm-linux-musleabihf-cross/bin/arm-linux-musleabihf-gcc /usr/local/bin/ ;; + linux-amd64) + # sudo apt-get install -y build-essential ;; + wget -q https://musl.cc/x86_64-linux-musl-cross.tgz -O /tmp/musl-cross.tgz + sudo tar -xzf /tmp/musl-cross.tgz -C /opt/ + sudo ln -sf /opt/x86_64-linux-musl-cross/bin/x86_64-linux-musl-gcc /usr/local/bin/ ;; windows-amd64|windows-386) sudo apt-get install -y build-essential gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 ;; *) @@ -310,6 +352,10 @@ jobs: if [[ "${{ matrix.goos }}" == "windows" ]]; then export CGO_LDFLAGS="-static-libgcc -static-libstdc++" fi + # 对于 Linux i386 架构的特殊处理 + if [[ "${{ matrix.goos }}" == "linux" && "${{ matrix.goarch }}" == "386" ]]; then + export CC="i686-linux-musl-gcc" + fi fi # 测试编译器(仅在启用 CGO 时) @@ -464,4 +510,4 @@ jobs: fi fi env: - GITHUB_TOKEN: ${{ secrets.GHT }} + GITHUB_TOKEN: ${{ secrets.GHT }} \ No newline at end of file