Skip to content

Commit

Permalink
Run the #85441 regression test on MSVC only
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nagisa committed Oct 2, 2021
1 parent b7d2b46 commit 5b4873a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions library/std/src/sys/windows/net.rs
Expand Up @@ -29,12 +29,12 @@ pub mod netc {

pub struct Socket(OwnedSocket);

static WSA: SyncOnceCell<unsafe extern "system" fn() -> i32> = SyncOnceCell::new();
static WSA_CLEANUP: SyncOnceCell<unsafe extern "system" fn() -> i32> = SyncOnceCell::new();

/// Checks whether the Windows socket interface has been started already, and
/// if not, starts it.
pub fn init() {
let _ = WSA.get_or_init(|| unsafe {
let _ = WSA_CLEANUP.get_or_init(|| unsafe {
let mut data: c::WSADATA = mem::zeroed();
let ret = c::WSAStartup(
0x202, // version 2.2
Expand All @@ -51,7 +51,7 @@ pub fn init() {

pub fn cleanup() {
// only perform cleanup if network functionality was actually initialized
if let Some(cleanup) = WSA.get() {
if let Some(cleanup) = WSA_CLEANUP.get() {
unsafe {
cleanup();
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-make/issue-85441/Makefile
@@ -1,4 +1,4 @@
# only-windows
# only-windows-msvc

-include ../../run-make-fulldeps/tools.mk

Expand Down

0 comments on commit 5b4873a

Please sign in to comment.