Stop exporting rust_eh_personality and friends from cdylib

This commit is contained in:
Gary Guo 2022-04-25 14:06:30 +01:00
parent 1af3e0a65e
commit 6f9b2b3247

View file

@ -105,24 +105,18 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, cnum: CrateNum) -> DefIdMap<
}
})
.map(|def_id| {
let export_level = if special_runtime_crate {
let (export_level, used) = if special_runtime_crate {
let name = tcx.symbol_name(Instance::mono(tcx, def_id.to_def_id())).name;
// We can probably do better here by just ensuring that
// it has hidden visibility rather than public
// visibility, as this is primarily here to ensure it's
// not stripped during LTO.
//
// In general though we won't link right if these
// symbols are stripped, and LTO currently strips them.
match name {
// We won't link right if these symbols are stripped during LTO.
let used = match name {
"rust_eh_personality"
| "rust_eh_register_frames"
| "rust_eh_unregister_frames" =>
SymbolExportLevel::C,
_ => SymbolExportLevel::Rust,
}
| "rust_eh_unregister_frames" => true,
_ => false,
};
(SymbolExportLevel::Rust, used)
} else {
symbol_export_level(tcx, def_id.to_def_id())
(symbol_export_level(tcx, def_id.to_def_id()), false)
};
let codegen_attrs = tcx.codegen_fn_attrs(def_id.to_def_id());
debug!(
@ -142,7 +136,7 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, cnum: CrateNum) -> DefIdMap<
SymbolExportKind::Text
},
used: codegen_attrs.flags.contains(CodegenFnAttrFlags::USED)
|| codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER),
|| codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER) || used,
})
})
.collect();