Link dynamic and static late_link_args before generic ones
This commit is contained in:
parent
e599b53e67
commit
bfdb7903c9
@ -1333,9 +1333,6 @@ fn add_late_link_args(
|
||||
crate_type: CrateType,
|
||||
codegen_results: &CodegenResults,
|
||||
) {
|
||||
if let Some(args) = sess.target.target.options.late_link_args.get(&flavor) {
|
||||
cmd.args(args);
|
||||
}
|
||||
let any_dynamic_crate = crate_type == CrateType::Dylib
|
||||
|| codegen_results.crate_info.dependency_formats.iter().any(|(ty, list)| {
|
||||
*ty == crate_type && list.iter().any(|&linkage| linkage == Linkage::Dynamic)
|
||||
@ -1349,6 +1346,9 @@ fn add_late_link_args(
|
||||
cmd.args(args);
|
||||
}
|
||||
}
|
||||
if let Some(args) = sess.target.target.options.late_link_args.get(&flavor) {
|
||||
cmd.args(args);
|
||||
}
|
||||
}
|
||||
|
||||
/// Add arbitrary "post-link" args defined by the target spec.
|
||||
|
@ -23,6 +23,7 @@ pub fn opts() -> TargetOptions {
|
||||
"-lmsvcrt".to_string(),
|
||||
"-lmingwex".to_string(),
|
||||
"-lmingw32".to_string(),
|
||||
"-lgcc".to_string(), // alas, mingw* libraries above depend on libgcc
|
||||
// mingw's msvcrt is a weird hybrid import library and static library.
|
||||
// And it seems that the linker fails to use import symbols from msvcrt
|
||||
// that are required from functions in msvcrt in certain cases. For example
|
||||
@ -41,8 +42,6 @@ pub fn opts() -> TargetOptions {
|
||||
// the shared libgcc_s-dw2-1.dll. This is required to support
|
||||
// unwinding across DLL boundaries.
|
||||
"-lgcc_s".to_string(),
|
||||
"-lgcc".to_string(),
|
||||
"-lkernel32".to_string(),
|
||||
];
|
||||
late_link_args_dynamic.insert(LinkerFlavor::Gcc, dynamic_unwind_libs.clone());
|
||||
late_link_args_dynamic.insert(LinkerFlavor::Lld(LldFlavor::Ld), dynamic_unwind_libs);
|
||||
@ -54,10 +53,6 @@ pub fn opts() -> TargetOptions {
|
||||
// boundaries when unwinding across FFI boundaries.
|
||||
"-lgcc_eh".to_string(),
|
||||
"-l:libpthread.a".to_string(),
|
||||
"-lgcc".to_string(),
|
||||
// libpthread depends on libmsvcrt, so we need to link it *again*.
|
||||
"-lmsvcrt".to_string(),
|
||||
"-lkernel32".to_string(),
|
||||
];
|
||||
late_link_args_static.insert(LinkerFlavor::Gcc, static_unwind_libs.clone());
|
||||
late_link_args_static.insert(LinkerFlavor::Lld(LldFlavor::Ld), static_unwind_libs);
|
||||
|
Loading…
Reference in New Issue
Block a user