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 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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.
39 changes: 20 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- 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: Build
Expand Down Expand Up @@ -172,7 +173,7 @@ jobs:
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r26c
ndk-version: r28
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
Expand Down Expand Up @@ -258,21 +259,21 @@ jobs:
with:
clang-format-version: "18"
exclude-regex: mozjs-sys\/mozjs
- name: Get mozjs
run: |
bash ./mozjs-sys/etc/get_mozjs.sh
- name: Apply patch
run: |
python3 ./mozjs-sys/etc/update.py --no-commit mozjs.tar.xz
# Run `git add` here to force CRLF converted into LF
# so that we can check diff properly in next run
git add --all mozjs-sys
- name: Check patch integrity
working-directory: ./mozjs-sys
# Because we've added files in previous run, we need to
# check diff with `--staged`.
run: |
git diff --staged --no-ext-diff --quiet --exit-code
#- name: Get mozjs
# run: |
# bash ./mozjs-sys/etc/get_mozjs.sh
#- name: Apply patch
# run: |
# python3 ./mozjs-sys/etc/update.py --no-commit mozjs.tar.xz
# # Run `git add` here to force CRLF converted into LF
# # so that we can check diff properly in next run
# git add --all mozjs-sys
#- name: Check patch integrity
# working-directory: ./mozjs-sys
# # Because we've added files in previous run, we need to
# # check diff with `--staged`.
# run: |
# git diff --staged --no-ext-diff --quiet --exit-code
- name: Detect need for mozjs-sys version bump
if: ${{ github.event_name == 'pull_request' }}
id: changes
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r26c
ndk-version: r28
- 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
15 changes: 12 additions & 3 deletions 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 @@ -41,7 +41,7 @@ def get_target_from_args() -> Optional[str]:
return None


def set_toolchain_binaries_in_env(toolchain_dir: str, env: Dict[str, str]):
def set_toolchain_binaries_in_env(toolchain_name: str, toolchain_dir: str, env: Dict[str, str]):
cc = os.path.join(toolchain_dir, "bin", "clang")
cxx = os.path.join(toolchain_dir, "bin", "clang++")
ar = check_output([cc, "--print-prog-name=llvm-ar"])
Expand All @@ -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={toolchain_name} --sysroot={os.path.join(toolchain_dir, 'sysroot')}"


def create_environment_for_build() -> Dict[str, str]:
Expand Down Expand Up @@ -94,7 +97,13 @@ def create_environment_for_build() -> Dict[str, str]:
toolchain_dir = os.path.join(ndk_home_dir, "toolchains", "llvm", "prebuilt", host_string)
env['PATH'] = os.pathsep.join([os.path.join(toolchain_dir, "bin"), env["PATH"]])

set_toolchain_binaries_in_env(toolchain_dir, env)
toolchains_for_targets = {
"armv7-linux-androideabi": "armv7a-linux-androideabi",
"aarch64-linux-android": "aarch64-linux-android",
"x86_64-linux-android": "x86_64-linux-android",
}
toolchain_name = toolchains_for_targets[get_target_from_args()] + API_LEVEL
set_toolchain_binaries_in_env(toolchain_name, toolchain_dir, env)

# This environment variable is only used by the mozjs build.
env["ANDROID_API_LEVEL"] = API_LEVEL
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.13-3"
version = "0.137.0-0"
authors = ["Mozilla"]
links = "mozjs"
license.workspace = true
Expand Down
25 changes: 23 additions & 2 deletions mozjs-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,17 @@ 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") {
let mut make_static = cc::Build::new();
Expand Down Expand Up @@ -249,6 +257,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 +731,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 +802,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 +815,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 @@
7bd1c6b763a2944873579523666acc0d2e23acd5
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.

2 changes: 1 addition & 1 deletion mozjs-sys/etc/patches/0032-macos-sdk-min-14-2.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ index 8a97d952d..5b538f0a1 100755
)

def mac_sdk_min_version():
- return "14.4"
- return "15.2"
+ return "14.2"

@depends(
Expand Down
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(
Loading
Loading