feat(rust): async-spawn - build under no_std + alloc#1600
Open
mattwilkinsonn wants to merge 3 commits intobytecodealliance:mainfrom
Open
feat(rust): async-spawn - build under no_std + alloc#1600mattwilkinsonn wants to merge 3 commits intobytecodealliance:mainfrom
async-spawn - build under no_std + alloc#1600mattwilkinsonn wants to merge 3 commits intobytecodealliance:mainfrom
Conversation
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.
Summary
Closes #1599.
Follow-up to #1591, which made the
asyncfeature work underno_std. That PR leftstdon theasync-spawnfeature, but nothing insrc/rt/async_support/spawn.rsactually requiresstd— it'sBox,Vec,Future,Context,Poll, andFuturesUnordered/StreamExtfrom thefuturescrate. All of these are available throughcore/alloconcefuturesopts out of its defaultstdfeature.This PR is the mechanical swap:
std::*→alloc::*/core::*, dropstdfrom the feature definition, and adddefault-features = false, features = ["alloc"]to thefuturesdep.Changes
Five edits across three files:
crates/guest-rust/Cargo.toml:async-spawn = ['async', 'dep:futures', 'std']→async-spawn = ['async', 'dep:futures']futures = { version = "0.3.30", optional = true }→futures = { version = "0.3.30", optional = true, default-features = false, features = ["alloc"] }crates/guest-rust/src/rt/async_support/spawn.rs:use std::{boxed, future, task, vec};swapped foruse alloc::{boxed, vec};+use core::{future, task};.github/workflows/main.yml:rustup target add wasm32v1-nonein thecheckjob setupcargo build --target wasm32v1-none -p wit-bindgen --no-default-features --features {async,async-spawn}lines so a regression that pullsstdback in fails CI instead of silently relinking againstwasm32-wasip1's std.wasm32v1-none(Tier 2, stable) is used for the guard because it has nostdat all, unlikewasm32-unknown-unknownwhich happily links std even when you opt out via features.Verification
Default-features build is unchanged. The
async-spawnfeature also builds withoutstd:The new CI guards are correct — on
main(before this PR) thewasm32v1-noneline fails to link becausefutures-executorpulls instd:With the patch applied, it compiles clean.
Downstream verification: my WIP project (not public yet) carries this exact patch on top of 0.55.0 and builds its agent as a fully
no_stdcomponent onwasm32-wasip3with-Zbuild-std=core,alloc.