posk-io opened PR #15292 from posk-io:posk/nostd-threads to bytecodealliance:main:
Currently the
threadsCargo feature on thewasmtimecrate impliesstd(threads = ["std"]). This prevents#![no_std]embedders (such as bare-metal or kernel hosts loading precompiled AOT modules withcustom-sync-primitives) from enablingWasmFeatures::THREADS, executing WebAssembly atomic instructions, or sharing aSharedMemoryacross multipleStores on separate host threads.This commit decouples
threadsfromstdwith a minimal set of runtime changes and without expanding thewasmtime-platform.hC API:
Remove
"std"from thethreadsfeature incrates/wasmtime/Cargo.tomland switchSharedMemoryfromstdtypes tocore/allocpluscrate::sync::RwLock(which delegates tostd::sync::RwLockwhenstdis enabled, host locks whencustom-sync-primitivesis enabled, or panic-on-contention in single-threadedno_stdbuilds).Route
SharedMemory::newthroughConfig::with_host_memory(falling back toDefaultMemoryCreator) instead of hardcodingMmapMemory. Module-defined shared memories inMemory::new_dynamicalready usedMemoryCreator, whereasSharedMemory::newdirectly calledMmapMemory::new, which is unavailable when!cfg!(has_virtual_memory)and ignored customMemoryCreators.LocalMemoryalready enforcesmemory_may_move == falsefor shared memories so growth never relocates the base pointer beyond the initial allocation capacity.Gate
ParkingSpotbehind#[cfg(feature = "std")]. Inno_stdbuilds,atomic_notify,atomic_wait32, andatomic_wait64still perform alignment and bounds checks;atomic_notifyreturnsOk(0)andatomic_wait32/64handle value mismatches (WaitResult::Mismatch) and zero-duration timeouts (WaitResult::TimedOut), panicking only if a guest attempts a blockingmemory.atomic.waitwithoutstd.Guard
AtomicU64usage oncfg(target_has_atomic = "64")and bail inSharedMemory::wrapwhen 64-bit atomics are unavailable so 32-bitno_stdtargets such asriscv32imac-unknown-none-elfcontinue to build cleanly with--features threads.Add a
shared_memory_uses_custom_creatortest, enablethreadsin theno_stdCI checks, and listthreadsin the#![no_std]platform support documentation.<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease review the Bytecode Alliance's AI tool usage policy at
https://github.com/bytecodealliance/governance/blob/main/AI_TOOL_POLICY.mdPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
posk-io removed the review request for wasmtime-core-reviewers from PR #15292.
posk-io requested dicej for a review on PR #15292.
posk-io requested wasmtime-core-reviewers for a review on PR #15292.
posk-io removed the review request for wasmtime-default-reviewers from PR #15292.
posk-io requested alexcrichton for a review on PR #15292.
posk-io requested wasmtime-default-reviewers for a review on PR #15292.
github-actions[bot] added the label wasmtime:api on PR #15292.
github-actions[bot] added the label wasmtime:docs on PR #15292.
:cross_mark: pchickey closed without merge PR #15292.
pchickey commented on PR #15292:
This PR doesn't appear to comply with our policy on tool-generated content, and requires additional justification for why it is valuable enough to the project for us to review it. Please see our developer policy on AI-generated contributions: https://github.com/bytecodealliance/governance/blob/main/AI_TOOL_POLICY.md
posk-io commented on PR #15292:
This PR doesn't appear to comply with our policy on tool-generated content, and requires additional justification for why it is valuable enough to the project for us to review it. Please see our developer policy on AI-generated contributions: https://github.com/bytecodealliance/governance/blob/main/AI_TOOL_POLICY.md
I created a new PR with additional justification. PTAL.
Last updated: Nov 19 2026 at 20:05 UTC