Skip to content

x86_64-pc-windows-gnu image 0.2.5: link failure — GetHostNameW missing from mingw-w64 #1754

@coconutbird

Description

@coconutbird

Summary

Building a Rust nightly project with cross build --target x86_64-pc-windows-gnu using the 0.2.5 image fails at link time with an undefined reference to GetHostNameW. All Rust compilation succeeds — only the final mingw linker step fails.

Environment

  • Host: aarch64-apple-darwin (Apple Silicon, Docker Desktop with Rosetta)
  • Rust toolchain: nightly-x86_64-unknown-linux-gnu1.96.0-nightly (80282b130 2026-03-06)
  • cross version: 0.2.5
  • Docker image: ghcr.io/cross-rs/x86_64-pc-windows-gnu:0.2.5
  • CROSS_CONTAINER_OPTS: --platform linux/amd64 (required on ARM64 host)

Error

error: linking with `x86_64-w64-mingw32-gcc` failed: exit status: 1
  ...
  /rust/lib/rustlib/x86_64-pc-windows-gnu/lib/libstd-949922d303bba3ab.rlib(std-*.rcgu.o):
    .../std/src/sys/net/hostname/windows.rs:15: undefined reference to `GetHostNameW'
  collect2: error: ld returned 1 exit status

The linker command does include -lws2_32, so the library is being linked — but the mingw-w64 version in the image doesn't export GetHostNameW.

Root Cause

Rust nightly's std now uses GetHostNameW (in std::sys::net::hostname::windows). This function requires a newer mingw-w64 than what's bundled in the 0.2.5 image. The x86_64-unknown-linux-gnu and aarch64-unknown-linux-gnu images work fine — this only affects the Windows GNU cross-compilation image.

Reproduction

# Any Rust project using tokio or std networking should reproduce this
cargo init --name repro && cd repro
echo 'tokio = { version = "1", features = ["full"] }' >> Cargo.toml
cat > src/main.rs << 'EOF'
#[tokio::main]
async fn main() {
    println!("hello");
}
EOF
CROSS_CONTAINER_OPTS="--platform linux/amd64" cross build --target x86_64-pc-windows-gnu

Expected Behavior

The build should link successfully, as it does for the Linux targets.

Suggested Fix

Update the mingw-w64 toolchain in the x86_64-pc-windows-gnu Docker image to a version that includes GetHostNameW in its ws2_32 import library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions