From 27aa6dbb8a6c8e9ff870a1a8233f83d9fe2b5e18 Mon Sep 17 00:00:00 2001 From: yiguo Date: Wed, 29 Jul 2026 13:49:12 +0800 Subject: [PATCH] Fix Windows ARM64 build toolchain --- .github/workflows/build.yml | 56 +++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a887d5be..fb4ec44f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -84,6 +84,62 @@ jobs: - name: Download Go modules run: go mod download + # ========================= + # Windows ARM64 toolchain + # ========================= + - name: Install LLVM-MinGW for Windows ARM64 + if: matrix.target == 'windows' && matrix.arch == 'arm64' + shell: pwsh + env: + GH_TOKEN: ${{ github.token }} + run: | + $headers = @{ + Accept = "application/vnd.github+json" + Authorization = "Bearer $env:GH_TOKEN" + "X-GitHub-Api-Version" = "2022-11-28" + } + $release = Invoke-RestMethod ` + -Headers $headers ` + -Uri "https://api.github.com/repos/mstorsjo/llvm-mingw/releases/latest" + $asset = $release.assets | + Where-Object { $_.name -match "^llvm-mingw-.+-ucrt-aarch64\.zip$" } | + Select-Object -First 1 + if ($null -eq $asset) { + throw "The latest LLVM-MinGW release has no ARM64 UCRT archive" + } + + $archivePath = Join-Path $env:RUNNER_TEMP $asset.name + $extractPath = Join-Path $env:RUNNER_TEMP "llvm-mingw" + Write-Host "Downloading LLVM-MinGW $($release.tag_name): $($asset.name)" + Invoke-WebRequest -Uri $asset.browser_download_url -OutFile $archivePath + Expand-Archive -LiteralPath $archivePath -DestinationPath $extractPath + + $binPath = Get-ChildItem -LiteralPath $extractPath -Directory | + ForEach-Object { Join-Path $_.FullName "bin" } | + Where-Object { Test-Path (Join-Path $_ "gcc.exe") } | + Select-Object -First 1 + if ($null -eq $binPath) { + throw "LLVM-MinGW bin directory was not found in $extractPath" + } + $binPath | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + + - name: Verify Windows ARM64 CGo toolchain + if: matrix.target == 'windows' && matrix.arch == 'arm64' + shell: pwsh + run: | + where.exe gcc.exe + where.exe g++.exe + + $gccTarget = (& gcc.exe -dumpmachine).Trim() + $gxxTarget = (& g++.exe -dumpmachine).Trim() + $expectedTarget = '^aarch64-w64-(windows-gnu|mingw32)$' + if ($gccTarget -notmatch $expectedTarget) { + throw "Unexpected gcc target: $gccTarget" + } + if ($gxxTarget -notmatch $expectedTarget) { + throw "Unexpected g++ target: $gxxTarget" + } + # ========================= # Apple toolchain # =========================