Uh oh!
There was an error while loading. Please reload this page.
Only register WSACleanup if WSAStartup is actually ever called - #85595
Only register WSACleanup if WSAStartup is actually ever called#85595CDirkx wants to merge 2 commits into
WSACleanup if WSAStartup is actually ever called#85595Conversation
rust-highfive
commented
May 23, 2021
(rust-highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
Consider using SyncLazy/SyncOnceCell for the INIT.
There was a problem hiding this comment.
I combined the two statics in a SyncOnceCell.
nagisa
commented
May 23, 2021
This seems okay to me. Is there any way a test could be written for this? |
klensy
commented
May 23, 2021
For example from issue, output will be: we can grep output, but this is ugly. |
CDirkx
commented
May 23, 2021
I could add a |
klensy
commented
May 23, 2021
|
klensy
commented
May 23, 2021
Test |
CDirkx
commented
May 24, 2021
I added a |
klensy
commented
Jun 6, 2021
Works, at least under |
nagisa
commented
Jun 6, 2021
bors
commented
Jun 6, 2021
📌 Commit f798596 has been approved by |
Only register `WSACleanup` if `WSAStartup` is actually ever called Fix for rust-lang#85441. Because `WSACleanup` appears in `cleanup` currently `WS2_32.dll` is always linked, even if no network functionality is ever used. To prevent this, `WSACleanup` has to only appear in `init`, hence the workaround of registering it in a static. If anyone knows a cleaner solution, let me know.
GuillaumeGomez
commented
Jun 6, 2021
CDirkx
commented
Jun 7, 2021
Good news, using |
This comment has been minimized.
This comment has been minimized.
crlf0710
commented
Jul 9, 2021
@CDirkx Ping from triage, any updates on this? |
CDirkx
commented
Jul 9, 2021
I had trouble getting the tests to run under |
| pub struct Socket(c::SOCKET); | ||
| static INIT: Once = Once::new(); | ||
| static WSA: SyncOnceCell<unsafe extern "system" fn() -> i32> = SyncOnceCell::new(); |
There was a problem hiding this comment.
Could this be named WSA_CLEANUP? Or otherwise wrap the fn pointer in a struct - as it stands, the WSA name doesn't make it obvious what the fn pointer is supposed to be.
JohnCSimon
commented
Sep 13, 2021
Ping from triage: |
nagisa
commented
Oct 2, 2021
I looked at the build failure. I believe this is likely related to the fact that the rust/compiler/rustc_target/src/spec/windows_gnu_base.rs Lines 66 to 67 in 21e1cd9 I don't think re-enabling the function sections is going to be feasible, so we should only run that test on Since Christiaan seems to be away since at least July, I'm going to close this and open a fixed PR. |
mati865
commented
Oct 2, 2021
FWIW I think it's not an issue with |
Only register `WSACleanup` if `WSAStartup` is actually ever called See rust-lang#85595Fixesrust-lang#85441
Only register `WSACleanup` if `WSAStartup` is actually ever called See rust-lang#85595Fixesrust-lang#85441
Fix for #85441.
Because
WSACleanupappears incleanupcurrentlyWS2_32.dllis always linked, even if no network functionality is ever used.To prevent this,
WSACleanuphas to only appear ininit, hence the workaround of registering it in a static.If anyone knows a cleaner solution, let me know.