Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,17 @@ impl<'ll, 'tcx> MiscCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
DUMMY_SP,
)),
_ => {
let name = name.unwrap_or("rust_eh_personality");
let mangled_symbol;
let name = match name {
Some(name) => name,
None => {
mangled_symbol = rustc_symbol_mangling::mangle_internal_symbol(
tcx,
"rust_eh_personality",
);
mangled_symbol.as_str()
}
};
if let Some(llfn) = self.get_declared_value(name) {
llfn
} else {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/back/symbol_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use rustc_ast::expand::allocator::{
ALLOC_ERROR_HANDLER, ALLOCATOR_METHODS, NO_ALLOC_SHIM_IS_UNSTABLE, global_fn_name,
};
use rustc_data_structures::unord::UnordMap;
use rustc_hir::LangItem;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LOCAL_CRATE, LocalDefId};
use rustc_middle::bug;
Expand Down Expand Up @@ -105,8 +106,7 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
})
.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 used = tcx.is_lang_item(def_id.to_def_id(), LangItem::EhPersonality);

let export_level = if special_runtime_crate {
SymbolExportLevel::Rust
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_symbol_mangling/src/v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ pub(super) fn mangle<'tcx>(

pub fn mangle_internal_symbol<'tcx>(tcx: TyCtxt<'tcx>, item_name: &str) -> String {
match item_name {
// rust_eh_personality must not be renamed as LLVM hard-codes the name
"rust_eh_personality" => return item_name.to_owned(),
// Apple availability symbols need to not be mangled to be usable by
// C/Objective-C code.
"__isPlatformVersionAtLeast" | "__isOSVersionAtLeast" => return item_name.to_owned(),
Expand Down
Loading