@@ -16,34 +16,13 @@ pub fn opts() -> TargetOptions {
1616 ] ,
1717 ) ;
1818
19- let mut late_link_args = LinkArgs :: new ( ) ;
2019 let mut late_link_args_dynamic = LinkArgs :: new ( ) ;
2120 let mut late_link_args_static = LinkArgs :: new ( ) ;
22- // Order of `late_link_args*` was found through trial and error to work with various
23- // mingw-w64 versions (not tested on the CI). It's expected to change from time to time.
24- let mingw_libs = vec ! [
25- "-lmsvcrt" . to_string( ) ,
26- "-lmingwex" . to_string( ) ,
27- "-lmingw32" . to_string( ) ,
28- "-lgcc" . to_string( ) , // alas, mingw* libraries above depend on libgcc
29- // mingw's msvcrt is a weird hybrid import library and static library.
30- // And it seems that the linker fails to use import symbols from msvcrt
31- // that are required from functions in msvcrt in certain cases. For example
32- // `_fmode` that is used by an implementation of `__p__fmode` in x86_64.
33- // The library is purposely listed twice to fix that.
34- //
35- // See https://github.com/rust-lang/rust/pull/47483 for some more details.
36- "-lmsvcrt" . to_string( ) ,
37- "-luser32" . to_string( ) ,
38- "-lkernel32" . to_string( ) ,
39- ] ;
40- late_link_args. insert ( LinkerFlavor :: Gcc , mingw_libs. clone ( ) ) ;
41- late_link_args. insert ( LinkerFlavor :: Lld ( LldFlavor :: Ld ) , mingw_libs) ;
4221 let dynamic_unwind_libs = vec ! [
4322 // If any of our crates are dynamically linked then we need to use
4423 // the shared libgcc_s-dw2-1.dll. This is required to support
4524 // unwinding across DLL boundaries.
46- "-lgcc_s " . to_string( ) ,
25+ "-l:libunwind.dll.a " . to_string( ) ,
4726 ] ;
4827 late_link_args_dynamic. insert ( LinkerFlavor :: Gcc , dynamic_unwind_libs. clone ( ) ) ;
4928 late_link_args_dynamic. insert ( LinkerFlavor :: Lld ( LldFlavor :: Ld ) , dynamic_unwind_libs) ;
@@ -53,8 +32,7 @@ pub fn opts() -> TargetOptions {
5332 // binaries to be redistributed without the libgcc_s-dw2-1.dll
5433 // dependency, but unfortunately break unwinding across DLL
5534 // boundaries when unwinding across FFI boundaries.
56- "-lgcc_eh" . to_string( ) ,
57- "-l:libpthread.a" . to_string( ) ,
35+ "-l:libunwind.a" . to_string( ) ,
5836 ] ;
5937 late_link_args_static. insert ( LinkerFlavor :: Gcc , static_unwind_libs. clone ( ) ) ;
6038 late_link_args_static. insert ( LinkerFlavor :: Lld ( LldFlavor :: Ld ) , static_unwind_libs) ;
@@ -64,7 +42,8 @@ pub fn opts() -> TargetOptions {
6442 env : "gnu" . to_string ( ) ,
6543 vendor : "pc" . to_string ( ) ,
6644 // FIXME(#13846) this should be enabled for windows
67- function_sections : false ,
45+ function_sections : true ,
46+ no_default_libraries : false ,
6847 linker : Some ( "gcc" . to_string ( ) ) ,
6948 dynamic_linking : true ,
7049 executables : true ,
@@ -80,7 +59,6 @@ pub fn opts() -> TargetOptions {
8059 pre_link_objects_fallback : crt_objects:: pre_mingw_fallback ( ) ,
8160 post_link_objects_fallback : crt_objects:: post_mingw_fallback ( ) ,
8261 crt_objects_fallback : Some ( CrtObjectsFallback :: Mingw ) ,
83- late_link_args,
8462 late_link_args_dynamic,
8563 late_link_args_static,
8664 abi_return_struct_as_int : true ,
0 commit comments