Skip to content

Replace --async with --sync - #1730

Open
Lstarsky0 wants to merge 2 commits into
bytecodealliance:mainfrom
Lstarsky0:sync-option
Open

Lstarsky0 wants to merge 2 commits into
bytecodealliance:mainfrom
Lstarsky0:sync-option

Conversation

@Lstarsky0

Copy link
Copy Markdown
Contributor

As discussed in #1622: functions that are async in WIT get async bindings, everything else gets sync bindings, and --sync is the only override. It takes the same filters --async did (all, foo:bar/baz#f, import:…, export:…), without the - prefix. Since they only go one way now, their order no longer matters. generate! takes sync: true / sync: [...] in place of async:, and async: now fails with a message pointing at sync:.

For reference, async: true on main builds fine for a world with a sync import, and then wasmtime refuses the component with "the async canonical option requires an async function type".

The --async=all codegen variant for Rust, C and MoonBit is gone. Swapping it for --sync=all passes for Rust and C, but only 3 of the 109 codegen tests have async functions, so it would mostly repeat the default run. Happy to add it if you'd like.

Ran the Rust and C codegen and runtime tests locally, plus the crate tests, clippy and rustfmt. I couldn't run Go or MoonBit end to end here; their generators only see the renamed flag, and the MoonBit direction test is updated for it.

Closes #1622
Closes #1623

Since WebAssembly/component-model#646 a function that isn't `async` in
WIT can't be lifted or lowered async, so the only override that still
makes sense is turning an `async` function back to sync. `--sync` takes
the filters `--async` took, without the `-` prefix. The `generate!`
option is renamed the same way, and `async:` now errors and points at
`sync:`.

The `--async=all` codegen test variant for Rust, C and MoonBit is
removed: it generated async imports and exports for sync functions,
which can't be put in a component.

Closes bytecodealliance#1622
Closes bytecodealliance#1623

@alexcrichton alexcrichton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Apologies for the delay, but thanks for this! Overall this looks good to me, but I've got one comment below about test coverage where I think --sync=all should in theory be a testable variant now for generators that support that.

Comment thread crates/test/src/c.rs
&[
("no-sig-flattening", &["--no-sig-flattening"]),
("autodrop", &["--autodrop-borrows=yes"]),
("async", &["--async=all"]),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For testing, could this perhaps be inverted to --sync=all?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added --sync=all back for C and Rust in 3bc4cfe. Codegen passes for both, 1199 tests, the same count main had with the async variant. I left MoonBit out since it's commented out of the CI matrix and I can't run it here.

The `--async=all` variant was dropped with the flag; bring the matrix
back with its replacement so forcing every function sync stays covered.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecate the async opt? Stop allowing async override for non-async func types

2 participants