In #122580 I added some code that prevents the magic compiler_builtins crate from linking against core. The replacement of calls happens as late as possible, so we end up with some odd behavior, where the LLVM IR and LLVM bitcode contain declarations of panic functions from core that are never called. We have those declarations because of this loop:
|
for &(mono_item, data) in &mono_items { |
|
mono_item.predefine::<Builder<'_, '_, '_>>(&cx, data.linkage, data.visibility); |
|
} |
We have MonoItems for the panic functions, and no calls to them. The key point is that we have MonoItems for items that we know would be invalid to call.
Is it possible to not have those MonoItems in builds of compiler_builtins?
One possible implementation of this would be to hoist this "error or abort on upstream call" to a MIR transform that's only run when building compiler_builtins. Then maybe we could drop the logic from cg_ssa?
In #122580 I added some code that prevents the magic
compiler_builtinscrate from linking againstcore. The replacement of calls happens as late as possible, so we end up with some odd behavior, where the LLVM IR and LLVM bitcode contain declarations of panic functions fromcorethat are never called. We have those declarations because of this loop:rust/compiler/rustc_codegen_llvm/src/base.rs
Lines 87 to 89 in d6eb0f5
We have
MonoItems for the panic functions, and no calls to them. The key point is that we haveMonoItems for items that we know would be invalid to call.Is it possible to not have those
MonoItems in builds ofcompiler_builtins?One possible implementation of this would be to hoist this "error or abort on upstream call" to a MIR transform that's only run when building
compiler_builtins. Then maybe we could drop the logic from cg_ssa?