about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-12-07 20:31:55 +0000
committerbors <bors@rust-lang.org>2023-12-07 20:31:55 +0000
commit503e129328080e924c0ddfca6abf4c2812580102 (patch)
tree0f2ffd2b117cd2349c7a9639545d8b4d11736441 /compiler/rustc_codegen_llvm/src
parent0e7f91b75e7484a713e2f644212cfc1aa7478a28 (diff)
parentca0738f98152c15909cef69760f2c47e31a5eeff (diff)
downloadrust-503e129328080e924c0ddfca6abf4c2812580102.tar.gz
rust-503e129328080e924c0ddfca6abf4c2812580102.zip
Auto merge of #118568 - DianQK:no-builtins-symbols, r=pnkfelix
Avoid adding builtin functions to `symbols.o`

We found performance regressions in #113923. The problem seems to be that `--gc-sections` does not remove these symbols. I tested that lld removes these symbols, but ld and gold do not.

I found that `used` adds symbols to `symbols.o` at https://github.com/rust-lang/rust/blob/3e202ead604be31f4c1a5798a296953d3159da7e/compiler/rustc_codegen_ssa/src/back/linker.rs#L1786-L1791.
The PR removes builtin functions.

Note that under LTO, ld still preserves these symbols. (lld will still remove them.)

The first commit also fixes #118559. But I think the second commit also makes sense.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
-rw-r--r--compiler/rustc_codegen_llvm/src/back/lto.rs2
1 files changed, 1 insertions, 1 deletions
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