Skip to content

bazel/wasm: upgrade wasmtime from 32.0.0 to 42.0.2#30250

Closed
travisdowns wants to merge 1 commit intoredpanda-data:devfrom
travisdowns:td-hermetic-wasmtime42
Closed

bazel/wasm: upgrade wasmtime from 32.0.0 to 42.0.2#30250
travisdowns wants to merge 1 commit intoredpanda-data:devfrom
travisdowns:td-hermetic-wasmtime42

Conversation

@travisdowns
Copy link
Copy Markdown
Member

@travisdowns travisdowns commented Apr 22, 2026

Motivation: make the Bazel build of //:redpanda byte-for-byte
reproducible. #30187 did this for hwloc, openssl, and libxml2 via local
rules_foreign_cc build tweaks, but for the wasmtime / cranelift side
of things we had two local reproducibility patches that were already
fixed upstream and only required a version bump to pick up. Per the
discussion on #30187 (#30187 (comment)),
the cleaner path is to drop the patches and upgrade wasmtime instead —
which is what this PR does.

The minimum wasmtime version that carries both cranelift fixes is v42,
so this is a jump from v32.0.0 to v42.0.2. The upgrade brings along the
following required adjustments:

  • Rust toolchain bump from 1.86.0 to 1.91.0 (wasmtime 42 MSRV).
  • Add PULLEY and ALL_ARCH feature flags to the wasmtime.BUILD
    conf.h template substitutions (new in wasmtime 42).
  • Drop the wasmtime_config_async_support_set() call. Async support
    is implicit now — the separate toggle was deprecated and removed
    from the C API in Remove need for explicit Config::async_support knob  bytecodealliance/wasmtime#12371.
  • Introduce a local rust_alloc_shim workaround. Rust >= 1.87 changed
    how allocator shim symbols are emitted when linking Rust static
    libraries into C++ binaries via cc_common.link; rules_rust 0.60.0
    does not yet handle this (cc_common_link is broken in rust 1.87.0 bazelbuild/rules_rust#3459). The shim can
    be removed once rules_rust picks up the fix — tracked in CORE-16131.

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v25.3.x
  • v25.2.x
  • v25.1.x

Release Notes

  • none

Copilot AI review requested due to automatic review settings April 22, 2026 21:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Upgrades the Bazel-managed Wasmtime integration to Wasmtime v42.0.2, updating the Rust toolchain and adjusting build/runtime glue to match upstream C API and build template changes.

Changes:

  • Bump Wasmtime crates from 32.0.0 to 42.0.2 (Cargo.toml / Cargo.lock) and update generated conf.h template substitutions.
  • Update the Rust toolchain version to Rust 1.91.0 (Wasmtime 42 MSRV).
  • Remove deprecated Wasmtime C API async toggle call and introduce a Bazel-side rust_alloc_shim workaround dependency.

Reviewed changes

Copilot reviewed 7 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/v/wasm/wasmtime.cc Removes the removed/deprecated async-support config call from runtime initialization.
src/v/wasm/BUILD Adds the new rust_alloc_shim dependency to the Wasmtime C++ library build.
bazel/thirdparty/wasmtime.BUILD Extends conf.h template substitutions for new Wasmtime 42 feature defines.
bazel/thirdparty/rust_alloc_shim.rs Adds an “empty” Rust crate intended to pull allocator symbols into the final link.
bazel/thirdparty/Cargo.toml Bumps Wasmtime-related crate versions to 42.0.2.
bazel/thirdparty/Cargo.lock Updates the full Rust dependency graph lockfile for the Wasmtime upgrade.
bazel/thirdparty/BUILD Introduces rust_alloc_shim and empty_alloc Bazel targets for allocator-shim workaround.
MODULE.bazel Adds documentation about the allocator-shim workaround and bumps Rust toolchain version.

Comment thread bazel/thirdparty/rust_alloc_shim.rs Outdated
Comment on lines +1 to +2
// Empty crate that provides Rust allocator symbols when linked.
// See https://github.com/bazelbuild/rules_rust/issues/3459
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new rust_alloc_shim crate is completely empty (comments only). If the goal is to reliably pull allocator symbols into the final link, consider adding a minimal reference that forces linking the relevant Rust runtime/alloc components; as-is, the crate itself does not define any allocator symbols and may not achieve the intended workaround under dead-code elimination.

Suggested change
// Empty crate that provides Rust allocator symbols when linked.
// See https://github.com/bazelbuild/rules_rust/issues/3459
// Minimal shim crate that forces a reference to Rust heap allocation code.
// See https://github.com/bazelbuild/rules_rust/issues/3459
//
// Keeping this crate comment-only does not reliably pull allocator-related
// symbols into the final link under dead-code elimination. Define and retain
// a tiny symbol that performs a heap allocation instead.
#[no_mangle]
pub extern "C" fn rust_alloc_shim_force_link() {
drop(Box::new(0u8));
}
#[used]
static RUST_ALLOC_SHIM_FORCE_LINK: extern "C" fn() = rust_alloc_shim_force_link;

Copilot uses AI. Check for mistakes.
Comment thread MODULE.bazel
Comment on lines 356 to 360
"aarch64-unknown-linux-gnu",
"x86_64-unknown-linux-gnu",
],
versions = ["1.86.0"],
versions = ["1.91.0"],
)
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

//bazel/thirdparty:empty_alloc is added as part of the allocator-shim workaround, but this rust.toolchain(...) registration doesn’t reference it (and a repo-wide search finds no references). If the intent is to override the toolchain’s allocator library to prevent double-linking, wire empty_alloc into the toolchain configuration here; otherwise consider removing the unused target/comment.

Copilot uses AI. Check for mistakes.
Comment thread bazel/thirdparty/BUILD Outdated
Comment on lines 21 to 25
cc_library(
name = "empty_alloc",
visibility = ["//visibility:public"],
)

Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty_alloc is introduced as part of the allocator shim workaround but appears unused (no references found anywhere in the repo). If it’s required for the workaround, add the missing reference from the Rust toolchain registration; otherwise remove it to avoid an extra public target that has no effect.

Suggested change
cc_library(
name = "empty_alloc",
visibility = ["//visibility:public"],
)

Copilot uses AI. Check for mistakes.
Comment thread bazel/thirdparty/BUILD Outdated
Comment on lines +11 to +13
# The empty cc_library is used as allocator_library in the toolchain
# registration to prevent rules_rust from double-linking its own
# allocator shim.
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment claims empty_alloc is used as allocator_library in the toolchain registration to prevent double-linking, but there are no references to //bazel/thirdparty:empty_alloc in the repo. Either wire it into the toolchain configuration or update/remove this comment so it doesn’t describe behavior that isn’t happening.

Suggested change
# The empty cc_library is used as allocator_library in the toolchain
# registration to prevent rules_rust from double-linking its own
# allocator shim.
# The empty cc_library is kept as a placeholder target for allocator-related
# toolchain integration, but this file does not wire it into any toolchain
# registration.

Copilot uses AI. Check for mistakes.
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)
- Add rust_alloc_shim workaround for Rust >= 1.87 allocator symbol
  changes that are not yet handled by rules_rust 0.60.0
  (bazelbuild/rules_rust#3459, CORE-16131)
@travisdowns travisdowns force-pushed the td-hermetic-wasmtime42 branch from fc68ab9 to 7f39714 Compare April 22, 2026 23:23
@vbotbuildovich
Copy link
Copy Markdown
Collaborator

CI test results

test results on build#83524
test_status test_class test_method test_arguments test_kind job_url passed reason test_history
FLAKY(PASS) ShadowLinkingReplicationTests test_replication_basic {"shuffle_leadership": true, "source_cluster_spec": {"cluster_type": "kafka", "kafka_quorum": "COMBINED_KRAFT", "kafka_version": "3.8.0"}, "storage_mode": "tiered"} integration https://buildkite.com/redpanda/redpanda/builds/83524#019db78d-2dbd-48b5-b1b7-0be3aec539ca 10/11 Test PASSES after retries.No significant increase in flaky rate(baseline=0.0000, p0=1.0000, reject_threshold=0.0100. adj_baseline=0.1000, p1=0.3487, trust_threshold=0.5000) https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=ShadowLinkingReplicationTests&test_method=test_replication_basic
FLAKY(PASS) ShadowLinkingReplicationTests test_with_restart {"storage_mode": "tiered_cloud"} integration https://buildkite.com/redpanda/redpanda/builds/83524#019db78d-2dbb-48d1-b6e3-b460c414f645 28/31 Test PASSES after retries.No significant increase in flaky rate(baseline=0.0182, p0=0.1029, reject_threshold=0.0100. adj_baseline=0.1000, p1=0.4114, trust_threshold=0.5000) https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=ShadowLinkingReplicationTests&test_method=test_with_restart
FLAKY(PASS) RedpandaNodeOperationsSmokeTest test_node_ops_smoke_test {"cloud_storage_type": 1, "mixed_versions": false} integration https://buildkite.com/redpanda/redpanda/builds/83524#019db78b-c5cb-42c7-8c16-acd1215b85d0 10/11 Test PASSES after retries.No significant increase in flaky rate(baseline=0.0020, p0=1.0000, reject_threshold=0.0100. adj_baseline=0.1000, p1=0.3487, trust_threshold=0.5000) https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=RedpandaNodeOperationsSmokeTest&test_method=test_node_ops_smoke_test
FLAKY(PASS) RedpandaNodeOperationsSmokeTest test_node_ops_smoke_test {"cloud_storage_type": 1, "mixed_versions": true} integration https://buildkite.com/redpanda/redpanda/builds/83524#019db78b-c5cb-48a0-bebf-33ecfd9a2e5d 10/11 Test PASSES after retries.No significant increase in flaky rate(baseline=0.0000, p0=1.0000, reject_threshold=0.0100. adj_baseline=0.1000, p1=0.3487, trust_threshold=0.5000) https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=RedpandaNodeOperationsSmokeTest&test_method=test_node_ops_smoke_test
FLAKY(PASS) WriteCachingFailureInjectionE2ETest test_crash_all {"use_transactions": false} integration https://buildkite.com/redpanda/redpanda/builds/83524#019db78d-2db5-42be-9e1b-96b8f418329f 9/11 Test PASSES after retries.No significant increase in flaky rate(baseline=0.0759, p0=0.5458, reject_threshold=0.0100. adj_baseline=0.2108, p1=0.3441, trust_threshold=0.5000) https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=WriteCachingFailureInjectionE2ETest&test_method=test_crash_all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants