Skip to content

Commit

Permalink
Merge branch 'main' into jc.reuse-runtime-when-compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffcharles committed Oct 17, 2024
2 parents 4df150b + 5a1f1c0 commit c2f022a
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
9 changes: 8 additions & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions crates/cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())?;
Expand Down
1 change: 1 addition & 0 deletions crates/cli/src/codegen/static.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<WasiCtx>| unsafe {
Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ static mut COMPILE_SRC_RET_AREA: [u32; 2] = [0; 2];
static mut RUNTIME: OnceCell<Runtime> = 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
Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const FUNCTION_MODULE_NAME: &str = "function.mjs";
static mut RUNTIME: OnceCell<Runtime> = OnceCell::new();
static mut BYTECODE: OnceCell<Vec<u8>> = 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(
Expand Down

0 comments on commit c2f022a

Please sign in to comment.