Wgpu-rs: Linker errors (unresolved external symbol) building with "-Ctarget-feature=+crt-static" on x86_64-pc-windows-msvc

Created on 29 Nov 2019  路  2Comments  路  Source: gfx-rs/wgpu-rs

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

bug

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.

All 2 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yutannihilation picture yutannihilation  路  4Comments

branpk picture branpk  路  3Comments

OptimisticPeach picture OptimisticPeach  路  3Comments

rukai picture rukai  路  5Comments

gzp-crey picture gzp-crey  路  3Comments