Before you burn me at the stake for using
static mut. It's a shortcut that is not going to end up even in draft PR.
I have committed first of the fix at https://github.com/rust-lang/rust/commit/d87b0043778b83063b7e431c63bb1cf47bcbdac9
It might be easier to understand if you look at the linker invocation first: https://www.diffchecker.com/GEuYFmzo
Original invocation fails when linking together Rust and C objects because Rust ships mingw-w64 libraries that almost never happen to be compatible with user's mingw-w64 installation.
My changes get system mingw-w64 libraries path and caches it (lines 905-933), libraries that are passed to the linker via their full path (
crt2.o in this case) are first searched in system mingw-w64 installation (lines 936-944) and finally it prepends system mingw-w64 libraries search path before rust libraries (lines 1118-1123).
IMO the idea is good (code isn't) and I'd like to hear from the team about it.
Note: Because of
#[cfg(...)] it works only on Windows but the same workaround is required when cross-compiling.
Sorry for the wall of text.
Can somebody do
@bors try on https://github.com/rust-lang/rust/pull/67429 ?