Skip to content

Commit 964d3af

Browse files
committed
Move a special case for rust_eh_personality from reachable_non_generics to cg_llvm
This is a workaround for an LLVM bug, so put it in cg_llvm.
1 parent bd3ac03 commit 964d3af

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

compiler/rustc_codegen_llvm/src/back/lto.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ fn prepare_lto(
7777
// should have default visibility.
7878
symbols_below_threshold.push(c"__llvm_profile_counter_bias".to_owned());
7979

80+
// LTO seems to discard this otherwise under certain circumstances.
81+
symbols_below_threshold.push(c"rust_eh_personality".to_owned());
82+
8083
// If we're performing LTO for the entire crate graph, then for each of our
8184
// upstream dependencies, find the corresponding rlib and load the bitcode
8285
// from the archive.

compiler/rustc_codegen_ssa/src/back/symbol_export.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
104104
if tcx.cross_crate_inlinable(def_id) { None } else { Some(def_id) }
105105
})
106106
.map(|def_id| {
107-
// We won't link right if this symbol is stripped during LTO.
108-
let name = tcx.symbol_name(Instance::mono(tcx, def_id.to_def_id())).name;
109-
let used = name == "rust_eh_personality";
110-
111107
let export_level = if special_runtime_crate {
112108
SymbolExportLevel::Rust
113109
} else {
@@ -131,8 +127,7 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
131127
SymbolExportKind::Text
132128
},
133129
used: codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_COMPILER)
134-
|| codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER)
135-
|| used,
130+
|| codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER),
136131
rustc_std_internal_symbol: codegen_attrs
137132
.flags
138133
.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL),

0 commit comments

Comments
 (0)