about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorLuqman Aden <me@luqman.ca>2021-05-27 18:59:32 -0700
committerLuqman Aden <me@luqman.ca>2021-05-27 22:13:39 -0700
commitcffef3385d33316344895db14016d55989e3649b (patch)
tree66fe3af5274c81a8a9981c39323c63ee8958a843 /compiler
parent1c6868aa21981b37cbd3fc95828ee3b0ac22d494 (diff)
downloadrust-cffef3385d33316344895db14016d55989e3649b.tar.gz
rust-cffef3385d33316344895db14016d55989e3649b.zip
Move metadata objects to before as-needed/zignore flags to make sure they are kept.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_codegen_ssa/src/back/link.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
index 32275e9b073..478b1ce5785 100644
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
@@ -1642,10 +1642,16 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
     // Make the binary compatible with data execution prevention schemes.
     cmd.add_no_exec();
 
+    // OBJECT-FILES-YES
+    add_local_crate_metadata_objects(cmd, crate_type, codegen_results);
+
     // NO-OPT-OUT, OBJECT-FILES-NO
     // 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.
+    // On solaris-like systems, this also will ignore unreferenced ELF sections
+    // from relocatable objects. For that reason, we move the metadata objects
+    // to before this flag as they would otherwise be removed.
     cmd.add_as_needed();
 
     // NO-OPT-OUT, OBJECT-FILES-NO
@@ -1698,9 +1704,6 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
     cmd.export_symbols(tmpdir, crate_type);
 
     // OBJECT-FILES-YES
-    add_local_crate_metadata_objects(cmd, crate_type, codegen_results);
-
-    // OBJECT-FILES-YES
     add_local_crate_allocator_objects(cmd, codegen_results);
 
     // OBJECT-FILES-NO, AUDIT-ORDER