Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for using webc v3 #4651

Merged
merged 10 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions lib/cli/src/commands/run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::{
};

use anyhow::{bail, Context, Error};
use clap::Parser;
use clap::{Parser, ValueEnum};
use indicatif::{MultiProgress, ProgressBar};
use once_cell::sync::Lazy;
use sha2::{Digest, Sha256};
Expand Down Expand Up @@ -107,11 +107,20 @@ impl Run {
wasmer_vm::set_stack_size(self.stack_size.unwrap());
}

// check for the preferred webc version
let preferred_webc_version = match std::env::var("WASMER_USE_WEBCV3") {
Ok(val) if ["1", "yes", "true"].contains(&val.as_str()) => webc::Version::V3,
_ => webc::Version::V2,
};

let _guard = handle.enter();
let (store, _) = self.store.get_store()?;
let runtime = self
.wasi
.prepare_runtime(store.engine().clone(), &self.env, runtime)?;
let runtime = self.wasi.prepare_runtime(
store.engine().clone(),
&self.env,
runtime,
preferred_webc_version,
)?;

// This is a slow operation, so let's temporarily wrap the runtime with
// something that displays progress
Expand Down
7 changes: 5 additions & 2 deletions lib/cli/src/commands/run/wasi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ impl Wasi {
engine: Engine,
env: &WasmerEnv,
rt_or_handle: I,
preferred_webc_version: webc::Version,
) -> Result<impl Runtime + Send + Sync>
where
I: Into<RuntimeOrHandle>,
Expand Down Expand Up @@ -565,7 +566,7 @@ impl Wasi {
.prepare_package_loader(env, client.clone())
.context("Unable to prepare the package loader")?;

let registry = self.prepare_source(env, client)?;
let registry = self.prepare_source(env, client, preferred_webc_version)?;

let cache_dir = env.cache_dir().join("compiled");
let module_cache = wasmer_wasix::runtime::module_cache::in_memory()
Expand Down Expand Up @@ -627,6 +628,7 @@ impl Wasi {
&self,
env: &WasmerEnv,
client: Arc<dyn HttpClient + Send + Sync>,
preferred_webc_version: webc::Version,
) -> Result<impl Source + Send + Sync> {
let mut source = MultiSource::new();

Expand All @@ -643,7 +645,8 @@ impl Wasi {
let graphql_endpoint = self.graphql_endpoint(env)?;
let cache_dir = env.cache_dir().join("queries");
let mut wapm_source = WapmSource::new(graphql_endpoint, Arc::clone(&client))
.with_local_cache(cache_dir, WAPM_SOURCE_CACHE_TIMEOUT);
.with_local_cache(cache_dir, WAPM_SOURCE_CACHE_TIMEOUT)
.with_preferred_webc_version(preferred_webc_version);
if let Some(token) = env
.config()?
.registry
Expand Down
Loading
Loading