Skip to content

std's tests fail to dynamically link under Windows 7 due to GetHostNameW missing #150896

@PaulDance

Description

@PaulDance

When running std's tests under Windows 7, it fails on the first execution on the following error:

     Running unittests lib.rs (build/x86_64-unknown-linux-gnu/stage1-std/x86_64-win7-windows-msvc/release/deps/alloctests-6f6372787480eb2d.exe)
uploaded "/builds/hlab/rust-ci/rust/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-win7-windows-msvc/release/deps/alloctests-6f6372787480eb2d.exe", waiting for result
run "C:\\Users\\root\\AppData\\Local\\Temp\\work\\test0\\alloctests-6f6372787480eb2d.exe"
error: test failed, to rerun pass `-p alloctests --lib`
Caused by:
  process didn't exit successfully: `/builds/hlab/rust-ci/rust/build/x86_64-unknown-linux-gnu/stage1-tools-bin/remote-test-client run 0 /builds/hlab/rust-ci/rust/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-win7-windows-msvc/release/deps/alloctests-6f6372787480eb2d.exe -Z unstable-options --format json` (exit status: 57)
note: test exited abnormally; to see the full output pass --no-capture to the harness.

(remote running is used, here under x86_64 Windows 7 SP1, but it also applies to x86)

Manually running the alloctests-*.exe program with std-*.dll alongside it gives the following dialog box:

Image

which can confirmed using depends.exe and observing the function's absence from WS2_32.dll. It could therefore make programs compiled with Rust 1.92.0 systematically fail as well, but I haven't been able to test that just yet.

The only place where this function is used if for std::net::hostname's Windows support, that is still unstable and tracked with #135142. This should explain why it started to fail only now as the feature's initial implementation is recent and only landed in stable under 1.92. As documented, GetHostNameW is indeed only available starting from Windows 8.

Removing this feature's support for Windows 7 should be easy, but ideally it should be adapted or ported to be compatible with Win7. Another possibility would be to use GetComputerNameExW that is available from prehistory times, but I don't know if its semantics are the same as GetHostNameW: would it work for what we want for the feature?

cc @roblabla @orowith2os @joboet

@rustbot label C-bug O-windows-7 T-libs A-io

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ioArea: `std::io`, `std::fs`, `std::net` and `std::path`C-bugCategory: This is a bug.O-windows-7OS: Windows 7 or Windows Server 2008 R2 or etc.T-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions