-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Use the .drectve section for exporting symbols from dlls on Windows #142568
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
base: master
Are you sure you want to change the base?
Conversation
r? @wesleywiser rustbot has assigned @wesleywiser. Use |
Some changes occurred in compiler/rustc_codegen_ssa |
e63c76b
to
94ec88c
Compare
@bors2 try jobs=x86_64-msvc-1,x86_64-msvc-2 |
Use the .drectve section for exporting symbols from dlls on Windows While it would be reasonable to expect the Windows linker to handle linker args in the .drectve section identical to cli arguments, as it turns out exporting weak symbols only works when the /EXPORT is in the .drectve section, not when it is a linker argument or when a .DEF file is used. Necessary for and extracted out of #142366. Thanks `@dpaoliello` for figuring out this weird quirk of link.exe! try-job: x86_64-msvc-1 try-job: x86_64-msvc-2
💔 Test failed
|
@bors2 try jobs=x86_64-msvc-1,x86_64-msvc-2 |
Use the .drectve section for exporting symbols from dlls on Windows While it would be reasonable to expect the Windows linker to handle linker args in the .drectve section identical to cli arguments, as it turns out exporting weak symbols only works when the /EXPORT is in the .drectve section, not when it is a linker argument or when a .DEF file is used. Necessary for and extracted out of #142366. Thanks `@dpaoliello` for figuring out this weird quirk of link.exe! try-job: x86_64-msvc-1 try-job: x86_64-msvc-2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
One overall design question: is it supported for folks to run the linker themselves AND specify their own def file? A couple of my changes broke the Chromium and Fuschia folks, so I'm a little paranoid now about changing anything to do with linking that may affect them.
This PR on it's own has no effect at all on people running the linker themself. Both the .DEF file and the symbols.o file are only generated when rustc itself runs the linker. As for a future PR that will use weak definitions, those symbols are not meant to be exported from a staticlib anyway. The only case that could break is if someone (Chromium) tries to link rlibs together into a dll and wants to export all symbols, which we don't officially support anyway. The Chromium people have had to adaot their build system for rustc changes anyway and I expect it to not all that hard to adapt to said future weak symbol usage too. |
💔 Test failed
|
The test executable failed with Looks like this is a test for shaking out unused functions: is the compiler supposed to do that, or is it relying on the linker? |
@bors2 try jobs=x86_64-msvc-1,x86_64-msvc-2 |
Use the .drectve section for exporting symbols from dlls on Windows While it would be reasonable to expect the Windows linker to handle linker args in the .drectve section identical to cli arguments, as it turns out exporting weak symbols only works when the /EXPORT is in the .drectve section, not when it is a linker argument or when a .DEF file is used. Necessary for and extracted out of #142366. Thanks `@dpaoliello` for figuring out this weird quirk of link.exe! try-job: x86_64-msvc-1 try-job: x86_64-msvc-2
8c88ff4
to
fc88eae
Compare
fc88eae
to
e6aa201
Compare
Squashed everything and reverted some now unnecessary changes. @rustbot ready |
@bors r+ |
809b270
to
d40bee8
Compare
@bors r+ |
…=wesleywiser Use the .drectve section for exporting symbols from dlls on Windows While it would be reasonable to expect the Windows linker to handle linker args in the .drectve section identical to cli arguments, as it turns out exporting weak symbols only works when the /EXPORT is in the .drectve section, not when it is a linker argument or when a .DEF file is used. Necessary for and extracted out of rust-lang#142366. Thanks `@dpaoliello` for figuring out this weird quirk of link.exe!
☔ The latest upstream changes (presumably #142962) made this pull request unmergeable. Please resolve the merge conflicts. |
d40bee8
to
aa98f4d
Compare
This comment has been minimized.
This comment has been minimized.
While it would be reasonable to expect the Windows linker to handle linker args in the .drectve section identical to cli arguments, as it turns out exporting weak symbols only works when the /EXPORT is in the .drectve section, not when it is a linker argument or when a .DEF file is used.
aa98f4d
to
7539730
Compare
@rustbot ready |
@bors r+ |
…=wesleywiser Use the .drectve section for exporting symbols from dlls on Windows While it would be reasonable to expect the Windows linker to handle linker args in the .drectve section identical to cli arguments, as it turns out exporting weak symbols only works when the /EXPORT is in the .drectve section, not when it is a linker argument or when a .DEF file is used. Necessary for and extracted out of rust-lang#142366. Thanks `@dpaoliello` for figuring out this weird quirk of link.exe!
Rollup of 12 pull requests Successful merges: - #141829 (Specialize sleep_until implementation for unix (except mac)) - #141847 (Explain `TOCTOU` on the top of `std::fs`, and reference it in functions) - #142138 (Add `Vec::into_chunks`) - #142321 (Expose elf abi on ppc64 targets) - #142568 (Use the .drectve section for exporting symbols from dlls on Windows) - #142886 (ci: aarch64-gnu: Stop skipping `panic_abort_doc_tests`) - #143038 (avoid suggesting traits from private dependencies) - #143194 (fix bitcast of single-element SIMD vectors) - #143206 (Align attr fixes) - #143258 (Don't recompute `DisambiguatorState` for every RPITIT in trait definition) - #143260 (Use the correct export kind for __rust_alloc_error_handler_should_panic) - #143274 (ci: support optional jobs) r? `@ghost` `@rustbot` modify labels: rollup
Not certain, but this seems likely to be the cause of #143305 (comment) @bors r- |
While it would be reasonable to expect the Windows linker to handle linker args in the .drectve section identical to cli arguments, as it turns out exporting weak symbols only works when the /EXPORT is in the .drectve section, not when it is a linker argument or when a .DEF file is used.
Necessary for and extracted out of #142366.
Thanks @dpaoliello for figuring out this weird quirk of link.exe!