Skip to content

Commit b9c0f15

Browse files
committed
Fix LTO for internalizing rustc_std_internal_symbol symbols
1 parent c44a23c commit b9c0f15

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
@@ -1876,6 +1876,21 @@ pub(crate) fn linked_symbols(
18761876
}
18771877
}
18781878

1879+
match tcx.sess.lto() {
1880+
Lto::No | Lto::ThinLocal => {}
1881+
Lto::Thin | Lto::Fat => {
1882+
// We really only need symbols from upstream rlibs to end up in the linked symbols list.
1883+
// The rest are in separate object files which the linker will always link in and
1884+
// doesn't have rules around the order in which they need to appear.
1885+
// When doing LTO, some of the symbols in the linked symbols list may end up getting
1886+
// internalized, which then prevents referencing them from symbols.o. When doing LTO,
1887+
// all object files that get linked in will be local object files rather than pulled in
1888+
// from rlibs, so an empty linked symbols list works fine to avoid referencing all those
1889+
// internalized symbols from symbols.o.
1890+
return Vec::new();
1891+
}
1892+
}
1893+
18791894
let mut symbols = Vec::new();
18801895

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

0 commit comments

Comments
 (0)