about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
diff options
context:
space:
mode:
authorDianQK <dianqk@dianqk.net>2023-12-03 19:16:55 +0800
committerDianQK <dianqk@dianqk.net>2023-12-05 07:50:14 +0800
commitca0738f98152c15909cef69760f2c47e31a5eeff (patch)
tree71a37701cd4e318abfc80bdcb2526244e459c223 /compiler/rustc_codegen_ssa/src
parent9ed0d11efbec18a1fa4155576a3bcb685676d23c (diff)
downloadrust-ca0738f98152c15909cef69760f2c47e31a5eeff.tar.gz
rust-ca0738f98152c15909cef69760f2c47e31a5eeff.zip
Consider only `#[no_mangle]` as builtin functions
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
-rw-r--r--compiler/rustc_codegen_ssa/src/back/symbol_export.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs
index f7d6a4aa75d..f9ad8ca9563 100644
--- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs
+++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs
@@ -105,12 +105,14 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
             }
         })
         .map(|def_id| {
+            let codegen_attrs = tcx.codegen_fn_attrs(def_id.to_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;
             // 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);
+                    .is_below_threshold(SymbolExportLevel::C)
+                && codegen_attrs.flags.contains(CodegenFnAttrFlags::NO_MANGLE);
             let used = name == "rust_eh_personality";
 
             let export_level = if special_runtime_crate {
@@ -118,7 +120,6 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
             } else {
                 symbol_export_level(tcx, def_id.to_def_id())
             };
-            let codegen_attrs = tcx.codegen_fn_attrs(def_id.to_def_id());
             debug!(
                 "EXPORTED SYMBOL (local): {} ({:?})",
                 tcx.symbol_name(Instance::mono(tcx, def_id.to_def_id())),