diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2021-06-06 17:48:18 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2021-06-06 17:48:18 +0300 |
| commit | 3eab2805676b9be331ae7a1cfe5bb4124dc6a2d3 (patch) | |
| tree | 3ba88e5a0c07fce18d90e8b2ad12c8e08abe016b /compiler/rustc_codegen_ssa/src | |
| parent | 5275bf1c1d1cc1adf68fd5165baa75005e790b28 (diff) | |
| download | rust-3eab2805676b9be331ae7a1cfe5bb4124dc6a2d3.tar.gz rust-3eab2805676b9be331ae7a1cfe5bb4124dc6a2d3.zip | |
linker: Re-apply Solaris fixes for `-z ignore`
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/link.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 71f5b1e09d0..f9f59be1e8b 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -1764,11 +1764,6 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>( // ------------ Early order-dependent options ------------ - // Avoid linking to dynamic libraries unless they satisfy some undefined symbols - // at the point at which they are specified on the command line. - // Must be passed before any (dynamic) libraries to have effect on them. - cmd.add_as_needed(); - // If we're building something like a dynamic library then some platforms // need to make sure that all symbols are exported correctly from the // dynamic library. @@ -1822,6 +1817,16 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>( add_local_crate_metadata_objects(cmd, crate_type, codegen_results); add_local_crate_allocator_objects(cmd, codegen_results); + // Avoid linking to dynamic libraries unless they satisfy some undefined symbols + // at the point at which they are specified on the command line. + // Must be passed before any (dynamic) libraries to have effect on them. + // On Solaris-like systems, `-z ignore` acts as both `--as-needed` and `--gc-sections` + // so it will ignore unreferenced ELF sections from relocatable objects. + // For that reason, we put this flag after metadata objects as they would otherwise be removed. + // FIXME: Support more fine-grained dead code removal on Solaris/illumos + // and move this option back to the top. + cmd.add_as_needed(); + // FIXME: Move this below to other native libraries // (or alternatively link all native libraries after their respective crates). // This change is somewhat breaking in practice due to local static libraries being linked |
