From cce17d1a71c40772c7114159f07518fc64160eaa Mon Sep 17 00:00:00 2001 From: Jeffrey Charles Date: Thu, 17 Oct 2024 10:04:21 -0400 Subject: [PATCH 1/3] Rename wizer.initialize to initialize_runtime (#780) --- crates/cli/build.rs | 1 + crates/cli/src/codegen/static.rs | 1 + crates/core/src/lib.rs | 4 ++-- crates/core/src/main.rs | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/cli/build.rs b/crates/cli/build.rs index bb93aaef..4ebe2a2c 100644 --- a/crates/cli/build.rs +++ b/crates/cli/build.rs @@ -55,6 +55,7 @@ fn copy_javy_core() -> Result<()> { let mut wizer = wizer::Wizer::new(); let wizened = wizer + .init_func("initialize_runtime") .allow_wasi(true)? .wasm_bulk_memory(true) .run(read_file(&quickjs_provider_path)?.as_slice())?; diff --git a/crates/cli/src/codegen/static.rs b/crates/cli/src/codegen/static.rs index b0bcdb35..780da24d 100644 --- a/crates/cli/src/codegen/static.rs +++ b/crates/cli/src/codegen/static.rs @@ -81,6 +81,7 @@ impl CodeGen for StaticGenerator { }; let wasm = Wizer::new() + .init_func("initialize_runtime") .make_linker(Some(Rc::new(|engine| { let mut linker = Linker::new(engine); wasi_common::sync::add_to_linker(&mut linker, |_: &mut Option| unsafe { diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs index 38a98779..4548a471 100644 --- a/crates/core/src/lib.rs +++ b/crates/core/src/lib.rs @@ -15,8 +15,8 @@ static mut COMPILE_SRC_RET_AREA: [u32; 2] = [0; 2]; static mut RUNTIME: OnceCell = OnceCell::new(); /// Used by Wizer to preinitialize the module. -#[export_name = "wizer.initialize"] -pub extern "C" fn init() { +#[export_name = "initialize_runtime"] +pub extern "C" fn initialize_runtime() { let runtime = runtime::new(Config::default()).unwrap(); unsafe { RUNTIME diff --git a/crates/core/src/main.rs b/crates/core/src/main.rs index dfebcbc7..e23ba255 100644 --- a/crates/core/src/main.rs +++ b/crates/core/src/main.rs @@ -15,8 +15,8 @@ const FUNCTION_MODULE_NAME: &str = "function.mjs"; static mut RUNTIME: OnceCell = OnceCell::new(); static mut BYTECODE: OnceCell> = OnceCell::new(); -#[export_name = "wizer.initialize"] -pub extern "C" fn init() { +#[export_name = "initialize_runtime"] +pub extern "C" fn initialize_runtime() { let _wasm_ctx = WasmCtx::new(); let js_runtime_config = Config::from_bits( From 89afb6c7b9a94c3fdbd0ddc62f47f2cc4ddb8da3 Mon Sep 17 00:00:00 2001 From: Jeffrey Charles Date: Thu, 17 Oct 2024 11:59:25 -0400 Subject: [PATCH 2/3] Fix missing argument for wizer build assets workflow (#783) --- .github/workflows/build-assets.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-assets.yml b/.github/workflows/build-assets.yml index c5c6b6ee..a9004836 100644 --- a/.github/workflows/build-assets.yml +++ b/.github/workflows/build-assets.yml @@ -50,7 +50,7 @@ jobs: - name: Wizen and archive wizened quickjs_provider run: | - wizer target/wasm32-wasi/release/javy_quickjs_provider.wasm --allow-wasi --wasm-bulk-memory true -o target/wasm32-wasi/release/javy_quickjs_provider_wizened.wasm + wizer target/wasm32-wasi/release/javy_quickjs_provider.wasm --allow-wasi --init-func initialize_runtime --wasm-bulk-memory true -o target/wasm32-wasi/release/javy_quickjs_provider_wizened.wasm gzip -k -f target/wasm32-wasi/release/javy_quickjs_provider_wizened.wasm && mv target/wasm32-wasi/release/javy_quickjs_provider_wizened.wasm.gz javy-quickjs_provider.wasm.gz - name: Upload archived quickjs_provider to artifacts From 5a1f1c0e864cdb87345aebc4cbe06d2bab56b88e Mon Sep 17 00:00:00 2001 From: Jeffrey Charles Date: Thu, 17 Oct 2024 17:27:58 -0400 Subject: [PATCH 3/3] Disable reference-types since Wizer doesn't support them (#785) --- .cargo/config.toml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 949ef543..8317a149 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -2,8 +2,15 @@ # Cargo doesn't read directives in individual crates when invoking build # commands from the workspace root, hence adding it at the workspace root. # https://doc.rust-lang.org/cargo/reference/config.html +# Disable reference-types since Wizer (as of version 7.0.0) does not support +# reference-types. [target.wasm32-wasi] -rustflags = ["-C", "target-feature=+simd128"] +rustflags = [ + "-C", + "target-feature=+simd128", + "-C", + "target-feature=-reference-types", +] # We want to ensure that all the MSVC dependencies are statically resolved and # included in the final CLI binary.