From 964d3af793eeebbe4aa1289ffdffeca6e3d56664 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Wed, 29 Oct 2025 12:58:55 +0000 Subject: [PATCH 1/2] Move a special case for rust_eh_personality from reachable_non_generics to cg_llvm This is a workaround for an LLVM bug, so put it in cg_llvm. --- compiler/rustc_codegen_llvm/src/back/lto.rs | 3 +++ compiler/rustc_codegen_ssa/src/back/symbol_export.rs | 7 +------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/back/lto.rs b/compiler/rustc_codegen_llvm/src/back/lto.rs index 5ac3a87c158e6..02b50fa8a6971 100644 --- a/compiler/rustc_codegen_llvm/src/back/lto.rs +++ b/compiler/rustc_codegen_llvm/src/back/lto.rs @@ -77,6 +77,9 @@ fn prepare_lto( // should have default visibility. symbols_below_threshold.push(c"__llvm_profile_counter_bias".to_owned()); + // LTO seems to discard this otherwise under certain circumstances. + symbols_below_threshold.push(c"rust_eh_personality".to_owned()); + // If we're performing LTO for the entire crate graph, then for each of our // upstream dependencies, find the corresponding rlib and load the bitcode // from the archive. diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index 5bc18e2d7f8bb..8a1f20826a946 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -104,10 +104,6 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap, _: LocalCrate) -> DefIdMap Date: Wed, 29 Oct 2025 13:06:24 +0000 Subject: [PATCH 2/2] Remove special case for the panic runtime from reachable_non_generics The panic runtime uses #[rustc_std_internal_symbol] which has the same effect as this special case with respect to symbol visibility. --- .../rustc_codegen_ssa/src/back/symbol_export.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index 8a1f20826a946..d9ba5017a422d 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -51,15 +51,7 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap = tcx .reachable_set(()) @@ -104,7 +96,12 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap