@@ -74,53 +74,15 @@ jobs:
7474 go-version-file : go.mod
7575 cache : true
7676
77- # Wrap `zig cc`/`zig c++` in single-binary launchers and point CC/CXX at
78- # them. Why not CC="zig cc -target ..." directly: the cgo build links ~560
79- # object files (webrtc APM + portaudio), whose paths overflow Windows'
80- # ~32KB command-line limit ("fork/exec zig.exe: The filename or extension
81- # is too long"). Go's linker avoids this by writing the args to a @response
82- # file, but only after probing that the linker accepts one -- and the probe
83- # runs only argv[0] of $CC. With a multi-token CC that's bare `zig` (no
84- # `cc` subcommand), so the probe fails, Go skips the response file, and the
85- # full argv overflows. A single-binary CC makes the probe pass. Must run
86- # after Set up Go (it builds the launchers) and before any cgo build.
87- - name : Build zig cgo launchers (Windows)
77+ # Use `zig cc`/`zig c++` directly as the cgo toolchain, exactly as
78+ # .goreleaser.yaml's Windows builds do. Go's cgo splits a multi-token
79+ # CC/CXX into argv, so the `-target` flags are carried through to zig.
80+ - name : Set zig as cgo compiler (Windows)
8881 if : matrix.os == 'windows-latest'
8982 shell : bash
9083 run : |
91- dir="$(cygpath "$RUNNER_TEMP")/zigcc"
92- mkdir -p "$dir"
93- cat > "$dir/main.go" <<'EOF'
94- // Forwards to `zig cc`/`zig c++ -target x86_64-windows-gnu`, picking the
95- // subcommand from its own basename, so $CC/$CXX are single executables.
96- package main
97-
98- import (
99- "os"
100- "os/exec"
101- "path/filepath"
102- "strings"
103- )
104-
105- func main() {
106- sub := "cc"
107- if b := filepath.Base(os.Args[0]); strings.Contains(b, "xx") || strings.Contains(b, "++") {
108- sub = "c++"
109- }
110- cmd := exec.Command("zig", append([]string{sub, "-target", "x86_64-windows-gnu"}, os.Args[1:]...)...)
111- cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
112- if err := cmd.Run(); err != nil {
113- if ee, ok := err.(*exec.ExitError); ok {
114- os.Exit(ee.ExitCode())
115- }
116- os.Exit(1)
117- }
118- }
119- EOF
120- (cd "$dir" && go mod init zigcc && go build -o zcc.exe . && go build -o zxx.exe .)
121- win="$(cygpath -w "$dir")"
122- echo "CC=$win\\zcc.exe" >> "$GITHUB_ENV"
123- echo "CXX=$win\\zxx.exe" >> "$GITHUB_ENV"
84+ echo 'CC=zig cc -target x86_64-windows-gnu' >> "$GITHUB_ENV"
85+ echo 'CXX=zig c++ -target x86_64-windows-gnu' >> "$GITHUB_ENV"
12486
12587 # Go's compiled objects embed COFF /DEFAULTLIB directives (dbghelp,
12688 # bcrypt, ...) that lld resolves directly, bypassing zig's lazy .def->.a
@@ -161,6 +123,9 @@ jobs:
161123 # Go's cgo flag allowlist rejects it unless explicitly permitted (same
162124 # as .goreleaser.yaml's Windows builds). No-op on Linux/macOS.
163125 CGO_CXXFLAGS_ALLOW : -fms-extensions
126+ # zig-0.16 UBSan workaround carried over from .goreleaser.yaml's
127+ # Windows builds; empty (no-op) on Linux/macOS.
128+ CGO_CXXFLAGS : ${{ matrix.os == 'windows-latest' && '-fno-sanitize=all' || '' }}
164129 LIVEKIT_API_KEY : ${{ secrets.LIVEKIT_API_KEY }}
165130 LIVEKIT_API_SECRET : ${{ secrets.LIVEKIT_API_SECRET }}
166131 LIVEKIT_URL : ${{ secrets.LIVEKIT_URL }}
0 commit comments