Skip to content
This repository has been archived by the owner on Jun 18, 2021. It is now read-only.

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

Closed
gridbugs opened this issue Nov 28, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@gridbugs
Copy link

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

@grovesNL
Copy link
Collaborator

Thanks for reporting this issue. This might be related to grovesNL/spirv_cross#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)?

@gridbugs
Copy link
Author

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.

@kvark
Copy link
Member

kvark commented Jun 3, 2021

Already presents upstream

@kvark kvark closed this as completed Jun 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants