Closed niklasf closed 6 months ago
Thank you for the report!
unrecognized option '/Wl,--undefined=AUDITABLE_VERSION_INFO'; ignored
This is caused by cargo auditable
prefixing the --undefined
option with -Wl
because typically rustc
doesn't use the linker directly, it uses a compiler such as GCC as a wrapper around the linker, and -Wl
is the GCC and clang option to pass an argument to the linker.
This could be an issue with cargo auditable
that was undiscovered until now because it is only a warning. I'll investigate it. However, it is only a warning, so that's not what is causing compilation to fail.
unresolved external symbol __mingw_vfprintf
This indicates that libzstd has been build with mingw (GCC for Windows) toolchain; linking it with the MSVC toolchain then fails, as expected.
So it seems that something confuses zstd-sys and makes it build with MinGW instead of MSVC toolchain when run under cargo auditable
.
I don't think cargo auditable
emits the wrong kind of object file, because then we would be seeing linking errors from things other than libzstd - it would either complain about cargo_auditable_issue_x_audit_data.o
or about the toplevel binary being compiled.
This is the extent of the changes that cargo auditable
makes to the compilation command.
Perhaps zstd-sys
sees the options starting with -
or --
and decides that it should be using MinGW instead of MSVC?
After I figure out the -Wl
issue, the compilation failure may or may not go away. I suggest reporting this to zstd-sys maintainers regardless. If the issue is indeed with it incorrectly picking MinGW instead of MSVC, then zstd-sys should be fixed regardless because their toolchain detection is fragile and will break not just under cargo auditable
.
I've created a branch that might fix the issue: #142
Could you test it and see if the problem still occurs?
New run: https://github.com/niklasf/cargo-auditable-issue-141/actions/runs/8866914352/job/24344898298
unrecognized option '/Wl,--undefined=AUDITABLE_VERSION_INFO'; ignored
This is now fixed.
However, it is only a warning, so that's not what is causing compilation to fail.
And indeed it still fails with libzstd_sys-2baf2e10c8662d45.rlib(b0401a448be314bb-fastcover.o) : error LNK2001: unresolved external symbol __mingw_vfprintf
etc.
I've double-checked the way cargo auditable
write object files, and there is no distinction between MinGW and MSVC targets. And this logic were incorrect (already a stretch because it's copied from rustc), all builds would be broken, not just zstd.
I'm afraid that's an issue with zstd-sys getting confused about what toolchain should be used, and mistakenly picking MinGW. That's not something I can fix in cargo auditable
; you will have to report it to zstd-sys maintainers.
Thanks for looking into it!
Reduced example: https://github.com/niklasf/cargo-auditable-issue-141 (where
cargo build --release
works butcargo auditable build --release
fails)Workflow: https://github.com/niklasf/cargo-auditable-issue-141/blob/main/.github/workflows/demo.yml
Error: https://github.com/niklasf/cargo-auditable-issue-141/actions/runs/8866193441/job/24343338399
Log snippet: