Cranelift and Rust code in Spidermonkey

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Cranelift and Rust code in Spidermonkey

Benjamin Bouvier-2
- a Rust toolchain is needed to build Spidermonkey (i.e. from version 63);
- experimental support for Cranelift (new wasm code generator) has landed
in Spidermonkey;
- anyone can easily add Rust code in Spidermonkey now.

Support for Cranelift, a new code generator written in Rust, has landed
today on mozilla-inbound. It means that experimental support for
WebAssembly compilation using the Cranelift backend can now be enabled
using the javascript.options.wasm_cranelift about:config pref (or
--wasm-force-cranelift in the JS shell). It is enabled by default on
Nightly *only*, and can be configured with --enable-cranelift /

More notably, since the code itself is written in Rust, building the shell
now requires Rust / Cargo et al. to build Spidermonkey. Running the
toplevel `./mach bootstrap` in a Gecko tree should get you all the required
dependencies. The tarball package contains all the necessary Rust
dependencies pinned to a specific version, to make sure they're correct and
match our expectations.

Moreover, if you wish to add new Rust code to Spidermonkey, you have to:
- create a new *lib* crate (with crate-type="rlib") and include it in the
top-level Cargo.toml workspace
- add it as a dependency of jsrust_shared in js/src/rust/shared/Cargo.toml
- reference it as an extern crate in js/src/rust/shared/
- make sure the jsrust/ directory gets conditionally included in
- run `./mach vendor rust` to vendor in the Rust dependencies
- add your bindgen bindings (this is a bit hard at the moment to provide
all the right flags for every compiler/architecture, but could be improved
in the future)
- (safe) fun and profit!

Thanks to the build peers who provided a lot of help during the last few
weeks and gave insightful reviews.

dev-tech-js-engine mailing list
[hidden email]