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.
This commit is contained in:
bjorn3 2025-10-29 12:58:55 +00:00
parent bd3ac03300
commit 964d3af793
2 changed files with 4 additions and 6 deletions

View file

@ -77,6 +77,9 @@ fn prepare_lto(
// should have default visibility.
symbols_below_threshold.push(c"__llvm_profile_counter_bias".to_owned());
// LTO seems to discard this otherwise under certain circumstances.
symbols_below_threshold.push(c"rust_eh_personality".to_owned());
// If we're performing LTO for the entire crate graph, then for each of our
// upstream dependencies, find the corresponding rlib and load the bitcode
// from the archive.

View file

@ -104,10 +104,6 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
if tcx.cross_crate_inlinable(def_id) { None } else { Some(def_id) }
})
.map(|def_id| {
// We won't link right if this symbol is stripped during LTO.
let name = tcx.symbol_name(Instance::mono(tcx, def_id.to_def_id())).name;
let used = name == "rust_eh_personality";
let export_level = if special_runtime_crate {
SymbolExportLevel::Rust
} else {
@ -131,8 +127,7 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
SymbolExportKind::Text
},
used: codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_COMPILER)
|| codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER)
|| used,
|| codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER),
rustc_std_internal_symbol: codegen_attrs
.flags
.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL),