From 25a5c77344ed0b733f860668e6bae1696a059b39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Forment?= Date: Fri, 27 Feb 2026 14:39:42 +0100 Subject: [PATCH] Feat: fixes --- .cargo/config.toml | 4 +++- build.rs | 7 +++++-- scripts/cross/x86_64-windows.Dockerfile | 8 +++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index e47423c..1263c61 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -2,4 +2,6 @@ xtask = "run --package xtask --release --" [target.x86_64-pc-windows-gnu] -rustflags = ["-C", "link-args=-lstdc++ -lws2_32 -liphlpapi -lwinmm"] +rustflags = [ + "-C", "link-args=-Wl,-Bstatic -lstdc++ -lgcc -lgcc_eh -lpthread -Wl,-Bdynamic -lmingwex -lmsvcrt -lws2_32 -liphlpapi -lwinmm -lole32 -loleaut32 -luuid -lkernel32", +] diff --git a/build.rs b/build.rs index ec85c8e..631a969 100644 --- a/build.rs +++ b/build.rs @@ -4,10 +4,13 @@ fn main() { let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default(); if target_os == "windows" { - // rusty_link's build.rs only links stdc++ on linux — add it for windows too - println!("cargo:rustc-link-lib=stdc++"); + // C++ runtime (stdc++, gcc, gcc_eh, pthread) linked statically via .cargo/config.toml + // using -Wl,-Bstatic. Only Windows system DLLs go here. println!("cargo:rustc-link-lib=ws2_32"); println!("cargo:rustc-link-lib=iphlpapi"); + println!("cargo:rustc-link-lib=winmm"); + println!("cargo:rustc-link-lib=ole32"); + println!("cargo:rustc-link-lib=oleaut32"); } #[cfg(windows)] diff --git a/scripts/cross/x86_64-windows.Dockerfile b/scripts/cross/x86_64-windows.Dockerfile index 9af0293..3aa7b5b 100644 --- a/scripts/cross/x86_64-windows.Dockerfile +++ b/scripts/cross/x86_64-windows.Dockerfile @@ -7,7 +7,13 @@ RUN apt-get update && \ libclang-dev \ mingw-w64-tools \ mingw-w64-x86-64-dev \ + g++-mingw-w64-x86-64 \ && rm -rf /var/lib/apt/lists/* \ && ln -sf windows.h /usr/x86_64-w64-mingw32/include/Windows.h \ && ln -sf winsock2.h /usr/x86_64-w64-mingw32/include/WinSock2.h \ - && ln -sf ws2tcpip.h /usr/x86_64-w64-mingw32/include/WS2tcpip.h + && ln -sf ws2tcpip.h /usr/x86_64-w64-mingw32/include/WS2tcpip.h \ + && GCCDIR=$(ls -d /usr/lib/gcc/x86_64-w64-mingw32/*-posix 2>/dev/null | head -1) \ + && ln -sf "$GCCDIR/libstdc++.a" /usr/x86_64-w64-mingw32/lib/libstdc++.a \ + && ln -sf "$GCCDIR/libgcc.a" /usr/x86_64-w64-mingw32/lib/libgcc.a \ + && rm -f /usr/x86_64-w64-mingw32/lib/libstdc++.dll.a \ + && rm -f /usr/lib/gcc/x86_64-w64-mingw32/*/libstdc++.dll.a