diff options
| author | DianQK <dianqk@dianqk.net> | 2023-10-18 22:29:00 +0800 |
|---|---|---|
| committer | DianQK <dianqk@dianqk.net> | 2023-10-21 19:14:01 +0800 |
| commit | b592f29a8e7b1f83958f429ca42947f32ec6898c (patch) | |
| tree | 72e9ee3579e7db338a79c353e02392d85c7641e2 /compiler/rustc_codegen_ssa/src/back | |
| parent | 665da1ed320abeaf276dafbfd041ebcda50034cf (diff) | |
| download | rust-b592f29a8e7b1f83958f429ca42947f32ec6898c.tar.gz rust-b592f29a8e7b1f83958f429ca42947f32ec6898c.zip | |
Treat extern in compiler-builtins as `used`
We have to preserve the symbols of the built-in functions during LTO.
Diffstat (limited to 'compiler/rustc_codegen_ssa/src/back')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/symbol_export.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index 9cd4394108a..0e436f247b0 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -54,8 +54,8 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S // export level, however, as they're just implementation details. // Down below we'll hardwire all of the symbols to the `Rust` export // level instead. - let special_runtime_crate = - tcx.is_panic_runtime(LOCAL_CRATE) || tcx.is_compiler_builtins(LOCAL_CRATE); + let is_compiler_builtins = tcx.is_compiler_builtins(LOCAL_CRATE); + let special_runtime_crate = tcx.is_panic_runtime(LOCAL_CRATE) || is_compiler_builtins; let mut reachable_non_generics: DefIdMap<_> = tcx .reachable_set(()) @@ -107,7 +107,11 @@ 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"; + // We have to preserve the symbols of the built-in functions during LTO. + let is_builtin_fn = is_compiler_builtins + && symbol_export_level(tcx, def_id.to_def_id()) + .is_below_threshold(SymbolExportLevel::C); + let used = is_builtin_fn || name == "rust_eh_personality"; let export_level = if special_runtime_crate { SymbolExportLevel::Rust |
