From 9ed0d11efbec18a1fa4155576a3bcb685676d23c Mon Sep 17 00:00:00 2001 From: DianQK Date: Sun, 3 Dec 2023 18:55:42 +0800 Subject: [PATCH] Avoid adding compiler-used functions to `symbols.o` --- compiler/rustc_codegen_llvm/src/back/lto.rs | 2 +- .../rustc_codegen_ssa/src/back/symbol_export.rs | 13 ++++++++++++- .../rustc_middle/src/middle/exported_symbols.rs | 5 +++++ src/tools/miri/src/bin/miri.rs | 1 + tests/run-make/no-builtins-symbols/Makefile | 7 +++++++ tests/run-make/no-builtins-symbols/main.rs | 1 + 6 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 tests/run-make/no-builtins-symbols/Makefile create mode 100644 tests/run-make/no-builtins-symbols/main.rs diff --git a/compiler/rustc_codegen_llvm/src/back/lto.rs b/compiler/rustc_codegen_llvm/src/back/lto.rs index db297425b03..abc33a04598 100644 --- a/compiler/rustc_codegen_llvm/src/back/lto.rs +++ b/compiler/rustc_codegen_llvm/src/back/lto.rs @@ -60,7 +60,7 @@ fn prepare_lto( }; let symbol_filter = &|&(ref name, info): &(String, SymbolExportInfo)| { - if info.level.is_below_threshold(export_threshold) || info.used { + if info.level.is_below_threshold(export_threshold) || info.used || info.used_compiler { Some(CString::new(name.as_str()).unwrap()) } else { None diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index 5f2fad0536b..f7d6a4aa75d 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -111,7 +111,7 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap, _: LocalCrate) -> DefIdMap, _: LocalCrate) -> DefIdMap