Only use dlltool.exe on MinGW if -Cdlltool is passed - #161050
Conversation
7dda195 to
fd82481
Compare
|
@rustbot ready MCP has been accepted. |
|
@bors r+ |
|
📋 This PR cannot be approved because it currently has the following label: |
|
@bors r+ I suppose we will want to include it in release notes, no? |
Only use dlltool.exe on MinGW if -Cdlltool is passed The linker used by MinGW now works with ar_archive_writer generated short import libraries too. Implements rust-lang/compiler-team#1029 r? @mati865
Only use dlltool.exe on MinGW if -Cdlltool is passed The linker used by MinGW now works with ar_archive_writer generated short import libraries too. Implements rust-lang/compiler-team#1029 r? @mati865
Only use dlltool.exe on MinGW if -Cdlltool is passed The linker used by MinGW now works with ar_archive_writer generated short import libraries too. Implements rust-lang/compiler-team#1029 r? @mati865
…uwer Rollup of 6 pull requests Successful merges: - #155499 (stabilize never type) - #161294 (add crashtests [6/N]) - #161050 (Only use dlltool.exe on MinGW if -Cdlltool is passed) - #159583 (Add new `invalid_markdown_table` rustdoc lint) - #161098 (PassWrapper: handle LLVM 24 change in function types) - #161661 (Don't treat slashes as path seps after drive letters in verbatim paths)
…uwer Rollup of 5 pull requests Successful merges: - #161294 (add crashtests [6/N]) - #161050 (Only use dlltool.exe on MinGW if -Cdlltool is passed) - #159583 (Add new `invalid_markdown_table` rustdoc lint) - #161098 (PassWrapper: handle LLVM 24 change in function types) - #161661 (Don't treat slashes as path seps after drive letters in verbatim paths)
Only use dlltool.exe on MinGW if -Cdlltool is passed The linker used by MinGW now works with ar_archive_writer generated short import libraries too. Implements rust-lang/compiler-team#1029 r? @mati865
…uwer Rollup of 6 pull requests Successful merges: - #155499 (stabilize never type) - #161294 (add crashtests [6/N]) - #161050 (Only use dlltool.exe on MinGW if -Cdlltool is passed) - #159583 (Add new `invalid_markdown_table` rustdoc lint) - #161098 (PassWrapper: handle LLVM 24 change in function types) - #161661 (Don't treat slashes as path seps after drive letters in verbatim paths)
|
@bors try jobs=dist-i686-mingw |
This comment has been minimized.
This comment has been minimized.
Only use dlltool.exe on MinGW if -Cdlltool is passed try-job: dist-i686-mingw
|
I can look into that failure tomorrow. Looks like we don't prefix import symbols correctly on i686 windows GNU for some reason. |
|
@bors r- |
|
This pull request was unapproved. This PR was contained in a rollup (#161688), which was unapproved. |
|
💔 Test for 3d9e5bb failed: CI. Failed job:
|
This comment has been minimized.
This comment has been minimized.
Okay, I couldn't resist. |
This comment has been minimized.
This comment has been minimized.
The linker used by MinGW now works with ar_archive_writer generated short import libraries too.
Doesn't that mean |
fd82481 to
3b99205
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Uhm, that's a good point about stdlib. I was under impression we don't use raw-dylib by default there, but that's not the case. rust/library/std/src/sys/pal/windows/c.rs Line 105 in e457a7b rust/library/std/src/sys/pal/windows/c.rs Line 166 in e457a7b So, your change already make the std contain ar_archive_writer generated import libraries and user cannot opt out them without rebuilding std. And we only saw that because without changes in mati865@fe906617 your PR creates mismatch in symbol decoration logic (ar_archive_writer vs dlltool). And that logic is scattered across many places as you can see in my commit. |
|
If we apply mati865@fe906617 and build std with |
|
Wouldn't we need to record whether dlltool was used into the raw-dylib definition and then choose between the codegen path for dlltool vs ar_archive_writer when codegening calls to this raw-dylib? Otherwise standard library functions codegened outside the standard library would assume ar_archive_writer even though only a dlltool import library is present. |
Certainly I'm not up to speed in this area. Does that mean we might feed |
|
If I understand correctly ar_archive_writer and dlltool generated import libraries will expose the imported functions under different names. (I think one exposes them with their decorated name and the other with their undecorated name) And because of this cg_llvm has to generate different calls depending on if the import library was generated by ar_archive_writer or by dlltool. If I recall correctly the import library is generated (and thus the symbol name set to one or the other option) when compiling the crate that defines the raw-dylib. But if calls are generated in another crate, mati865@fe906617 would pick the symbol name to call based on the local
I'm afraid so. |
Dlltool adds the decorations itself (or rather adds them unless you pass We asked it to create dllimported There goes the theory, I just checked the binaries and in the practice we mess up big time here. And sure But what the heck happened with
We should always generate call to the same dllimport symbol, no matter how the import lib was made. "Do as I say, not as I do"rust/compiler/rustc_codegen_llvm/src/callee.rs Lines 139 to 144 in fe90661 But that is irrelevant for our raw-dylib consideration. So, if we fix this cursed dlltool hack and both ar_archive_writer and dlltool generate the symbols, there should be no problem with switching between them? |
Yes, I think we should just nuke it. If it had worked with the |
|
Haven't ran the tests on Windows machine yet and some changes are done hastily without deep consideration, but that looks like a nice cleanup in addition to fixing the discrepancy: main...mati865:rust:push-wwnqklwnwkwu Before: After: |
|
^^ no, forget about it. Dlltool was not designed to handle all our cases. Achieving identical symbol decorations for typical use cases is easy, but handling We are left only with the nuclear solution. |
View all comments
The linker used by MinGW now works with ar_archive_writer generated short import libraries too.
Implements rust-lang/compiler-team#1029
r? @mati865