Using target `x86_64-pc-windows-gnu` still tries to link in `msvcrt`
doawoo opened this issue · 4 comments
I have had a lot of success targeting Linux and macOS machines with this.
However I'm running into a puzzling issue, it seems that Rust really wants to link msvcrt
, even when the command I'm specifying is:
cargo zigbuild --target x86_64-pc-windows-gnu
It complains about not being able to locate the library.
= note: error: unable to find dynamic system library 'msvcrt' using strategy 'paths_first'. searched paths:
/Users/digit/git/Jsonrs/native/jsonrs/target/x86_64-pc-windows-gnu/debug/deps/msvcrt.dll
/Users/digit/git/Jsonrs/native/jsonrs/target/x86_64-pc-windows-gnu/debug/deps/msvcrt.lib
/Users/digit/git/Jsonrs/native/jsonrs/target/x86_64-pc-windows-gnu/debug/deps/libmsvcrt.a
/Users/digit/git/Jsonrs/native/jsonrs/target/debug/deps/msvcrt.dll
/Users/digit/git/Jsonrs/native/jsonrs/target/debug/deps/msvcrt.lib
/Users/digit/git/Jsonrs/native/jsonrs/target/debug/deps/libmsvcrt.a
/Users/digit/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/x86_64-pc-windows-gnu/lib/msvcrt.dll
/Users/digit/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/x86_64-pc-windows-gnu/lib/msvcrt.lib
/Users/digit/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/x86_64-pc-windows-gnu/lib/libmsvcrt.a
/Users/digit/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/x86_64-pc-windows-gnu/lib/msvcrt.dll
/Users/digit/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/x86_64-pc-windows-gnu/lib/msvcrt.lib
/Users/digit/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/x86_64-pc-windows-gnu/lib/libmsvcrt.a
Does this flag need to be filtered out in the linker argument processing step?
Re-running the long command that's spat out, and then removing the -lmsvcrt
results in the build proceeding further until it hits the temp files that no longer exist post-build.
FYI, -lmsvcrt
seems to be added by Rust in https://github.com/rust-lang/rust/blob/b5723af3457b9cd3795eeb97e9af2d34964854f2/compiler/rustc_target/src/spec/base/windows_gnu.rs#L33-L44
Thanks for the quick reply. Looking at the CI results there's some other gotchas involved here. I've cloned down your branch and will be playing a bit with it to see if I can resolve any of the linker issues I've seen in CI.