Skip to content

Commit 1606341

Browse files
authored
Document the mingw -lmsvcrt hack better
1 parent bfde33f commit 1606341

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/librustc_back/target/windows_base.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,15 @@ pub fn opts() -> TargetOptions {
5959
"-lmingw32".to_string(),
6060
"-lgcc".to_string(), // alas, mingw* libraries above depend on libgcc
6161
"-lmsvcrt".to_string(),
62-
"-lmsvcrt".to_string(), // mingw is insane...?
62+
// mingw's msvcrt is a weird hybrid import library and static library.
63+
// And it seems that the linker fails to use import symbols from msvcrt
64+
// that are required from functions in msvcrt in certain cases. For example
65+
// `_fmode` that is used by an implementation of `__p__fmode` in x86_64.
66+
// Listing the library twice seems to fix that, and seems to also be done
67+
// by mingw's gcc (Though not sure if it's done on purpose, or by mistake).
68+
//
69+
// See https://github.com/rust-lang/rust/pull/47483
70+
"-lmsvcrt".to_string(),
6371
"-luser32".to_string(),
6472
"-lkernel32".to_string(),
6573
]);

0 commit comments

Comments
 (0)