Skip to content

Commit cffef33

Browse files
committed
Move metadata objects to before as-needed/zignore flags to make sure they are kept.
1 parent 1c6868a commit cffef33

File tree

1 file changed

+6
-3
lines changed
  • compiler/rustc_codegen_ssa/src/back

1 file changed

+6
-3
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1642,10 +1642,16 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
16421642
// Make the binary compatible with data execution prevention schemes.
16431643
cmd.add_no_exec();
16441644

1645+
// OBJECT-FILES-YES
1646+
add_local_crate_metadata_objects(cmd, crate_type, codegen_results);
1647+
16451648
// NO-OPT-OUT, OBJECT-FILES-NO
16461649
// Avoid linking to dynamic libraries unless they satisfy some undefined symbols
16471650
// at the point at which they are specified on the command line.
16481651
// Must be passed before any dynamic libraries.
1652+
// On solaris-like systems, this also will ignore unreferenced ELF sections
1653+
// from relocatable objects. For that reason, we move the metadata objects
1654+
// to before this flag as they would otherwise be removed.
16491655
cmd.add_as_needed();
16501656

16511657
// NO-OPT-OUT, OBJECT-FILES-NO
@@ -1697,9 +1703,6 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
16971703
// dynamic library.
16981704
cmd.export_symbols(tmpdir, crate_type);
16991705

1700-
// OBJECT-FILES-YES
1701-
add_local_crate_metadata_objects(cmd, crate_type, codegen_results);
1702-
17031706
// OBJECT-FILES-YES
17041707
add_local_crate_allocator_objects(cmd, codegen_results);
17051708

0 commit comments

Comments
 (0)