@@ -1764,11 +1764,6 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
1764
1764
1765
1765
// ------------ Early order-dependent options ------------
1766
1766
1767
- // Avoid linking to dynamic libraries unless they satisfy some undefined symbols
1768
- // at the point at which they are specified on the command line.
1769
- // Must be passed before any (dynamic) libraries to have effect on them.
1770
- cmd. add_as_needed ( ) ;
1771
-
1772
1767
// If we're building something like a dynamic library then some platforms
1773
1768
// need to make sure that all symbols are exported correctly from the
1774
1769
// dynamic library.
@@ -1822,6 +1817,16 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
1822
1817
add_local_crate_metadata_objects ( cmd, crate_type, codegen_results) ;
1823
1818
add_local_crate_allocator_objects ( cmd, codegen_results) ;
1824
1819
1820
+ // Avoid linking to dynamic libraries unless they satisfy some undefined symbols
1821
+ // at the point at which they are specified on the command line.
1822
+ // Must be passed before any (dynamic) libraries to have effect on them.
1823
+ // On Solaris-like systems, `-z ignore` acts as both `--as-needed` and `--gc-sections`
1824
+ // so it will ignore unreferenced ELF sections from relocatable objects.
1825
+ // For that reason, we put this flag after metadata objects as they would otherwise be removed.
1826
+ // FIXME: Support more fine-grained dead code removal on Solaris/illumos
1827
+ // and move this option back to the top.
1828
+ cmd. add_as_needed ( ) ;
1829
+
1825
1830
// FIXME: Move this below to other native libraries
1826
1831
// (or alternatively link all native libraries after their respective crates).
1827
1832
// This change is somewhat breaking in practice due to local static libraries being linked
0 commit comments