]> git.lizzy.rs Git - rust.git/commit
Auto merge of #102900 - abrachet:master, r=bjorn3
authorbors <bors@rust-lang.org>
Sun, 11 Dec 2022 14:42:45 +0000 (14:42 +0000)
committerbors <bors@rust-lang.org>
Sun, 11 Dec 2022 14:42:45 +0000 (14:42 +0000)
commitd137783642b0b98eda2796dc66bffc2b089a8327
treee9c78732ef81279fab96d40eca25b2f7a00831dc
parent4de4d60779ba9c1f79d851e8ffceb038e9042610
parent5d88d3605339d61c81d16b29a1c01edf771a8fe6
Auto merge of #102900 - abrachet:master, r=bjorn3

Don't internalize __llvm_profile_counter_bias

Currently, LLVM profiling runtime counter relocation cannot be used by rust during LTO because symbols are being internalized before all symbol information is known.

This mode makes LLVM emit a __llvm_profile_counter_bias symbol which is referenced by the profiling initialization, which itself is pulled in by the rust driver here [1].

It is enabled with -Cllvm-args=-runtime-counter-relocation for platforms which are opt-in to this mode like Linux. On these platforms there will be no link error, rather just surprising behavior for a user which request runtime counter relocation. The profiling runtime will not see that symbol go on as if it were never there. On Fuchsia, the profiling runtime must have this symbol which will cause a hard link error.

As an aside, I don't have enough context as to why rust's LTO model is how it is. AFAICT, the internalize pass is only safe to run at link time when all symbol information is actually known, this being an example as to why. I think special casing this symbol as a known one that LLVM can emit which should not have it's visbility de-escalated should be fine given how seldom this pattern of defining an undefined symbol to get initilization code pulled in is. From a quick grep, __llvm_profile_runtime is the only symbol that rustc does this for.

[1] https://github.com/rust-lang/rust/blob/0265a3e93bf1b89d97cae113ed214954d5c35e22/compiler/rustc_codegen_ssa/src/back/linker.rs#L598