cargo-zigbuild icon indicating copy to clipboard operation
cargo-zigbuild copied to clipboard

Using target `x86_64-pc-windows-gnu` still tries to link in `msvcrt`

Open doawoo opened this issue 6 months ago • 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.

doawoo avatar Aug 22 '24 21:08 doawoo