bytecodealliance / ComponentizeJS

JS -> WebAssembly Component
Apache License 2.0
242 stars 32 forks source link

Question: Using custom build of starlingmonkey #110

Open karthik2804 opened 6 months ago

karthik2804 commented 6 months ago

I am attempting to use the engine produced by a debug build of the PR that refactors fetch.

My understanding is that it should be sufficient to pass the engine argument to the componentize function as below:

const { component, imports } = await componentize(source, {
    sourceName: basename(src),
    witPath: resolve(args.witPath),
    worldName: args.triggerType,
    engine: "./starlingmonkey/cmake-build-debug/starling.wasm",
    disable features: [],
});

I run into the following error.

thread '<unnamed>' panicked at crates/spidermonkey-embedding-splicer/src/splice.rs:119:80:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
wasm://wasm/01874b72:1

RuntimeError: unreachable
    at __rust_start_panic (wasm://wasm/01874b72:wasm-function[6443]:0x372beb)
    at rust_panic (wasm://wasm/01874b72:wasm-function[6431]:0x37262c)
    at _ZN3std9panicking20rust_panic_with_hook17hc97f08b908247b1dE (wasm://wasm/01874b72:wasm-function[6430]:0x37255f)
    at _ZN3std9panicking19begin_panic_handler28_$u7b$$u7b$closure$u7d$$u7d$17hdd638bdaba0c6bccE (wasm://wasm/01874b72:wasm-function[6418]:0x3718f7)
    at _ZN3std10sys_common9backtrace26__rust_end_short_backtrace17h5b392607309abb6aE (wasm://wasm/01874b72:wasm-function[6417]:0x37185d)
    at rust_begin_unwind (wasm://wasm/01874b72:wasm-function[6425]:0x371f36)
    at _ZN4core9panicking9panic_fmt17h9fec598e5939a913E (wasm://wasm/01874b72:wasm-function[6588]:0x38040f)
    at _ZN4core9panicking5panic17h711f5cad5118a4ddE (wasm://wasm/01874b72:wasm-function[6599]:0x381c2f)
    at _ZN30spidermonkey_embedding_splicer6splice27synthesize_import_functions17hd2a9a03ce4744861E (wasm://wasm/01874b72:wasm-function[106]:0x2a36b)
    at _ZN30spidermonkey_embedding_splicer6splice6splice17h5faa7a23aef7cffbE (wasm://wasm/01874b72:wasm-function[105]:0x25dbf)

Is there some trick to getting this to work? or is the current state of the PR incompatible? Thanks!

guybedford commented 6 months ago

The engine to be built is lib/starlingmonkey_embedding.debug.wasm (the release build won't work pending https://github.com/bytecodealliance/StarlingMonkey/issues/50).

To get this file, run make lib/starlingmonkey_embedding.debug.wasm.

The StarlingMonkey build is referenced as a submodule of this repo.

guybedford commented 6 months ago

Hmm actually the debug build of ComponentizeJS isn't working itself, so you do have to use a release build.

Therefore until https://github.com/bytecodealliance/StarlingMonkey/pull/53 is landed you won't be able to progress here.

karthik2804 commented 6 months ago

The debug build was not working and the workaround I used was to modify the makefile to build a debug build instead of RelWithDebInfo https://github.com/bytecodealliance/ComponentizeJS/blob/519256f5632f48e42cfea54bfd588f383eccb855/Makefile#L29

and then modifying the JS script to point at the right reference. https://github.com/bytecodealliance/ComponentizeJS/blob/519256f5632f48e42cfea54bfd588f383eccb855/src/componentize.js#L41

which led me into running into the following error

Splicer error: unable to read prelude sequence, continuing for debug build but note binding functions will not work
guybedford commented 6 months ago

Yes, the debug build does not work for ComponentizeJS.

karthik2804 commented 6 months ago

Thanks! This is helpful.

guybedford commented 6 months ago

Latest release build fix for StarlingMonkey is in https://github.com/bytecodealliance/StarlingMonkey/pull/53.

guybedford commented 6 months ago

I've updated the internal build in https://github.com/bytecodealliance/ComponentizeJS/pull/111 as an example.