Browse Source

Rename `-S common` to `-S cli`. (#8166)

* Rename `-S common` to `-S cli`.

The "common" in `-S common` came from "wasi-common" which came from the
idea of having code in common between Wasmtime, Lucet, and others. It
doesn't have a clear meaning for end users, and has a risk of being
interpreted as "common" functionality that's generally available
everywhere.

This PR renames `-S common` to `-S cli`, and documents it as including
the WASI CLI APIs, to clarify its purpose `-S common` is still accepted,
with a warning.

* Fix formatting in RELEASES.md.

* Disable the warning about `-S common` for now.
pull/8193/head
Dan Gohman 8 months ago
committed by GitHub
parent
commit
bcd0119ec0
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 4
      RELEASES.md
  2. 6
      crates/cli-flags/src/lib.rs
  3. 17
      src/commands/run.rs
  4. 26
      src/commands/serve.rs
  5. 2
      src/old_cli.rs
  6. 2
      tests/all/cli_tests.rs

4
RELEASES.md

@ -8,6 +8,10 @@ Unreleased.
### Changed ### Changed
* The `-S common` flag is renamed to `-S cli`, to better reflect that it provides
the wasi-cli APIs. `-S common` is still accepted for now, and will be deprecated
in the future.
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
## 19.0.0 ## 19.0.0

6
crates/cli-flags/src/lib.rs

@ -252,7 +252,9 @@ wasmtime_option_group! {
wasmtime_option_group! { wasmtime_option_group! {
#[derive(PartialEq, Clone)] #[derive(PartialEq, Clone)]
pub struct WasiOptions { pub struct WasiOptions {
/// Enable support for WASI common APIs /// Enable support for WASI CLI APIs, including filesystems, sockets, clocks, and random.
pub cli: Option<bool>,
/// Deprecated alias for `cli`
pub common: Option<bool>, pub common: Option<bool>,
/// Enable suport for WASI neural network API (experimental) /// Enable suport for WASI neural network API (experimental)
pub nn: Option<bool>, pub nn: Option<bool>,
@ -265,7 +267,7 @@ wasmtime_option_group! {
pub listenfd: Option<bool>, pub listenfd: Option<bool>,
/// Grant access to the given TCP listen socket /// Grant access to the given TCP listen socket
pub tcplisten: Vec<String>, pub tcplisten: Vec<String>,
/// Implement WASI with preview2 primitives (experimental). /// Implement WASI CLI APIs with preview2 primitives (experimental).
/// ///
/// Indicates that the implementation of WASI preview1 should be backed by /// Indicates that the implementation of WASI preview1 should be backed by
/// the preview2 implementation for components. /// the preview2 implementation for components.

17
src/commands/run.rs

@ -607,7 +607,22 @@ impl RunCommand {
store: &mut Store<Host>, store: &mut Store<Host>,
module: &RunTarget, module: &RunTarget,
) -> Result<()> { ) -> Result<()> {
if self.run.common.wasi.common != Some(false) { let mut cli = self.run.common.wasi.cli;
// Accept -Scommon as a deprecated alias for -Scli.
if let Some(common) = self.run.common.wasi.common {
if cli.is_some() {
bail!(
"The -Scommon option should not be use with -Scli as it is a deprecated alias"
);
} else {
// In the future, we may add a warning here to tell users to use
// `-S cli` instead of `-S common`.
cli = Some(common);
}
}
if cli != Some(false) {
match linker { match linker {
CliLinker::Core(linker) => { CliLinker::Core(linker) => {
match (self.run.common.wasi.preview2, self.run.common.wasi.threads) { match (self.run.common.wasi.preview2, self.run.common.wasi.threads) {

26
src/commands/serve.rs

@ -191,16 +191,30 @@ impl ServeCommand {
} }
fn add_to_linker(&self, linker: &mut Linker<Host>) -> Result<()> { fn add_to_linker(&self, linker: &mut Linker<Host>) -> Result<()> {
// Repurpose the `-Scommon` flag of `wasmtime run` for `wasmtime serve` let mut cli = self.run.common.wasi.cli;
// Accept -Scommon as a deprecated alias for -Scli.
if let Some(common) = self.run.common.wasi.common {
if cli.is_some() {
bail!(
"The -Scommon option should not be use with -Scli as it is a deprecated alias"
);
} else {
// In the future, we may add a warning here to tell users to use
// `-S cli` instead of `-S common`.
cli = Some(common);
}
}
// Repurpose the `-Scli` flag of `wasmtime run` for `wasmtime serve`
// to serve as a signal to enable all WASI interfaces instead of just // to serve as a signal to enable all WASI interfaces instead of just
// those in the `proxy` world. If `-Scommon` is present then add all // those in the `proxy` world. If `-Scli` is present then add all
// `command` APIs which includes all "common" or base WASI APIs and then // `command` APIs and then additionally add in the required HTTP APIs.
// additionally add in the required HTTP APIs.
// //
// If `-Scommon` isn't passed then use the `proxy::add_to_linker` // If `-Scli` isn't passed then use the `proxy::add_to_linker`
// bindings which adds just those interfaces that the proxy interface // bindings which adds just those interfaces that the proxy interface
// uses. // uses.
if self.run.common.wasi.common == Some(true) { if cli == Some(true) {
wasmtime_wasi::command::add_to_linker(linker)?; wasmtime_wasi::command::add_to_linker(linker)?;
wasmtime_wasi_http::proxy::add_only_http_to_linker(linker)?; wasmtime_wasi_http::proxy::add_only_http_to_linker(linker)?;
} else { } else {

2
src/old_cli.rs

@ -981,7 +981,7 @@ impl CommonOptions {
ret.wasi.http = wasi_http; ret.wasi.http = wasi_http;
ret.wasi.nn = wasi_nn; ret.wasi.nn = wasi_nn;
ret.wasi.threads = wasi_threads; ret.wasi.threads = wasi_threads;
ret.wasi.common = wasi_common; ret.wasi.cli = wasi_common;
} }
ret ret
} }

2
tests/all/cli_tests.rs

@ -1499,7 +1499,7 @@ mod test_programs {
&[ &[
"-Ccache=no", "-Ccache=no",
"-Wcomponent-model", "-Wcomponent-model",
"-Scommon,http,preview2", "-Scli,http,preview2",
HTTP_OUTBOUND_REQUEST_RESPONSE_BUILD_COMPONENT, HTTP_OUTBOUND_REQUEST_RESPONSE_BUILD_COMPONENT,
], ],
None, None,

Loading…
Cancel
Save