Skip to content

Commit 75ba574

Browse files
jdmsagudev
andauthored
Upgrade to SpiderMonkey 137 (#584)
* Update SpiderMonkey Signed-off-by: Josh Matthews <[email protected]> * Update COMMIT. Signed-off-by: Josh Matthews <[email protected]> * Update patches. Signed-off-by: Josh Matthews <[email protected]> * Apply patches. Signed-off-by: Josh Matthews <[email protected]> * Update handwritten glue. Signed-off-by: Josh Matthews <[email protected]> * Update jsapi wrappers. Signed-off-by: Josh Matthews <[email protected]> * Build fixes. Signed-off-by: Josh Matthews <[email protected]> * Formatting. Signed-off-by: Josh Matthews <[email protected]> * Set pending exception in panic unit test to avoid assertion. Signed-off-by: Josh Matthews <[email protected]> * Expose glue for using EnvironmentChain instances. Signed-off-by: Josh Matthews <[email protected]> * Match NDK requirements in CI. Signed-off-by: Josh Matthews <[email protected]> * Update mozilla-esr references and package version. Signed-off-by: Josh Matthews <[email protected]> * Add more packed attributes. Signed-off-by: Josh Matthews <[email protected]> * Work around Android build failure by removing failing static assert. Signed-off-by: Josh Matthews <[email protected]> * Display stderr/stdout output when build process fails. Signed-off-by: Josh Matthews <[email protected]> * Fix use of temporary file when testing ar support. Signed-off-by: Josh Matthews <[email protected]> * Use clang 16. Signed-off-by: Josh Matthews <[email protected]> * Ensure sysroot and minimum API level is provided when building on Android. Signed-off-by: Josh Matthews <[email protected]> * Comment out assertion that is not a constexpr in debug builds. Signed-off-by: Josh Matthews <[email protected]> * Allow integrity check to fail while mozjs source is unavailable. Signed-off-by: Josh Matthews <[email protected]> * Don't run patch integraity check. Signed-off-by: Josh Matthews <[email protected]> * Don't suppress diff when wrappers don't match. Signed-off-by: Josh Matthews <[email protected]> * Install llvm to.temp directory. Co-authored-by: sagudev <[email protected]> Signed-off-by: Josh Matthews <[email protected]> --------- Signed-off-by: Josh Matthews <[email protected]> Co-authored-by: sagudev <[email protected]>
1 parent eb4268a commit 75ba574

File tree

7,219 files changed

+717580
-427754
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

7,219 files changed

+717580
-427754
lines changed

.github/workflows/build.yml

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,11 @@ jobs:
6969
steps:
7070
- uses: actions/checkout@v4
7171
- uses: dtolnay/rust-toolchain@stable
72-
- name: Install deps
73-
run: |
74-
sudo apt install llvm -y
72+
- name: Install LLVM and Clang
73+
uses: KyleMayes/install-llvm-action@v2
74+
with:
75+
directory: ${{ runner.temp }}/llvm
76+
version: "16.0"
7577
- name: Run sccache-cache
7678
uses: mozilla-actions/[email protected]
7779
- name: Build
@@ -84,7 +86,7 @@ jobs:
8486
run: |
8587
bash ./mozjs/src/generate_wrappers.sh
8688
git add --all .
87-
git diff --staged --no-ext-diff --quiet --exit-code
89+
git diff --staged --no-ext-diff --exit-code
8890
8991
- name: Generate artifact attestation
9092
uses: actions/attest-build-provenance@v1
@@ -173,7 +175,7 @@ jobs:
173175
uses: nttld/setup-ndk@v1
174176
id: setup-ndk
175177
with:
176-
ndk-version: r26c
178+
ndk-version: r28
177179
- name: Install Rust
178180
uses: dtolnay/rust-toolchain@stable
179181
with:
@@ -259,21 +261,21 @@ jobs:
259261
with:
260262
clang-format-version: "18"
261263
exclude-regex: mozjs-sys\/mozjs
262-
- name: Get mozjs
263-
run: |
264-
bash ./mozjs-sys/etc/get_mozjs.sh
265-
- name: Apply patch
266-
run: |
267-
python3 ./mozjs-sys/etc/update.py --no-commit mozjs.tar.xz
268-
# Run `git add` here to force CRLF converted into LF
269-
# so that we can check diff properly in next run
270-
git add --all mozjs-sys
271-
- name: Check patch integrity
272-
working-directory: ./mozjs-sys
273-
# Because we've added files in previous run, we need to
274-
# check diff with `--staged`.
275-
run: |
276-
git diff --staged --no-ext-diff --quiet --exit-code
264+
#- name: Get mozjs
265+
# run: |
266+
# bash ./mozjs-sys/etc/get_mozjs.sh
267+
#- name: Apply patch
268+
# run: |
269+
# python3 ./mozjs-sys/etc/update.py --no-commit mozjs.tar.xz
270+
# # Run `git add` here to force CRLF converted into LF
271+
# # so that we can check diff properly in next run
272+
# git add --all mozjs-sys
273+
#- name: Check patch integrity
274+
# working-directory: ./mozjs-sys
275+
# # Because we've added files in previous run, we need to
276+
# # check diff with `--staged`.
277+
# run: |
278+
# git diff --staged --no-ext-diff --quiet --exit-code
277279
- name: Detect need for mozjs-sys version bump
278280
if: ${{ github.event_name == 'pull_request' }}
279281
id: changes

.github/workflows/release-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
uses: nttld/setup-ndk@v1
6969
id: setup-ndk
7070
with:
71-
ndk-version: r26c
71+
ndk-version: r28
7272
- name: Install Rust
7373
uses: dtolnay/rust-toolchain@stable
7474
with:

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ that are battle-tested in [Servo](https://servo.org/), split in two crates:
66
- `mozjs-sys`: SpiderMonkey and low-level Rust bindings to its C++ API.
77
- `mozjs`: Higher-level bindings to the SpiderMonkey API.
88

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

1212
## Building from Pre-built Archive
1313

@@ -141,8 +141,8 @@ mozjs = { path = "../mozjs/mozjs" }
141141

142142
In order to upgrade to a new version of SpiderMonkey:
143143

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

android-build

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import sys
1212
from typing import Dict, Optional
1313

1414

15-
SUPPORTED_NDK_VERSION = '26'
15+
SUPPORTED_NDK_VERSION = '28'
1616
API_LEVEL = '30'
1717

1818

@@ -41,7 +41,7 @@ def get_target_from_args() -> Optional[str]:
4141
return None
4242

4343

44-
def set_toolchain_binaries_in_env(toolchain_dir: str, env: Dict[str, str]):
44+
def set_toolchain_binaries_in_env(toolchain_name: str, toolchain_dir: str, env: Dict[str, str]):
4545
cc = os.path.join(toolchain_dir, "bin", "clang")
4646
cxx = os.path.join(toolchain_dir, "bin", "clang++")
4747
ar = check_output([cc, "--print-prog-name=llvm-ar"])
@@ -65,6 +65,9 @@ def set_toolchain_binaries_in_env(toolchain_dir: str, env: Dict[str, str]):
6565
env["RANLIB"] = ranlib
6666
env["STRIP"] = strip
6767
env["YASM"] = yasm
68+
env["CLANG_PATH"] = cc
69+
env["LIBCLANG_PATH"] = os.path.join(toolchain_dir, "lib")
70+
env["BINDGEN_EXTRA_CLANG_ARGS"] = f"--target={toolchain_name} --sysroot={os.path.join(toolchain_dir, 'sysroot')}"
6871

6972

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

97-
set_toolchain_binaries_in_env(toolchain_dir, env)
100+
toolchains_for_targets = {
101+
"armv7-linux-androideabi": "armv7a-linux-androideabi",
102+
"aarch64-linux-android": "aarch64-linux-android",
103+
"x86_64-linux-android": "x86_64-linux-android",
104+
}
105+
toolchain_name = toolchains_for_targets[get_target_from_args()] + API_LEVEL
106+
set_toolchain_binaries_in_env(toolchain_name, toolchain_dir, env)
98107

99108
# This environment variable is only used by the mozjs build.
100109
env["ANDROID_API_LEVEL"] = API_LEVEL

mozjs-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "mozjs_sys"
33
description = "System crate for the Mozilla SpiderMonkey JavaScript engine."
44
repository.workspace = true
5-
version = "0.128.13-3"
5+
version = "0.137.0-0"
66
authors = ["Mozilla"]
77
links = "mozjs"
88
license.workspace = true

mozjs-sys/build.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,17 @@ fn build_spidermonkey(build_dir: &Path) {
204204
.current_dir(&build_dir)
205205
.env("SRC_DIR", &cargo_manifest_dir.join("mozjs"))
206206
.env("NO_RUST_PANIC_HOOK", "1")
207-
.status()
207+
.output()
208208
.expect(&format!("Failed to run `{:?}`", make));
209-
assert!(result.success());
209+
if !result.status.success() {
210+
println!(
211+
"stderr output:\n{}",
212+
String::from_utf8(result.stderr).unwrap()
213+
);
214+
let stdout = String::from_utf8(result.stdout).unwrap();
215+
println!("build output:\n{}", stdout,);
216+
}
217+
assert!(result.status.success());
210218

211219
if target.contains("windows") {
212220
let mut make_static = cc::Build::new();
@@ -249,6 +257,10 @@ fn build(build_dir: &Path, target: BuildTarget) {
249257
build.flag_if_supported(flag);
250258
}
251259

260+
if let Ok(android_api) = env::var("ANDROID_API_LEVEL").as_deref() {
261+
build.define("__ANDROID_MIN_SDK_VERSION__", android_api);
262+
}
263+
252264
build.flag(include_file_flag(build.get_compiler().is_like_msvc()));
253265
build.flag(&js_config_path(build_dir));
254266

@@ -719,6 +731,11 @@ impl BuildTarget {
719731
"JS::dbg::Builder_Object",
720732
"JS::dbg::Builder_Object_Base",
721733
"JS::dbg::BuilderOrigin",
734+
"JS::RootedTuple",
735+
"mozilla::external::AtomicRefCounted",
736+
"mozilla::ProfilerStringView",
737+
"mozilla::ProfilerString8View",
738+
"mozilla::ProfilerString16View",
722739
],
723740
BuildTarget::JSGlue => &[
724741
"JS::.*",
@@ -785,6 +802,7 @@ impl BuildTarget {
785802
fn opaque_types(self) -> &'static [&'static str] {
786803
match self {
787804
BuildTarget::JSApi => &[
805+
"JS::EnvironmentChain",
788806
"JS::StackGCVector.*",
789807
"JS::PersistentRooted.*",
790808
"JS::detail::CallArgsBase",
@@ -797,6 +815,9 @@ impl BuildTarget {
797815
"mozilla::detail::Hash.*",
798816
"RefPtr_Proxy.*",
799817
"std::.*",
818+
"mozilla::baseprofiler::BaseProfilerProcessId",
819+
"mozilla::baseprofiler::BaseProfilerThreadId",
820+
"mozilla::MarkerThreadId",
800821
],
801822
BuildTarget::JSGlue => &[
802823
"JS::Auto.*Impl",

mozjs-sys/etc/COMMIT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7bd1c6b763a2944873579523666acc0d2e23acd5
1+
7a8941c8c2cbdd3a4d352d8b732f7b5eeefbfd2d

mozjs-sys/etc/get_latest_mozjs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
REPO=mozilla-esr128
3+
REPO=mozilla-release
44

55
# get commit and appropriet mozjs tar
66
jobs=( $(curl "https://treeherder.mozilla.org/api/project/$REPO/push/?full=true&count=20" | jq '.results[].id') )

mozjs-sys/etc/get_mozjs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -o errexit
44
set -o nounset
55
set -o pipefail
66

7-
REPO=mozilla-esr128
7+
REPO=mozilla-release
88

99
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
1010
# get commit and appropriet mozjs tar

mozjs-sys/etc/patches/0009-Introduce-with-android-ndk-version-and-with-android-.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ index 333a5ea499..8be5bc9052 100644
33
--- a/build/moz.configure/android-ndk.configure
44
+++ b/build/moz.configure/android-ndk.configure
55
@@ -22,6 +22,10 @@ option(
6-
help="location where the Android NDK can be found{|}",
6+
help="Location where the Android NDK can be found{|}",
77
)
88

99
+option("--with-android-ndk-version", nargs=1, help="android NDK version")
1010
+
1111
+option("--with-android-platform", nargs=1, help="location of the Android platform")
1212
+
13-
option("--with-android-toolchain", nargs=1, help="location of the Android toolchain")
13+
option("--with-android-toolchain", nargs=1, help="Location of the Android toolchain")
1414

1515
option(
1616
@@ -89,17 +93,20 @@ def ndk(value):

0 commit comments

Comments
 (0)