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-gnu — 1.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.
Summary
Building a Rust nightly project with
cross build --target x86_64-pc-windows-gnuusing the0.2.5image fails at link time with an undefined reference toGetHostNameW. All Rust compilation succeeds — only the final mingw linker step fails.Environment
aarch64-apple-darwin(Apple Silicon, Docker Desktop with Rosetta)nightly-x86_64-unknown-linux-gnu—1.96.0-nightly (80282b130 2026-03-06)0.2.5ghcr.io/cross-rs/x86_64-pc-windows-gnu:0.2.5--platform linux/amd64(required on ARM64 host)Error
The linker command does include
-lws2_32, so the library is being linked — but the mingw-w64 version in the image doesn't exportGetHostNameW.Root Cause
Rust nightly's
stdnow usesGetHostNameW(instd::sys::net::hostname::windows). This function requires a newer mingw-w64 than what's bundled in the0.2.5image. Thex86_64-unknown-linux-gnuandaarch64-unknown-linux-gnuimages work fine — this only affects the Windows GNU cross-compilation image.Reproduction
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-gnuDocker image to a version that includesGetHostNameWin itsws2_32import library.