Repository navigation
fix(build): use correct linker stack-size flag for GNU target - #3547
Closed
andreguzik wants to merge 1 commit into
Closed
andreguzik wants to merge 1 commit into
andreguzik wants to merge 1 commit into
Conversation
build.rs unconditionally emitted /STACK:8388608, which is MSVC linker syntax. On x86_64-pc-windows-gnu (MinGW), this breaks the build: ld.exe: cannot find /STACK:8388608: No such file or directory Select the flag based on CARGO_CFG_TARGET_ENV: keep /STACK: for msvc, use -Wl,--stack,8388608 for gnu.
|
|
4 tasks done
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
build.rsunconditionally emits/STACK:8388608on any Windows build:/STACK:is MSVC linker syntax. Onx86_64-pc-windows-gnu(MinGW), the GNUlinker doesn't understand it and the build fails:
This breaks
cargo build/cargo test/cargo install --path .for anyonewhose default Rust toolchain is
stable-x86_64-pc-windows-gnuinstead ofstable-x86_64-pc-windows-msvc(a common setup for contributors who don'thave Visual Studio Build Tools installed).
Fix
Select the flag syntax based on
CARGO_CFG_TARGET_ENV(set by Cargo forbuild scripts): keep
/STACK:8388608formsvc, use the GNU-ld equivalent-Wl,--stack,8388608otherwise. Also switched the outer guard from#[cfg(windows)](host-compile-time) to checkingCARGO_CFG_TARGET_OS(the actual build target), which is the more correct signal for a build
script and matches how
CARGO_CFG_TARGET_ENVis already being read.Testing
cargo fmt --all --checkcargo clippy --all-targets(no new warnings)cargo test— 2575 passed, 8 ignored, 0 failed (previously: build didn'tcomplete at all on this target)
cargo install --path .succeeds and produces a workingrtk.exeonstable-x86_64-pc-windows-gnuNo behavior change on
x86_64-pc-windows-msvc(still emits/STACK:) ornon-Windows targets (flag is skipped entirely, same as before).
Build-script-only change; not user-facing, so no docs update needed per
CONTRIBUTING.md.