In particular, the way Corrosion passes the CMake CC_/CXX_ to rust here causes issues when the rust linker attempts to link the binary with the MSVC linker. This affects libcurl_sys and many other -sys crates that use the C compiler Corrosion specifies.
The only change here is switching the target to cdylib (which forces a complete, not partial, link):
= note: Creating library C:/Users/rii/Documents/dev/RiiStudio/ws/./cargo/build\x86_64-pc-windows-msvc\release\deps\riistudio_rs.dll.lib and object C:/Users/rii/Documents/dev/RiiStudio/ws/./cargo/build\x86_64-pc-windows-msvc\release\deps\riistudio_rs.dll.exp
libcurl_sys-7b6cbe17349096cb.rlib(digest_sspi.o) : error LNK2001: unresolved external symbol strdup
libcurl_sys-7b6cbe17349096cb.rlib(vauth.o) : error LNK2001: unresolved external symbol strdup
...
libcurl_sys-7b6cbe17349096cb.rlib(rename.o) : error LNK2001: unresolved external symbol strdup
libcurl_sys-7b6cbe17349096cb.rlib(warnless.o) : error LNK2019: unresolved external symbol read referenced in function curlx_read
libcurl_sys-7b6cbe17349096cb.rlib(warnless.o) : error LNK2019: unresolved external symbol write referenced in function curlx_write
...
A run with this issue can be seen here from this commit.
There are a few workarounds I've found:
- Switch to
clang-cl (not viable)
- Avoid libraries like
libcurl_sys (not viable)
- Manually pass the MSVC compiler as
CC to override CC_ (hacky)
- Disable passing
CC_ altogether (hacky, but works and seen here and fixes the build on CI seen above with this CI commit and CI run)
I believe the least annoying solution would be a flag to disable setting the CC_ rustflag altogether, and let rust use the system compiler directly. Alternatively, it seems if we want to pass CC, we may also need to pass the linker, though that appears less feasible.
Cheers
In particular, the way Corrosion passes the CMake
CC_/CXX_to rust here causes issues when the rust linker attempts to link the binary with the MSVC linker. This affectslibcurl_sysand many other-syscrates that use the C compiler Corrosion specifies.The only change here is switching the target to
cdylib(which forces a complete, not partial, link):A run with this issue can be seen here from this commit.
There are a few workarounds I've found:
clang-cl(not viable)libcurl_sys(not viable)CCto overrideCC_(hacky)CC_altogether (hacky, but works and seen here and fixes the build on CI seen above with this CI commit and CI run)I believe the least annoying solution would be a flag to disable setting the
CC_rustflag altogether, and let rust use the system compiler directly. Alternatively, it seems if we want to passCC, we may also need to pass the linker, though that appears less feasible.Cheers