fix(build): use the GNU linker's stack flag on *-pc-windows-gnu - #3239
fix(build): use the GNU linker's stack flag on *-pc-windows-gnu#3239kamusmg wants to merge 1 commit into
Conversation
`/STACK:8388608` is MSVC link.exe syntax. GNU ld reads it as a file path and aborts with `cannot find /STACK:8388608`, so the crate does not link at all on x86_64-pc-windows-gnu. CI only covers windows-latest (msvc), so the target has been silently unbuildable. Emit `-Wl,--stack,8388608` there instead, and gate on the target rather than the host: inside a build script `#[cfg(windows)]` describes the machine compiling build.rs, so it also fires when cross-compiling away from Windows and misses cross-compiling toward it. CARGO_CFG_TARGET_OS/ENV is the target-accurate source.
|
Confirming this from the user side, and it's worse than a nicety: current This patch fixes it. I've been carrying it in a local fork build since 2026-08-08 and building rtk on that target daily since, with no issues. It still merges cleanly with Worth noting for triage priority: this also blocks validating any other Windows PR from a gnu toolchain, since you can't build the baseline to compare against. I hit exactly that today and had to apply this patch locally just to run |
Summary
rtkdoes not build at all onx86_64-pc-windows-gnu:build.rsemitscargo:rustc-link-arg=/STACK:8388608, which is MSVClink.exesyntax. GNU ld reads/STACK:8388608as a file path and aborts. CI only coverswindows-latest(msvc), so the gnu target has been silently unbuildable.Emit
-Wl,--stack,8388608there instead, keeping/STACK:for msvc so the original intent (a larger main-thread stack for clap's command graph) is preserved on both.Also switches the gate from
#[cfg(windows)]toCARGO_CFG_TARGET_OS/CARGO_CFG_TARGET_ENV. Inside a build script#[cfg(windows)]describes the host compilingbuild.rs, not the target, so today it fires when cross-compiling away from Windows and misses cross-compiling toward it.Test plan
cargo fmt --all -- --check— cleancargo clippy --all-targets— cleancargo test --allonx86_64-pc-windows-gnu— 2511 passed, 0 failed (this target could not produce a binary before this change)rtk --version,rtk grep,rtk find,rtk git statusall start and run — the larger stack is still applied, just spelled for the right linker