-
Notifications
You must be signed in to change notification settings - Fork 507
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
Should raw-dylibs defined in windows-targets use import_name_type = "undecorated"? #3285
Comments
I guess the discussion on the LLVM side points to the problem being on the rust side of raw-dylib. |
Hm, do you know if older versions of Rust worked? I suspect this might be a rustc issue. Looking at a Windows import library (
And the linker members include:
So the name type should be I'm a bit puzzled why removing |
@dpaoliello thoughts? |
Anyone know how we might add this... windows-rs/.github/workflows/raw_dylib.yml Lines 12 to 13 in ff6f56d
...to a yml strategy/matrix so I can more easily run |
I did check with |
#3287 passed meaning we have the same testing for |
Happy to test rust-lld / lld-link if someone can point me to how that is done. I see its enabled by default on Linux but not Windows. Anyone know why? https://blog.rust-lang.org/2024/05/17/enabling-rust-lld-on-linux.html |
There have been compatibility issues in the past. I'm not exactly sure where we are at now but it seems rust-lang/rust#111480 is still open (though might just be that nobody has tested it recently). |
You can put this in [target.x86_64-pc-windows-msvc]
linker = "rust-lld" Or maybe use RUSTFLAGS with |
Thanks, I've tested this and it seems to work fine. |
Seems like it's the same issue as rust-lang/rust#124958 Essentially, we should be setting |
I also ran |
I've tried with a tiny testcase, and it seems the side effects of the rust raw-dylib shortcoming is only really visible with |
Well it sounds like this is unrelated to windows-rs so I'm closing this issue. |
Set "symbol name" in raw-dylib import libraries to the decorated name `windows-rs` received a bug report that mixing raw-dylib generated and the Windows SDK import libraries was causing linker failures: <microsoft/windows-rs#3285> The root cause turned out to be rust-lang#124958, that is we are not including the decorated name in the import library and so the import name type is also not being correctly set. This change modifies the generation of import libraries to set the "symbol name" to the fully decorated name and correctly marks the import as being data vs function. Note that this also required some changes to how the symbol is named within Rust: for MSVC we now need to use the decorated name but for MinGW we still need to use partially decorated (or undecorated) name. Fixes rust-lang#124958 Passing i686 MSVC and MinGW build: <https://github.com/rust-lang/rust/actions/runs/11000433888?pr=130586> r? `@ChrisDenton`
Set "symbol name" in raw-dylib import libraries to the decorated name `windows-rs` received a bug report that mixing raw-dylib generated and the Windows SDK import libraries was causing linker failures: <microsoft/windows-rs#3285> The root cause turned out to be rust-lang#124958, that is we are not including the decorated name in the import library and so the import name type is also not being correctly set. This change modifies the generation of import libraries to set the "symbol name" to the fully decorated name and correctly marks the import as being data vs function. Note that this also required some changes to how the symbol is named within Rust: for MSVC we now need to use the decorated name but for MinGW we still need to use partially decorated (or undecorated) name. Fixes rust-lang#124958 Passing i686 MSVC and MinGW build: <https://github.com/rust-lang/rust/actions/runs/11000433888?pr=130586> r? ``@ChrisDenton``
Set "symbol name" in raw-dylib import libraries to the decorated name `windows-rs` received a bug report that mixing raw-dylib generated and the Windows SDK import libraries was causing linker failures: <microsoft/windows-rs#3285> The root cause turned out to be rust-lang#124958, that is we are not including the decorated name in the import library and so the import name type is also not being correctly set. This change modifies the generation of import libraries to set the "symbol name" to the fully decorated name and correctly marks the import as being data vs function. Note that this also required some changes to how the symbol is named within Rust: for MSVC we now need to use the decorated name but for MinGW we still need to use partially decorated (or undecorated) name. Fixes rust-lang#124958 Passing i686 MSVC and MinGW build: <https://github.com/rust-lang/rust/actions/runs/11000433888?pr=130586> r? `@ChrisDenton`
Rollup merge of rust-lang#130586 - dpaoliello:fixrawdylib, r=wesleywiser Set "symbol name" in raw-dylib import libraries to the decorated name `windows-rs` received a bug report that mixing raw-dylib generated and the Windows SDK import libraries was causing linker failures: <microsoft/windows-rs#3285> The root cause turned out to be rust-lang#124958, that is we are not including the decorated name in the import library and so the import name type is also not being correctly set. This change modifies the generation of import libraries to set the "symbol name" to the fully decorated name and correctly marks the import as being data vs function. Note that this also required some changes to how the symbol is named within Rust: for MSVC we now need to use the decorated name but for MinGW we still need to use partially decorated (or undecorated) name. Fixes rust-lang#124958 Passing i686 MSVC and MinGW build: <https://github.com/rust-lang/rust/actions/runs/11000433888?pr=130586> r? `@ChrisDenton`
Set "symbol name" in raw-dylib import libraries to the decorated name `windows-rs` received a bug report that mixing raw-dylib generated and the Windows SDK import libraries was causing linker failures: <microsoft/windows-rs#3285> The root cause turned out to be rust-lang#124958, that is we are not including the decorated name in the import library and so the import name type is also not being correctly set. This change modifies the generation of import libraries to set the "symbol name" to the fully decorated name and correctly marks the import as being data vs function. Note that this also required some changes to how the symbol is named within Rust: for MSVC we now need to use the decorated name but for MinGW we still need to use partially decorated (or undecorated) name. Fixes rust-lang#124958 Passing i686 MSVC and MinGW build: <https://github.com/rust-lang/rust/actions/runs/11000433888?pr=130586> r? `@ChrisDenton`
Set "symbol name" in raw-dylib import libraries to the decorated name `windows-rs` received a bug report that mixing raw-dylib generated and the Windows SDK import libraries was causing linker failures: <microsoft/windows-rs#3285> The root cause turned out to be #124958, that is we are not including the decorated name in the import library and so the import name type is also not being correctly set. This change modifies the generation of import libraries to set the "symbol name" to the fully decorated name and correctly marks the import as being data vs function. Note that this also required some changes to how the symbol is named within Rust: for MSVC we now need to use the decorated name but for MinGW we still need to use partially decorated (or undecorated) name. Fixes #124958 Passing i686 MSVC and MinGW build: <https://github.com/rust-lang/rust/actions/runs/11000433888?pr=130586> r? `@ChrisDenton`
Summary
In a complex multi-language project, one may end up using both windows-target and the system libraries directly (that's the case of Firefox). When enabling windows-targets's support for raw-dylib, linking fails when using LLVM's lld-link (I haven't tried link.exe, it might actually work, but the result is probably suboptimal too). The cause for the link failure is possibly a bug in lld-link, but it is a manifestation of the fact that the fake import lib that rust creates with raw-dylib does not agree with the real system import lib, wrt symbol names: on 32-bits windows, the system import lib use the
__imp__sym@n
form, while the raw-dylib uses the__imp_sym
form because ofimport_name_type = "undecorated"
.See llvm/llvm-project#107371 (comment) for more details.
Removing
import_name_type = "undecorated"
solves the problem.Crate manifest
No response
Crate code
No response
The text was updated successfully, but these errors were encountered: