-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Fail to link i686 staticlib with MSVC #36097
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This affects Stylo. See atom_macro.rs. (The test code is also simplified from Stylo case) |
Yes I think this may have to do with dllimport at least a little? Right now we blindly apply dllimport to all imports and we rely on the linker to fix up any mistakes. This in general works for most references and will otherwise be fixed by rust-lang/rfcs#1717 The other remaining piece here is that it looks like LLVM is adding a leading #[link_name = "\x01?..."] That is, add a leading "1 byte" to the symbol and I think it disables the otherwise present name mangling. |
Looks like adding |
FWIW, it seems the warning is simply based on the name having |
Avoid LLVM prepending "_" for msvc32 symbols. See rust-lang/rust#36097. This patch adds a workaround to that issue, which makes win32 stylo build. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13116) <!-- Reviewable:end -->
Ok cool! Should this be closed? |
Should it? I suppose Rust (or LLVM) should fix this rather than relying on users to prepend an |
@upsuper LLVM decorating symbols based on the calling convention is expected behavior and not a bug. It is surprising behavior sometimes, yes, and there are cases where you don't want it, but the majority of the time it does the right thing. Dllimport shenanigans are a different yet known issue #27438 |
Yes it sounds like here you're basically taking on the name mangling of MSVC yourself, so I don't think there's much we could really do here other than offer this escape hatch. |
…rom upsuper:msvc32-atoms); r=emilio See rust-lang/rust#36097. This patch adds a workaround to that issue, which makes win32 stylo build. Source-Repo: https://github.com/servo/servo Source-Revision: c55588d25b6e0390d11b2cb654ccb1f95e16cebb UltraBlame original commit: 54bc210408658c7d7b27836cd9e04de7e2267381
…rom upsuper:msvc32-atoms); r=emilio See rust-lang/rust#36097. This patch adds a workaround to that issue, which makes win32 stylo build. Source-Repo: https://github.com/servo/servo Source-Revision: c55588d25b6e0390d11b2cb654ccb1f95e16cebb UltraBlame original commit: 54bc210408658c7d7b27836cd9e04de7e2267381
…rom upsuper:msvc32-atoms); r=emilio See rust-lang/rust#36097. This patch adds a workaround to that issue, which makes win32 stylo build. Source-Repo: https://github.com/servo/servo Source-Revision: c55588d25b6e0390d11b2cb654ccb1f95e16cebb UltraBlame original commit: 54bc210408658c7d7b27836cd9e04de7e2267381
See my test repo: upsuper/rust-msvc-link-test
i686-pc-windows-msvc
toolchaincl.exe
from MSVC 2015link.exe
from MSVC 2015(The 32bit MSVC 2015 toolchain locates at "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64_x86" for me)
It shows linker error like:
Using
dumpbin -symbols
to analysemain.obj
andtest.lib
shows that, inmain.obj
, the symbols arehowever, in
test.lib
generated by rustc, the import symbols areThus the mismatch.
It's even more interesting that the symbol from nested crate is different from the crate of the lib, even though they are both
extern
symbols.This issue doesn't show up for 64bit build with proper
link_name
. The corresponding symbols in rust staticlib with x86_64 toolchain would be:It could either because of the different prefix (
__imp_
vs.__imp__
and_
) or the different link type? But the linker also complains aboutdllimport
using on static link symbols for 64bit build.cc @alexcrichton
The text was updated successfully, but these errors were encountered: