Commit 33dc207
committed
bazel: switch rust LTO from fat to thin
Fixes the `--config=lto` / `--config=pgo-instrument` link, which
started failing with the wasmtime 42 upgrade (rust 1.91) with errors
like:
ld.lld: error: undefined symbol: __rustc::__rust_no_alloc_shim_is_unstable_v2
The empty `allocator_library` staticlib used by rules_rust's
`experimental_use_allocator_libraries_with_mangled_symbols` exists
only so rustc auto-injects the `__rustc::__rust_*` allocator shims
with GLOBAL binding, satisfying the rust stdlib's GLOBAL undefined
refs to those symbols. Under fat LTO, rustc runs LLVM's Internalize
pass over the staticlib before emitting it; nothing inside the empty
crate references the shims, so they get downgraded GLOBAL -> LOCAL
and ELF then refuses to bind the stdlib's GLOBAL refs to LOCAL defs
across object files. Thin LTO doesn't run that whole-crate
internalization, so the symbols stay GLOBAL and the link succeeds.
No measurable cost: with --config=pgo-instrument the resulting
//:redpanda binary is bit-identical (md5) before and after this
change. Every wasmtime crate is a `rust_library` (rlib), and for
rlibs rules_rust emits `-Clinker-plugin-lto` regardless of the
-Clto mode, so the rlib bitcode is the same either way -- the actual
cross-language LTO happens later at the C++ thin-LTO link step.1 parent 38d10c2 commit 33dc207
1 file changed
Lines changed: 16 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
152 | | - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
153 | 168 | | |
154 | 169 | | |
155 | 170 | | |
| |||
0 commit comments