Skip to content

Upgrade to SpiderMonkey 137 #584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
d795685
Update SpiderMonkey
jdm May 21, 2025
c2e1acc
Update COMMIT.
jdm May 21, 2025
98d52d9
Update patches.
jdm May 21, 2025
076fa9e
Apply patches.
jdm May 21, 2025
8c1ba1b
Update handwritten glue.
jdm May 21, 2025
8f6a375
Support generate_wrappers.sh work on macOS.
jdm May 21, 2025
3b6a2fa
Update jsapi wrappers.
jdm May 21, 2025
56410df
Build fixes.
jdm May 21, 2025
5ac3213
Formatting.
jdm May 21, 2025
c4c59e6
Set pending exception in panic unit test to avoid assertion.
jdm May 22, 2025
53147fa
Expose glue for using EnvironmentChain instances.
jdm May 22, 2025
a5d7405
Downgrade NDK requirement.
jdm May 29, 2025
4f754e6
Run clang-format on C++ code.
jdm May 29, 2025
bffb380
Set LIBCLANG_PATH in CI.
jdm May 29, 2025
f0e6a76
Upgrade macOS SDK minimum version.
jdm May 29, 2025
1fa2501
Update mozilla-esr references and package version.
jdm May 29, 2025
1c905be
Format rust code.
jdm May 29, 2025
aecd9ba
Update macOS CI hosts.
jdm May 29, 2025
d614cdc
fixup! Downgrade NDK requirement.
jdm May 29, 2025
ac5d36d
Use latest stable Xcode on macOS CI.
jdm May 29, 2025
9161087
Add more packed attributes.
jdm May 29, 2025
5e8de5b
Attempt to use a newer libclang.
jdm May 29, 2025
588cc9b
Work around Android build failure by removing failing static assert.
jdm May 29, 2025
dc74b4a
Windows build debug output.
jdm May 29, 2025
de37b0a
Upgrade NDK.
jdm May 29, 2025
26f9961
More windows debugging.
jdm May 29, 2025
bac97b3
More windows debugging.
jdm May 29, 2025
e9e945c
Update supported NDK.
jdm May 29, 2025
79a059d
Upgrade NDK.
jdm May 29, 2025
92ee540
Force library list on windows.
jdm May 29, 2025
3eca21f
Try another clang path.
jdm May 29, 2025
7f6fea9
Attempt different clang installation.
jdm May 29, 2025
ee15f94
More windows debugging.
jdm May 29, 2025
ab1efa7
Use clang 15.
jdm May 29, 2025
275fb22
More windows debugging.
jdm May 30, 2025
4399855
debugmozjs debugging.
jdm May 30, 2025
9f6c152
Fix.
jdm May 30, 2025
756f1bc
Fix use of temporary file when testing ar support.
jdm May 30, 2025
c7aef80
Remove hacks.
jdm May 30, 2025
80ecbcf
Reorder output.
jdm May 30, 2025
c62fe31
Upgrade clang.
jdm May 30, 2025
d35fa2d
Explicitly define __ANDROID_API__ when the api level is provided.
jdm Jun 10, 2025
2154194
Comment out problematic assert.
jdm Jun 10, 2025
ec7a8ab
Make android build succeed.
jdm Jun 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
21 changes: 15 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ jobs:
matrix:
features: ["debugmozjs", '""']
platform:
- { target: aarch64-apple-darwin, os: macos-14 }
- { target: x86_64-apple-darwin, os: macos-13 }
Comment on lines -24 to -25
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to do this in servo's CI too.

- { target: aarch64-apple-darwin, os: macos-15 }
- { target: x86_64-apple-darwin, os: macos-15 }
runs-on: ${{ matrix.platform.os }}
env:
RUSTC_WRAPPER: sccache
CCACHE: sccache
SCCACHE_GHA_ENABLED: "true"
steps:
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- uses: actions/checkout@v4
- name: Install deps
run: |
Expand Down Expand Up @@ -69,11 +72,17 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Install deps
run: |
sudo apt install llvm -y
#- name: Install deps
# run: |
# sudo apt install llvm -y
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v2
with:
version: "16.0"
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.8
#- name: Set LIBCLANG_PATH env
# run: echo "LIBCLANG_PATH=/usr/lib/llvm-16/lib" >> $GITHUB_ENV
- name: Build
run: |
cargo build --verbose --features ${{ matrix.features }}
Expand Down Expand Up @@ -164,7 +173,7 @@ jobs:
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r26c
ndk-version: r28b
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ that are battle-tested in [Servo](https://servo.org/), split in two crates:
- `mozjs-sys`: SpiderMonkey and low-level Rust bindings to its C++ API.
- `mozjs`: Higher-level bindings to the SpiderMonkey API.

Mozjs is currently tracking SpiderMonkey on [ESR-128](https://searchfox.org/mozilla-esr128/source/) branch
(currently version 128.0).
Mozjs is currently tracking SpiderMonkey on [mozilla-release](https://searchfox.org/mozilla-release/source/) branch
(currently version 137.0).

## Building from Pre-built Archive

Expand Down Expand Up @@ -141,8 +141,8 @@ mozjs = { path = "../mozjs/mozjs" }

In order to upgrade to a new version of SpiderMonkey:

1. Find the mozilla-esr128 commit for the desired version of SpiderMonkey, at
<https://treeherder.mozilla.org/#/jobs?repo=mozilla-esr128&filter-searchStr=spidermonkey%20pkg>.
1. Find the mozilla-release commit for the desired version of SpiderMonkey, at
<https://treeherder.mozilla.org/#/jobs?repo=mozilla-release&filter-searchStr=spidermonkey%20pkg>.
You are looking for an SM(pkg) tagged with FIREFOX_RELEASE.
Take a note of the commit number to the left (a hex number such as ac4fbb7aaca0).

Expand Down
5 changes: 4 additions & 1 deletion android-build
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import sys
from typing import Dict, Optional


SUPPORTED_NDK_VERSION = '26'
SUPPORTED_NDK_VERSION = '28'
API_LEVEL = '30'


Expand Down Expand Up @@ -65,6 +65,9 @@ def set_toolchain_binaries_in_env(toolchain_dir: str, env: Dict[str, str]):
env["RANLIB"] = ranlib
env["STRIP"] = strip
env["YASM"] = yasm
env["CLANG_PATH"] = cc
env["LIBCLANG_PATH"] = os.path.join(toolchain_dir, "lib")
env["BINDGEN_EXTRA_CLANG_ARGS"] = f"--target=armv7a-linux-androideabi30 --sysroot={os.path.join(toolchain_dir, 'sysroot')}"


def create_environment_for_build() -> Dict[str, str]:
Expand Down
2 changes: 1 addition & 1 deletion mozjs-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "mozjs_sys"
description = "System crate for the Mozilla SpiderMonkey JavaScript engine."
repository.workspace = true
version = "0.128.9-3"
version = "0.137.0-0"
authors = ["Mozilla"]
links = "mozjs"
license.workspace = true
Expand Down
30 changes: 28 additions & 2 deletions mozjs-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,24 @@ fn build_spidermonkey(build_dir: &Path) {
.current_dir(&build_dir)
.env("SRC_DIR", &cargo_manifest_dir.join("mozjs"))
.env("NO_RUST_PANIC_HOOK", "1")
.status()
.output()
.expect(&format!("Failed to run `{:?}`", make));
assert!(result.success());
if !result.status.success() {
println!(
"stderr output:\n{}",
String::from_utf8(result.stderr).unwrap()
);
let stdout = String::from_utf8(result.stdout).unwrap();
println!("build output:\n{}", stdout,);
}
assert!(result.status.success());

if target.contains("windows") {
/*println!("build output:\n{}", stdout,);
println!(
"configure status:\n{}",
std::fs::read_to_string(build_dir.join("config.status")).unwrap()
);*/
let mut make_static = cc::Build::new();
make_static.out_dir(join_path(build_dir, "js/src/build"));
fs::read_to_string(join_path(build_dir, "js/src/build/js_static_lib.list"))
Expand Down Expand Up @@ -249,6 +262,10 @@ fn build(build_dir: &Path, target: BuildTarget) {
build.flag_if_supported(flag);
}

if let Ok(android_api) = env::var("ANDROID_API_LEVEL").as_deref() {
build.define("__ANDROID_MIN_SDK_VERSION__", android_api);
}

build.flag(include_file_flag(build.get_compiler().is_like_msvc()));
build.flag(&js_config_path(build_dir));

Expand Down Expand Up @@ -719,6 +736,11 @@ impl BuildTarget {
"JS::dbg::Builder_Object",
"JS::dbg::Builder_Object_Base",
"JS::dbg::BuilderOrigin",
"JS::RootedTuple",
"mozilla::external::AtomicRefCounted",
"mozilla::ProfilerStringView",
"mozilla::ProfilerString8View",
"mozilla::ProfilerString16View",
],
BuildTarget::JSGlue => &[
"JS::.*",
Expand Down Expand Up @@ -785,6 +807,7 @@ impl BuildTarget {
fn opaque_types(self) -> &'static [&'static str] {
match self {
BuildTarget::JSApi => &[
"JS::EnvironmentChain",
"JS::StackGCVector.*",
"JS::PersistentRooted.*",
"JS::detail::CallArgsBase",
Expand All @@ -797,6 +820,9 @@ impl BuildTarget {
"mozilla::detail::Hash.*",
"RefPtr_Proxy.*",
"std::.*",
"mozilla::baseprofiler::BaseProfilerProcessId",
"mozilla::baseprofiler::BaseProfilerThreadId",
"mozilla::MarkerThreadId",
],
BuildTarget::JSGlue => &[
"JS::Auto.*Impl",
Expand Down
2 changes: 1 addition & 1 deletion mozjs-sys/etc/COMMIT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f4b6f95e39503cb356c42e71fffa0a21e949fbd8
7a8941c8c2cbdd3a4d352d8b732f7b5eeefbfd2d
2 changes: 1 addition & 1 deletion mozjs-sys/etc/get_latest_mozjs.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

REPO=mozilla-esr128
REPO=mozilla-release

# get commit and appropriet mozjs tar
jobs=( $(curl "https://treeherder.mozilla.org/api/project/$REPO/push/?full=true&count=20" | jq '.results[].id') )
Expand Down
2 changes: 1 addition & 1 deletion mozjs-sys/etc/get_mozjs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -o errexit
set -o nounset
set -o pipefail

REPO=mozilla-esr128
REPO=mozilla-release

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
# get commit and appropriet mozjs tar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ index 333a5ea499..8be5bc9052 100644
--- a/build/moz.configure/android-ndk.configure
+++ b/build/moz.configure/android-ndk.configure
@@ -22,6 +22,10 @@ option(
help="location where the Android NDK can be found{|}",
help="Location where the Android NDK can be found{|}",
)

+option("--with-android-ndk-version", nargs=1, help="android NDK version")
+
+option("--with-android-platform", nargs=1, help="location of the Android platform")
+
option("--with-android-toolchain", nargs=1, help="location of the Android toolchain")
option("--with-android-toolchain", nargs=1, help="Location of the Android toolchain")

option(
@@ -89,17 +93,20 @@ def ndk(value):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ index 060830948..af30e7622 100644
--- a/js/moz.configure
+++ b/js/moz.configure
@@ -59,8 +59,6 @@ set_config("JS_ENABLE_SMOOSH", enable_smoosh)
set_define("JS_ENABLE_SMOOSH", enable_smoosh)
set_config("MOZ_APP_NAME", moz_app_name)

include("../build/moz.configure/nspr.configure", when="--enable-compile-environment")
-include("../build/moz.configure/rust.configure", when="--enable-compile-environment")
Expand Down
22 changes: 0 additions & 22 deletions mozjs-sys/etc/patches/0030-autoconf-add-ohos.patch

This file was deleted.

13 changes: 0 additions & 13 deletions mozjs-sys/etc/patches/0032-macos-sdk-min-14-2.patch

This file was deleted.

32 changes: 11 additions & 21 deletions mozjs-sys/etc/patches/0033-no-zlib.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,13 @@ diff --git a/config/external/zlib/moz.build b/config/external/zlib/moz.build
index 755400fa7..d1311b9a7 100644
--- a/config/external/zlib/moz.build
+++ b/config/external/zlib/moz.build
@@ -6,16 +6,4 @@
@@ -6,9 +6,4 @@

Library("zlib")

-if CONFIG["MOZ_SYSTEM_ZLIB"]:
- OS_LIBS += CONFIG["MOZ_ZLIB_LIBS"]
-else:
- if CONFIG["ZLIB_IN_MOZGLUE"]:
- # Can't do this until mozglue is handled by moz.build instead of
- # config/rules.mk.
- # USE_LIBS += [
- # 'mozglue'
- # ]
- pass
- DIRS += [
- "../../../modules/zlib",
- ]
Expand All @@ -24,7 +17,7 @@ diff --git a/moz.configure b/moz.configure
index 804b9a375..87ccc508d 100755
--- a/moz.configure
+++ b/moz.configure
@@ -905,52 +905,11 @@ check_prog(
@@ -891,50 +891,8 @@ check_prog(
validate=validate_strip,
)

Expand Down Expand Up @@ -66,18 +59,15 @@ index 804b9a375..87ccc508d 100755
-
-set_config("MOZ_SYSTEM_ZLIB", True, when="--with-system-zlib")
-
-option(
- env="USE_LIBZ_RS",
- default=milestone.is_nightly,
- help="Use libz-rs-sys instead of zlib",
- when=toolkit & ~with_system_zlib_option,
-)
-
-@depends(with_system_zlib_option, js_shared, moz_linker, target.os)
-def zlib_in_mozglue(system_zlib, js_shared, linker, os):
- if not system_zlib and (js_shared or linker or os == "Android"):
- return True
-
-
-set_config("ZLIB_IN_MOZGLUE", zlib_in_mozglue)
-set_define("ZLIB_IN_MOZGLUE", zlib_in_mozglue)
-set_config("USE_LIBZ_RS", True, when="USE_LIBZ_RS")
+set_config("MOZ_SYSTEM_ZLIB", True)
+# This is not in upstream anymore
+set_config("ZLIB_IN_MOZGLUE", False)


# Please do not add configure checks from here on.
with only_when(cross_compiling):
option(
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ index 0b7395177..e84d76aba 100644
+ (void) OH_LOG_Print(LOG_APP, LOG_FATAL, 0, "MOZ_CRASH",
+ "Hit MOZ_CRASH(%{public}s), at %{public}s:%{public}d\n",
+ aStr, aFilename, aLine);
#else
# if defined(MOZ_BUFFER_STDERR)
char msg[1024] = "";
# if defined(MOZ_DUMP_ASSERTION_STACK)
MozWalkTheStackWithWriter(MOZ_CrashPrintFrame, CallerPC(),
/* aMaxFrames */ 0);
diff --git a/mfbt/DbgMacro.h b/mfbt/DbgMacro.h
index 3247b993c..c7039d5f8 100644
--- a/mfbt/DbgMacro.h
Expand Down Expand Up @@ -178,15 +178,15 @@ index 52bd6abc5..781402d56 100644
#include <string.h>
-#ifdef ANDROID
+#if defined(ANDROID)
#include <android/log.h>
# include <android/log.h>
+#elif defined(OHOS)
+# include <hilog/log.h>
#endif

/*
@@ -108,6 +110,19 @@ static void OutputDebugStringA(const char* msg) {
PR_Write(fd, buf, nb); \
} \
PR_Write(fd, buf, nb); \
} \
PR_END_MACRO
+#elif defined(OHOS)
+#define _PUT_LOG(fd, buf, nb) \
Expand All @@ -202,27 +202,25 @@ index 52bd6abc5..781402d56 100644
+ } \
+ PR_END_MACRO
#elif defined(_PR_PTHREADS)
#define _PUT_LOG(fd, buf, nb) PR_Write(fd, buf, nb)
# define _PUT_LOG(fd, buf, nb) PR_Write(fd, buf, nb)
#else
@@ -551,6 +566,8 @@ PR_IMPLEMENT(void) PR_Abort(void)
PR_LogPrint("Aborting");
PR_LogPrint("Aborting");
#ifdef ANDROID
__android_log_write(ANDROID_LOG_ERROR, "PRLog", "Aborting");
__android_log_write(ANDROID_LOG_ERROR, "PRLog", "Aborting");
+#elif defined(OHOS)
+ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "PRLog", "Aborting\n");
+ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "PRLog", "Aborting\n");
#endif
abort();
abort();
}
@@ -567,6 +584,9 @@ PR_IMPLEMENT(void) PR_Assert(const char *s, const char *file, PRIntn ln)
#elif defined(ANDROID)
__android_log_assert(NULL, "PRLog", "Assertion failure: %s, at %s:%d\n",
s, file, ln);
__android_log_assert(NULL, "PRLog", "Assertion failure: %s, at %s:%d\n", s,
file, ln);
+#elif defined(OHOS)
+ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "PRLog",
+ "Assertion failure: %{public}s, at %{public}s:%{public}d\n",s, file, ln);
+ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "PRLog",
+ "Assertion failure: %{public}s, at %{public}s:%{public}d\n",s, file, ln);
#endif
abort();
abort();
}
--
2.45.2

13 changes: 13 additions & 0 deletions mozjs-sys/etc/patches/0037-downgrade-ndk.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/python/mozboot/mozboot/android.py b/python/mozboot/mozboot/android.py
index c9f978796..0e20faeec 100644
--- a/python/mozboot/mozboot/android.py
+++ b/python/mozboot/mozboot/android.py
@@ -20,8 +20,8 @@ from tqdm import tqdm
# variable.
from mozboot.bootstrap import MOZCONFIG_SUGGESTION_TEMPLATE

-NDK_VERSION = "r28"
+NDK_VERSION = "r26c"
CMDLINE_TOOLS_VERSION_STRING = "19.0"
CMDLINE_TOOLS_VERSION = "13114758"

Loading
Loading