summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Schievink <jonasschievink@gmail.com>2020-09-27 01:53:23 +0200
committerGitHub <noreply@github.com>2020-09-27 01:53:23 +0200
commit3d1d24da9402459d44dbd7c088885de9d78699a7 (patch)
tree2db86be5c0d84c48bef242ca56aa51401773cac8
parentRollup merge of #77184 - pickfire:patch-4, r=kennytm (diff)
parentLink dynamic and static late_link_args before generic ones (diff)
downloadrust-3d1d24da9402459d44dbd7c088885de9d78699a7.tar.gz
rust-3d1d24da9402459d44dbd7c088885de9d78699a7.tar.bz2
rust-3d1d24da9402459d44dbd7c088885de9d78699a7.tar.xz
Rollup merge of #77208 - mati865:late-link-args-order, r=petrochenkov
Late link args order MSYS2 changed how winpthreads is built and as the result it now depends on more mingw-w64 libraries. This PR affects only MinGW targets since nobody else is using `late_link_args_{dynamic,static}`. Now the order is similar to how it used to be before https://github.com/rust-lang/rust/pull/67502.
-rw-r--r--compiler/rustc_codegen_ssa/src/back/link.rs6
-rw-r--r--compiler/rustc_target/src/spec/windows_gnu_base.rs7
2 files changed, 4 insertions, 9 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
index faeb727..87d539f 100644
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
@@ -1333,9 +1333,6 @@ fn add_late_link_args(
1333 crate_type: CrateType, 1333 crate_type: CrateType,
1334 codegen_results: &CodegenResults, 1334 codegen_results: &CodegenResults,
1335) { 1335) {
1336 if let Some(args) = sess.target.target.options.late_link_args.get(&flavor) {
1337 cmd.args(args);
1338 }
1339 let any_dynamic_crate = crate_type == CrateType::Dylib 1336 let any_dynamic_crate = crate_type == CrateType::Dylib
1340 || codegen_results.crate_info.dependency_formats.iter().any(|(ty, list)| { 1337 || codegen_results.crate_info.dependency_formats.iter().any(|(ty, list)| {
1341 *ty == crate_type && list.iter().any(|&linkage| linkage == Linkage::Dynamic) 1338 *ty == crate_type && list.iter().any(|&linkage| linkage == Linkage::Dynamic)
@@ -1349,6 +1346,9 @@ fn add_late_link_args(
1349 cmd.args(args); 1346 cmd.args(args);
1350 } 1347 }
1351 } 1348 }
1349 if let Some(args) = sess.target.target.options.late_link_args.get(&flavor) {
1350 cmd.args(args);
1351 }
1352} 1352}
1353 1353
1354/// Add arbitrary "post-link" args defined by the target spec. 1354/// Add arbitrary "post-link" args defined by the target spec.
diff --git a/compiler/rustc_target/src/spec/windows_gnu_base.rs b/compiler/rustc_target/src/spec/windows_gnu_base.rs
index a864918..0234ff5 100644
--- a/compiler/rustc_target/src/spec/windows_gnu_base.rs
+++ b/compiler/rustc_target/src/spec/windows_gnu_base.rs
@@ -23,6 +23,7 @@ pub fn opts() -> TargetOptions {
23 "-lmsvcrt".to_string(), 23 "-lmsvcrt".to_string(),
24 "-lmingwex".to_string(), 24 "-lmingwex".to_string(),
25 "-lmingw32".to_string(), 25 "-lmingw32".to_string(),
26 "-lgcc".to_string(), // alas, mingw* libraries above depend on libgcc
26 // mingw's msvcrt is a weird hybrid import library and static library. 27 // mingw's msvcrt is a weird hybrid import library and static library.
27 // And it seems that the linker fails to use import symbols from msvcrt 28 // And it seems that the linker fails to use import symbols from msvcrt
28 // that are required from functions in msvcrt in certain cases. For example 29 // that are required from functions in msvcrt in certain cases. For example
@@ -41,8 +42,6 @@ pub fn opts() -> TargetOptions {
41 // the shared libgcc_s-dw2-1.dll. This is required to support 42 // the shared libgcc_s-dw2-1.dll. This is required to support
42 // unwinding across DLL boundaries. 43 // unwinding across DLL boundaries.
43 "-lgcc_s".to_string(), 44 "-lgcc_s".to_string(),
44 "-lgcc".to_string(),
45 "-lkernel32".to_string(),
46 ]; 45 ];
47 late_link_args_dynamic.insert(LinkerFlavor::Gcc, dynamic_unwind_libs.clone()); 46 late_link_args_dynamic.insert(LinkerFlavor::Gcc, dynamic_unwind_libs.clone());
48 late_link_args_dynamic.insert(LinkerFlavor::Lld(LldFlavor::Ld), dynamic_unwind_libs); 47 late_link_args_dynamic.insert(LinkerFlavor::Lld(LldFlavor::Ld), dynamic_unwind_libs);
@@ -54,10 +53,6 @@ pub fn opts() -> TargetOptions {
54 // boundaries when unwinding across FFI boundaries. 53 // boundaries when unwinding across FFI boundaries.
55 "-lgcc_eh".to_string(), 54 "-lgcc_eh".to_string(),
56 "-l:libpthread.a".to_string(), 55 "-l:libpthread.a".to_string(),
57 "-lgcc".to_string(),
58 // libpthread depends on libmsvcrt, so we need to link it *again*.
59 "-lmsvcrt".to_string(),
60 "-lkernel32".to_string(),
61 ]; 56 ];
62 late_link_args_static.insert(LinkerFlavor::Gcc, static_unwind_libs.clone()); 57 late_link_args_static.insert(LinkerFlavor::Gcc, static_unwind_libs.clone());
63 late_link_args_static.insert(LinkerFlavor::Lld(LldFlavor::Ld), static_unwind_libs); 58 late_link_args_static.insert(LinkerFlavor::Lld(LldFlavor::Ld), static_unwind_libs);