From 81e9ff2f130a24262d7c88bbb7d441432292932c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2024 14:15:26 +0000 Subject: [PATCH 1/7] chore(deps): upgrade SpiderMonkey to `250be4ca3c669db9a397456402f68249aa15d8d5` --- mozcentral.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mozcentral.version b/mozcentral.version index 9f4b8194..edb1ac10 100644 --- a/mozcentral.version +++ b/mozcentral.version @@ -1 +1 @@ -a283127a5d0aa005c54d339e8ca27414b55f079b \ No newline at end of file +250be4ca3c669db9a397456402f68249aa15d8d5 \ No newline at end of file From a3c349479824e4b4e5fdd58df05b348d2d0c709b Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Tue, 3 Dec 2024 17:53:25 +0000 Subject: [PATCH 2/7] fix(JobQueue): the `JobQueue::getIncumbentGlobal` method has been removed from the definition in new SpiderMonkey version --- include/JobQueue.hh | 9 --------- src/JobQueue.cc | 4 ---- 2 files changed, 13 deletions(-) diff --git a/include/JobQueue.hh b/include/JobQueue.hh index 36a6d810..a4ad4ecb 100644 --- a/include/JobQueue.hh +++ b/include/JobQueue.hh @@ -34,15 +34,6 @@ explicit JobQueue(JSContext *cx); */ bool init(JSContext *cx); -/** - * @brief Ask the embedding for the incumbent global. - * - * SpiderMonkey doesn't itself have a notion of incumbent globals as defined - * by the HTML spec, so we need the embedding to provide this. See - * dom/script/ScriptSettings.h for details. - */ -JSObject *getIncumbentGlobal(JSContext *cx) override; - /** * @brief Enqueue a reaction job `job` for `promise`, which was allocated at * `allocationSite`. Provide `incumbentGlobal` as the incumbent global for diff --git a/src/JobQueue.cc b/src/JobQueue.cc index 6dcb548f..a4ddaa61 100644 --- a/src/JobQueue.cc +++ b/src/JobQueue.cc @@ -26,10 +26,6 @@ JobQueue::JobQueue(JSContext *cx) { finalizationRegistryCallbacks = new JS::PersistentRooted(cx); // Leaks but it's OK since freed at process exit } -JSObject *JobQueue::getIncumbentGlobal(JSContext *cx) { - return JS::CurrentGlobalOrNull(cx); -} - bool JobQueue::enqueuePromiseJob(JSContext *cx, [[maybe_unused]] JS::HandleObject promise, JS::HandleObject job, From b832fa87de4751a68761d74a795703b9cc026672 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Tue, 3 Dec 2024 18:03:21 +0000 Subject: [PATCH 3/7] feat(JobQueue): implement the new `JobQueue::getHostDefinedData` method on `JobQueue` for the new SpiderMonkey version --- include/JobQueue.hh | 17 +++++++++++++++++ src/JobQueue.cc | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/include/JobQueue.hh b/include/JobQueue.hh index a4ad4ecb..36734f92 100644 --- a/include/JobQueue.hh +++ b/include/JobQueue.hh @@ -34,6 +34,23 @@ explicit JobQueue(JSContext *cx); */ bool init(JSContext *cx); +/** + * @brief Ask the embedding for the host defined data. + * + * SpiderMonkey doesn't itself have a notion of host defined data as defined + * by the HTML spec, so we need the embedding to provide this. See + * dom/script/ScriptSettings.h for details. + * + * If the embedding has the host defined data, this method should return the + * host defined data via the `data` out parameter and return `true`. + * The object in the `data` out parameter can belong to any compartment. + * If the embedding doesn't need the host defined data, this method should + * set the `data` out parameter to `nullptr` and return `true`. + * If any error happens while generating the host defined data, this method + * should set a pending exception to `cx` and return `false`. + */ +bool getHostDefinedData(JSContext *cx, JS::MutableHandle data) const override; + /** * @brief Enqueue a reaction job `job` for `promise`, which was allocated at * `allocationSite`. Provide `incumbentGlobal` as the incumbent global for diff --git a/src/JobQueue.cc b/src/JobQueue.cc index a4ddaa61..928746fd 100644 --- a/src/JobQueue.cc +++ b/src/JobQueue.cc @@ -26,6 +26,11 @@ JobQueue::JobQueue(JSContext *cx) { finalizationRegistryCallbacks = new JS::PersistentRooted(cx); // Leaks but it's OK since freed at process exit } +bool JobQueue::getHostDefinedData(JSContext *cx, JS::MutableHandle data) const { + data.set(nullptr); // We don't need the host defined data + return true; // `true` indicates no error +} + bool JobQueue::enqueuePromiseJob(JSContext *cx, [[maybe_unused]] JS::HandleObject promise, JS::HandleObject job, From b36bbdfe87666a3eada0520cd9f7bd6e05530d63 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Tue, 3 Dec 2024 18:31:30 +0000 Subject: [PATCH 4/7] fix(CI): the macOS-12 environment is deprecated and removed from GitHub hosted runners --- .github/workflows/test-and-publish.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-and-publish.yaml b/.github/workflows/test-and-publish.yaml index cccd0aa0..92b2c750 100644 --- a/.github/workflows/test-and-publish.yaml +++ b/.github/workflows/test-and-publish.yaml @@ -16,7 +16,7 @@ on: options: - '' - 'ubuntu-20.04' - - 'macos-12' + - 'macos-13' - 'macos-14' - 'windows-2022' debug_enabled_python: @@ -132,7 +132,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ 'ubuntu-20.04', 'macos-12', 'macos-14', 'windows-2022', 'pi' ] + os: [ 'ubuntu-20.04', 'macos-13', 'macos-14', 'windows-2022', 'pi' ] python_version: [ '3.8', '3.9', '3.10', '3.11', '3.12', '3.13' ] runs-on: ${{ matrix.os }} steps: @@ -207,7 +207,7 @@ jobs: BUILD_TYPE=${WORKFLOW_BUILD_TYPE:-"Debug"} poetry build --format=wheel ls -lah ./dist/ - name: Make the wheels we build also support lower versions of macOS - if: ${{ matrix.os == 'macos-12' || matrix.os == 'macos-14' }} + if: ${{ matrix.os == 'macos-13' || matrix.os == 'macos-14' }} # Change the platform tag part of the wheel filename to `macosx_11_0_xxx` (means to support macOS 11.0 and above) # See https://packaging.python.org/en/latest/specifications/binary-distribution-format/#file-format # A wheel package file will only be selected by pip to install if the platform tag satisfies, regardless of whether the binary compatibility actually is. From 65e852f3eae08cf9684b52c4d2b656b27ee30b1e Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Sat, 21 Dec 2024 08:34:19 +0000 Subject: [PATCH 5/7] fix: class prototypes cannot be properly set test_bytes_instanceof: Python bytes instanceof JS Uint8Array assert False test_keys_iterator: TypeError iterator is not iterable If `explicit-resource-management` is enabled, the lib .so will be compiled differently to the header files when there's a `IF_EXPLICIT_RESOURCE_MANAGEMENT` macro used. The `enum JSProtoKey` index is off by 1 (header `JSProto_Uint8Array` 27 will be interpreted as `JSProto_Int8Array` in lib as lib has an extra element) --- setup.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index a10d7b66..dd5a6f50 100755 --- a/setup.sh +++ b/setup.sh @@ -79,7 +79,10 @@ mkdir -p ../../../../_spidermonkey_install/ --disable-jemalloc \ --disable-tests \ $(if [[ "$OSTYPE" == "darwin"* ]]; then echo "--enable-linker=ld64"; fi) \ - --enable-optimize + --enable-optimize \ + --disable-explicit-resource-management +# disable-explicit-resource-management: Disable the `using` syntax that is enabled by default in SpiderMonkey nightly, otherwise the header files will disagree with the compiled lib .so file +# when it's using a `IF_EXPLICIT_RESOURCE_MANAGEMENT` macro, e.g., the `enum JSProtoKey` index would be off by 1 (header `JSProto_Uint8Array` 27 will be interpreted as `JSProto_Int8Array` in lib as lib has an extra element) make -j$CPUS echo "Done building spidermonkey" From a3ea199e706b652cafc1a588ea32ff0abdb6f457 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Thu, 9 Jan 2025 08:11:19 +0000 Subject: [PATCH 6/7] chore: patches for Windows linking issues are no longer needed, as they were fixed in upstream SpiderMonkey See https://bugzilla.mozilla.org/show_bug.cgi?id=1751561 and https://bugzilla.mozilla.org/show_bug.cgi?id=1802675 See also: https://discourse.mozilla.org/t/problem-building-102-3-0esr-on-windows/105671 --- setup.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/setup.sh b/setup.sh index dd5a6f50..fedc944d 100755 --- a/setup.sh +++ b/setup.sh @@ -54,8 +54,6 @@ cd firefox-source # Apply patching # making it work for both GNU and BSD (macOS) versions of sed sed -i'' -e 's/os not in ("WINNT", "OSX", "Android")/os not in ("WINNT", "Android")/' ./build/moz.configure/pkg.configure # use pkg-config on macOS -sed -i'' -e '/"WindowsDllMain.cpp"/d' ./mozglue/misc/moz.build # https://discourse.mozilla.org/t/105671, https://bugzilla.mozilla.org/show_bug.cgi?id=1751561 -sed -i'' -e '/"winheap.cpp"/d' ./memory/mozalloc/moz.build # https://bugzilla.mozilla.org/show_bug.cgi?id=1802675 sed -i'' -e 's/bool Unbox/JS_PUBLIC_API bool Unbox/g' ./js/public/Class.h # need to manually add JS_PUBLIC_API to js::Unbox until it gets fixed in Spidermonkey sed -i'' -e 's/bool js::Unbox/JS_PUBLIC_API bool js::Unbox/g' ./js/src/vm/JSObject.cpp # same here sed -i'' -e 's/shared_lib = self._pretty_path(libdef.output_path, backend_file)/shared_lib = libdef.lib_name/' ./python/mozbuild/mozbuild/backend/recursivemake.py # would generate a Makefile to install the binary files from an invalid path prefix From aaa7e4d5db276c3c650a36afaf335ab78e92ef0c Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Thu, 9 Jan 2025 08:47:55 +0000 Subject: [PATCH 7/7] fix: error 'unistd.h' file not found on Windows On https://searchfox.org/mozilla-central/rev/ead020d/mozglue/baseprofiler/public/BaseProfilerUtils.h#22, it detects Windows platform by seeing if the `XP_WIN` macro is defined, if not then assumes it's on POSIX and includes the `` header to use `getpid()`. The `mozilla/BaseProfilerUtils.h` header file is introduced to `js/Debug.h` in https://phabricator.services.mozilla.com/D221102 (https://bugzilla.mozilla.org/show_bug.cgi?id=1911021), but it would be compiled without `XP_WIN` in our building configuration --- setup.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.sh b/setup.sh index fedc944d..5a2a2eb2 100755 --- a/setup.sh +++ b/setup.sh @@ -64,6 +64,7 @@ sed -i'' -e 's/return !IsIteratorHelpersEnabled()/return false/' ./js/src/vm/Glo sed -i'' -e '/MOZ_CRASH_UNSAFE_PRINTF/,/__PRETTY_FUNCTION__);/d' ./mfbt/LinkedList.h # would crash in Debug Build: in `~LinkedList()` it should have removed all this list's elements before the list's destruction sed -i'' -e '/MOZ_ASSERT(stackRootPtr == nullptr);/d' ./js/src/vm/JSContext.cpp # would assert false in Debug Build since we extensively use `new JS::Rooted` sed -i'' -e 's/"-fuse-ld=ld"/"-ld64" if c_compiler.version > "14.0.0" else "-fuse-ld=ld"/' ./build/moz.configure/toolchain.configure # XCode 15 changed the linker behaviour. See https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Linking +sed -i'' -e 's/defined(XP_WIN)/defined(_WIN32)/' ./mozglue/baseprofiler/public/BaseProfilerUtils.h # this header file is introduced to js/Debug.h in https://phabricator.services.mozilla.com/D221102, but it would be compiled without XP_WIN in this building configuration cd js/src mkdir -p _build @@ -81,6 +82,7 @@ mkdir -p ../../../../_spidermonkey_install/ --disable-explicit-resource-management # disable-explicit-resource-management: Disable the `using` syntax that is enabled by default in SpiderMonkey nightly, otherwise the header files will disagree with the compiled lib .so file # when it's using a `IF_EXPLICIT_RESOURCE_MANAGEMENT` macro, e.g., the `enum JSProtoKey` index would be off by 1 (header `JSProto_Uint8Array` 27 will be interpreted as `JSProto_Int8Array` in lib as lib has an extra element) +# https://bugzilla.mozilla.org/show_bug.cgi?id=1940342 make -j$CPUS echo "Done building spidermonkey"