From 86b5a64d0dbf9ee441dad1708cbaf472412247c3 Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Mon, 11 Nov 2024 19:34:45 +0100 Subject: [PATCH 1/2] 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 | 4 +++- mozjs-sys/build.rs | 3 +++ mozjs-sys/makefile.cargo | 6 +++++- mozjs/Cargo.toml | 3 ++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/mozjs-sys/Cargo.toml b/mozjs-sys/Cargo.toml index cdec66750e..b4dffed2e8 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.128.13-0" +version = "0.128.13-1" authors = ["Mozilla"] links = "mozjs" license.workspace = true @@ -22,8 +22,10 @@ name = "mozjs_sys" doctest = false [features] +default = ["jit"] debugmozjs = [] profilemozjs = [] +jit = [] jitspew = [] crown = [] oom_with_hook = [] diff --git a/mozjs-sys/build.rs b/mozjs-sys/build.rs index 44d48be627..4496465c4c 100644 --- a/mozjs-sys/build.rs +++ b/mozjs-sys/build.rs @@ -405,6 +405,9 @@ fn should_build_from_source() -> bool { } else if env::var_os("CARGO_FEATURE_DEBUGMOZJS").is_some() { println!("debug-mozjs feature is enabled. 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 f96ff430f7..44d8de2af8 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 @@ -63,7 +67,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 51b0667b47..7eb1b2b4cd 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 @@ -12,6 +12,7 @@ doctest = false [features] debugmozjs = ['mozjs_sys/debugmozjs'] +jit = ['mozjs_sys/jit'] jitspew = ['mozjs_sys/jitspew'] profilemozjs = ['mozjs_sys/profilemozjs'] crown = ['mozjs_sys/crown'] From 718f43c9e9aef85665f5d02f95b1a89dcfdacbad Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Thu, 10 Jul 2025 12:32:06 +0800 Subject: [PATCH 2/2] Move default jit feature to mozjs Signed-off-by: Jonathan Schwender --- mozjs-sys/Cargo.toml | 1 - mozjs/Cargo.toml | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/mozjs-sys/Cargo.toml b/mozjs-sys/Cargo.toml index b4dffed2e8..35d9831639 100644 --- a/mozjs-sys/Cargo.toml +++ b/mozjs-sys/Cargo.toml @@ -22,7 +22,6 @@ name = "mozjs_sys" doctest = false [features] -default = ["jit"] debugmozjs = [] profilemozjs = [] jit = [] diff --git a/mozjs/Cargo.toml b/mozjs/Cargo.toml index 7eb1b2b4cd..df0f67f4ff 100644 --- a/mozjs/Cargo.toml +++ b/mozjs/Cargo.toml @@ -12,6 +12,7 @@ doctest = false [features] debugmozjs = ['mozjs_sys/debugmozjs'] +default = ["jit"] jit = ['mozjs_sys/jit'] jitspew = ['mozjs_sys/jitspew'] profilemozjs = ['mozjs_sys/profilemozjs']