bazel: re-land wasmtime 42 upgrade with LTO fix#30390
Merged
travisdowns merged 2 commits intoredpanda-data:devfrom May 7, 2026
Merged
bazel: re-land wasmtime 42 upgrade with LTO fix#30390travisdowns merged 2 commits intoredpanda-data:devfrom
travisdowns merged 2 commits intoredpanda-data:devfrom
Conversation
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.
Re-land of 08fc3c5, which was reverted in 6116d3a (PR redpanda-data#30387) because the upgrade broke the `--config=lto` / `--config=pgo-instrument` link with: ld.lld: error: undefined symbol: __rustc::__rust_no_alloc_shim_is_unstable_v2 That LTO failure is fixed by the preceding commit switching the rust LTO mode from fat to thin; this commit re-introduces the upgrade unchanged. Additional changes required by the upgrade: - Bump Rust toolchain from 1.86.0 to 1.91.0 (wasmtime 42 MSRV) - Add PULLEY and ALL_ARCH feature flags to wasmtime.BUILD conf.h template substitutions (new in wasmtime 42) - Remove wasmtime_config_async_support_set() call: async support is now implicit, the separate toggle was deprecated and removed from the C API (bytecodealliance/wasmtime#12371) - Bump rules_rust 0.60.0 -> 0.70.0 and opt in to experimental_use_allocator_libraries_with_mangled_symbols so the mangled __rustc::* allocator shim symbols (introduced in rustc 1.87+) are provided when a Rust staticlib is linked into a cc_binary via cc_common.link. Without this flag the link fails with undefined references to __rustc::__rust_alloc, __rustc::__rust_dealloc, etc. Background: - Issue: bazelbuild/rules_rust#3459 - Fix PR: bazelbuild/rules_rust#3403 - Landed in rules_rust 0.63.0 as an opt-in setting. - Mirror the rustc tarball through vectorized-public to reduce dependence on static.rust-lang.org. - Incidental: bump bazel_skylib 1.8.1 -> 1.8.2 and rules_shell 0.4.1 -> 0.6.1 to silence direct-dependency version warnings pulled in by the new rules_rust.
Contributor
There was a problem hiding this comment.
Pull request overview
Re-lands the Bazel-based wasmtime upgrade (32.0.0 → 42.0.2) and adjusts the Bazel Rust LTO configuration to avoid allocator shim symbol resolution failures when building with LTO/PGO instrumentation.
Changes:
- Switch Rust LTO in the
ltoBazel config from fat LTO to thin LTO, and enable rules_rust’s mangled allocator shim libraries to satisfy__rustc::*allocator shim references. - Upgrade wasmtime (Rust crates + lockfile) to 42.0.2 and update the Rust toolchain version to meet the new MSRV.
- Update wasmtime C/C++ integration points: drop the removed async-support config call and extend the generated
conf.hsubstitutions for new feature macros.
Reviewed changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/v/wasm/wasmtime.cc |
Removes the deprecated/removed wasmtime C-API async-support toggle call during engine configuration. |
MODULE.bazel |
Bumps the Rust toolchain version used by Bazel to match the new wasmtime MSRV. |
bazel/thirdparty/wasmtime.BUILD |
Extends conf.h.in template substitutions to handle additional wasmtime feature macros introduced in newer versions. |
bazel/thirdparty/Cargo.toml |
Upgrades wasmtime crate dependencies to 42.0.2. |
bazel/thirdparty/Cargo.lock |
Refreshes the Rust dependency lockfile to match the wasmtime 42.0.2 upgrade. |
.bazelrc |
Enables mangled allocator shim libraries and switches Rust LTO to thin LTO under --config=lto to fix LTO link failures. |
dotnwat
approved these changes
May 6, 2026
Collaborator
CI test resultstest results on build#84117
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Re-lands the wasmtime 32 → 42 upgrade (#30263), which was reverted in
#30387 because it broke
--config=lto/--config=pgo-instrumentbuilds with:
Two commits:
bazel: switch rust LTO from fat to thin— fixes the link failure.The empty
allocator_librarystaticlib used by rules_rust'sexperimental_use_allocator_libraries_with_mangled_symbolsexistsonly so rustc auto-injects the
__rustc::__rust_*allocator shimsymbols with GLOBAL binding, satisfying the rust stdlib's GLOBAL
undefined refs to those symbols. With
-Clto=fat, rustc runs LLVM'sInternalizepass over the staticlib before emitting it; nothinginside the empty crate references those shims, so they get
downgraded GLOBAL → LOCAL. ELF then refuses to bind the stdlib's
GLOBAL refs to LOCAL defs across object files, and the link fails.
Thin LTO doesn't run that whole-crate internalization step, so the
symbols stay GLOBAL and the link succeeds.
Verified bit-identical (
md5sum)//:redpandaoutput before andafter this change under
--config=pgo-instrument. Every wasmtimecrate is a
rust_library(rlib), and for rlibs rules_rust emits-Clinker-plugin-ltoregardless of the-Cltomode — so the rlibbitcode is the same either way. The actual cross-language LTO
happens later at the C++ thin-LTO link step.
bazel/wasm: upgrade wasmtime from 32.0.0 to 42.0.2— identicalto the original PR bazel/wasm: upgrade wasmtime from 32.0.0 to 42.0.2 #30263 commit (08fc3c5), re-applied on top of
the LTO fix.
Verified end-to-end with a full
bazel build --config=pgo-instrument //:redpandaon this branch.Backports Required
Release Notes