When building on windows with the x86_64-pc-windows-msvc toolchain, attempting to statically link the c runtime causes errors during linking.
I'm trying to build with:
cargo rustc -- -Ctarget-feature=+crt-static
During linking there are many errors about unresolved symbols, e.g.:
libspirv_cross-f48771ae5cfe7d38.rlib(spirv_cross_parsed_ir.o) : error LNK2001: unresolved external symbol __imp_isdigit
I made a repo to reproduce the problem: https://github.com/stevebob/wgpu-static-link-error
Here's the output from building on appveyor with the full error: https://ci.appveyor.com/project/stevebob/wgpu-static-link-error/build/job/xibn78580git54b2
All the linker errors begin with libspirv_cross. I thought the spirv_cross crate could be the root cause of this issue, but I can't reproduce the error by linking an app depending on just spirv_cross with +crt-static. Here's my attempt: https://ci.appveyor.com/project/stevebob/spirv-cross-windows-static-link-repro/build/job/9p7ahefakr7u3i4f
Also possibly of note, is the fact that I can successfully compile it with the x86_64-pc-windows-gnu toolchain, which my understanding is that it always statically links the c runtime: https://ci.appveyor.com/project/stevebob/wgpu-static-link-error/build/job/0ws0c9unpfouhvn8
Thanks for reporting this issue. This might be related to https://github.com/grovesNL/spirv_cross/issues/109 although the missing symbols are a bit different. Could you try to trace this with a few different configurations (especially debug vs. release builds)?
Here's all combinations of debug/release, msvc/gnu, static/dynamic crt:
https://ci.appveyor.com/project/stevebob/wgpu-static-link-error/builds/29156920
I think crt-static is ignored by the gnu toolchain. The only faliures are static and msvc, and in these cases the errors are the same in debug and release mode.
Most helpful comment
Here's all combinations of debug/release, msvc/gnu, static/dynamic crt:
https://ci.appveyor.com/project/stevebob/wgpu-static-link-error/builds/29156920
I think crt-static is ignored by the gnu toolchain. The only faliures are static and msvc, and in these cases the errors are the same in debug and release mode.