From 352f50127e73ef1c1b31cae445b33411ef2759a5 Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Mon, 11 Nov 2024 19:34:45 +0100 Subject: [PATCH] Add default feature for JIT When building servo on Linux with the profile `production-stripped`, disabling JIT with this change shaves off 9MiB from the servo binary size, which is around 10%. Signed-off-by: Jonathan Schwender --- mozjs-sys/Cargo.toml | 3 ++- mozjs-sys/build.rs | 3 +++ mozjs-sys/makefile.cargo | 6 +++++- mozjs/Cargo.toml | 5 +++-- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/mozjs-sys/Cargo.toml b/mozjs-sys/Cargo.toml index e2daa7a6ccf..204e311e703 100644 --- a/mozjs-sys/Cargo.toml +++ b/mozjs-sys/Cargo.toml @@ -2,7 +2,7 @@ name = "mozjs_sys" description = "System crate for the Mozilla SpiderMonkey JavaScript engine." repository.workspace = true -version = "0.140.5-2" +version = "0.140.5-3" authors = ["Mozilla", "The Servo Project Developers"] links = "mozjs" license.workspace = true @@ -18,6 +18,7 @@ doctest = false [features] debugmozjs = [] profilemozjs = [] +jit = [] jitspew = [] libz-sys = ["dep:libz-sys"] libz-rs = ["dep:libz-rs-sys"] diff --git a/mozjs-sys/build.rs b/mozjs-sys/build.rs index 8273378ff8d..c664b67dee2 100644 --- a/mozjs-sys/build.rs +++ b/mozjs-sys/build.rs @@ -463,6 +463,9 @@ fn should_build_from_source() -> bool { } else if env::var_os("CARGO_FEATURE_INTL").is_none() { println!("intl feature is disabled. Building from source directly."); true + } else if !env::var_os("CARGO_FEATURE_JIT").is_some() { + println!("jit feature is NOT enabled. Building from source directly."); + true } else { false } diff --git a/mozjs-sys/makefile.cargo b/mozjs-sys/makefile.cargo index 303df1f2c63..4dd2c7ad621 100644 --- a/mozjs-sys/makefile.cargo +++ b/mozjs-sys/makefile.cargo @@ -11,6 +11,10 @@ CONFIGURE_FLAGS := \ --disable-shared-js \ --build-backends=RecursiveMake +ifeq (,$(CARGO_FEATURE_JIT)) + CONFIGURE_FLAGS += --disable-jit +endif + ifneq (,$(CARGO_FEATURE_JITSPEW)) CONFIGURE_FLAGS += --enable-jitspew endif @@ -77,7 +81,7 @@ ifneq ($(HOST),$(TARGET)) endif ifeq (aarch64-unknown-linux-gnu,$(TARGET)) - # Reset TARGET variable because aarch64 target name used by Rust is not + # Reset TARGET variable because aarch64 target name used by Rust is not # the same as the target name needed for the CXX toolchain. TARGET = aarch64-linux-gnu endif diff --git a/mozjs/Cargo.toml b/mozjs/Cargo.toml index a94f0c15fd0..3933afe2dea 100644 --- a/mozjs/Cargo.toml +++ b/mozjs/Cargo.toml @@ -2,7 +2,7 @@ name = "mozjs" description = "Rust bindings to the Mozilla SpiderMonkey JavaScript engine." repository.workspace = true -version = "0.14.1" +version = "0.14.2" authors = ["The Servo Project Developers"] license.workspace = true edition.workspace = true @@ -11,9 +11,10 @@ edition.workspace = true doctest = false [features] -default = ["libz-sys", "intl"] +default = ["jit", "libz-sys", "intl"] debugmozjs = ["mozjs_sys/debugmozjs"] profilemozjs = ["mozjs_sys/profilemozjs"] +jit = ['mozjs_sys/jit'] jitspew = ["mozjs_sys/jitspew"] libz-sys = ["mozjs_sys/libz-sys"] libz-rs = ["mozjs_sys/libz-rs"]