-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
from nightly-2021-04-26 started linking unneeded ws2_32.dll for x86_64-pc-windows-msvc target #85441
Comments
rustbot
added
A-linkage
Area: linking into static, shared libraries and binaries
O-windows
Operating system: Windows
labels
May 18, 2021
Yeah that makes sense that it is from #84115. rust/library/std/src/sys/windows/net.rs Lines 44 to 51 in 40d2302
pub fn cleanup() {
// only perform cleanup if network functionality was actually initialized
if INIT.is_completed() {
_cleanup();
}
}
// avoid linking to `WSACleanup` if it is never used by letting this function to be optimized away
#[inline(never)]
fn _cleanup() {
unsafe {
// close the socket interface
c::WSACleanup();
}
} |
GuillaumeGomez
added a commit
to GuillaumeGomez/rust
that referenced
this issue
Jun 6, 2021
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.
nagisa
added a commit
to nagisa/rust
that referenced
this issue
Oct 2, 2021
On MinGW toolchains the various features (such as function sections) necessary to eliminate dead function references are disabled due to various bugs. This means that the windows sockets library will most likely remain linked to any mingw toolchain built program that also utilizes libstd. That said, I made an attempt to also enable `function-sections` and `--gc-sections` during my experiments, but the symbol references remained, sadly.
Manishearth
added a commit
to Manishearth/rust
that referenced
this issue
Oct 4, 2021
Only register `WSACleanup` if `WSAStartup` is actually ever called See rust-lang#85595 Fixes rust-lang#85441
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For empty.rs:
rustc +nightly-2021-04-25-x86_64-pc-windows-msvc empty.rs -O
don't use ws2_32.dll
rustc +nightly-2021-04-26-x86_64-pc-windows-msvc empty.rs -O
use ws2_32.dll
Can be checked for example via
dumpbin.exe /dependents empty.exe
regressed between 42816d6...3709ae3, i'm thinking about #84115
Thing that imported from ws2_32 is
WSACleanup
@rustbot label +O-windows +A-linkage
The text was updated successfully, but these errors were encountered: