Skip to content

Commit 2489701

Browse files
committed
Fix LTO for internalizing rustc_std_internal_symbol symbols
1 parent 6df5456 commit 2489701

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

compiler/rustc_codegen_ssa/src/back/linker.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,6 +1823,21 @@ pub(crate) fn linked_symbols(
18231823
}
18241824
}
18251825

1826+
match tcx.sess.lto() {
1827+
Lto::No | Lto::ThinLocal => {}
1828+
Lto::Thin | Lto::Fat => {
1829+
// We really only need symbols from upstream rlibs to end up in the linked symbols list.
1830+
// The rest are in separate object files which the linker will always link in and
1831+
// doesn't have rules around the order in which they need to appear.
1832+
// When doing LTO, some of the symbols in the linked symbols list may end up getting
1833+
// internalized, which then prevents referencing them from symbols.o. When doing LTO,
1834+
// all object files that get linked in will be local object files rather than pulled in
1835+
// from rlibs, so an empty linked symbols list works fine to avoid referencing all those
1836+
// internalized symbols from symbols.o.
1837+
return Vec::new();
1838+
}
1839+
}
1840+
18261841
let mut symbols = Vec::new();
18271842

18281843
let export_threshold = symbol_export::crates_export_threshold(&[crate_type]);

0 commit comments

Comments
 (0)