From c55099cdd6d61a9907cd9a3235bcc45eae1c620f Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Wed, 14 Aug 2024 18:36:32 +0000 Subject: [PATCH 01/12] chore(CI): add arm64 build Building on our in-house Raspberry Pi runner. --- .github/workflows/test-and-publish.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-and-publish.yaml b/.github/workflows/test-and-publish.yaml index 296b66af..edd54105 100644 --- a/.github/workflows/test-and-publish.yaml +++ b/.github/workflows/test-and-publish.yaml @@ -60,7 +60,7 @@ jobs: fail-fast: false matrix: # Use Ubuntu 20.04 / Ubuntu 24.04 / macOS 13 x86_64 / macOS 14 arm64 + Python 3.10 to build SpiderMonkey - os: [ 'ubuntu-20.04', 'ubuntu-24.04', 'macos-13', 'macos-14' ] # macOS 14 runner exclusively runs on M1 hardwares + os: [ 'ubuntu-20.04', 'ubuntu-24.04', 'macos-13', 'macos-14', 'pi' ] # macOS 14 runner exclusively runs on M1 hardwares # see https://github.blog/changelog/2024-01-30-github-actions-macos-14-sonoma-is-now-available python_version: [ '3.10' ] runs-on: ${{ matrix.os }} @@ -127,7 +127,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ 'ubuntu-20.04', 'ubuntu-24.04', 'macos-12', 'macos-14', 'windows-2022' ] + os: [ 'ubuntu-20.04', 'ubuntu-24.04', 'macos-12', 'macos-14', 'windows-2022', 'pi' ] python_version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ] exclude: # actions/setup-python: The version '3.8'/'3.9' with architecture 'arm64' was not found for macOS. From 8e7c55934e2abea9f482e0c6b4748b8fa95c31f5 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Wed, 14 Aug 2024 18:38:35 +0000 Subject: [PATCH 02/12] fix(CI): temporarily fix Windows build --- setup.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index ca7ab7c9..9cab6c6d 100755 --- a/setup.sh +++ b/setup.sh @@ -34,7 +34,9 @@ fi # Install rust compiler echo "Installing rust compiler" curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain 1.76 -. $HOME/.cargo/env +if [[ "$OSTYPE" != "msys"* ]]; then # not Windows + . $HOME/.cargo/env +fi cargo install cbindgen # Setup Poetry echo "Installing poetry" From 723c301dc9ee048793ec3b3c82a2d9013bf0852f Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Wed, 14 Aug 2024 23:09:13 +0000 Subject: [PATCH 03/12] fix(CI): use the correct Python version for poetry --- .github/workflows/test-and-publish.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-and-publish.yaml b/.github/workflows/test-and-publish.yaml index edd54105..ad913aeb 100644 --- a/.github/workflows/test-and-publish.yaml +++ b/.github/workflows/test-and-publish.yaml @@ -162,9 +162,11 @@ jobs: fi echo "Installing python deps" poetry self add "poetry-dynamic-versioning[plugin]" - poetry env use python3 # use the correct Python version we've set up + poetry env use python$PYTHON_VERSION # use the correct Python version we've set up poetry install --no-root --only=dev echo "Installed Dependencies" + env: + PYTHON_VERSION: ${{ matrix.python_version }} - name: Build Docs # only build docs once if: ${{ matrix.os == 'ubuntu-20.04' && matrix.python_version == '3.11' }} run: | From 228467f54a55aa22ee3214176d544f04657d31ca Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Thu, 15 Aug 2024 14:53:57 +0000 Subject: [PATCH 04/12] Revert "fix(CI): use the correct Python version for poetry" This reverts commit 723c301dc9ee048793ec3b3c82a2d9013bf0852f. --- .github/workflows/test-and-publish.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/test-and-publish.yaml b/.github/workflows/test-and-publish.yaml index ad913aeb..edd54105 100644 --- a/.github/workflows/test-and-publish.yaml +++ b/.github/workflows/test-and-publish.yaml @@ -162,11 +162,9 @@ jobs: fi echo "Installing python deps" poetry self add "poetry-dynamic-versioning[plugin]" - poetry env use python$PYTHON_VERSION # use the correct Python version we've set up + poetry env use python3 # use the correct Python version we've set up poetry install --no-root --only=dev echo "Installed Dependencies" - env: - PYTHON_VERSION: ${{ matrix.python_version }} - name: Build Docs # only build docs once if: ${{ matrix.os == 'ubuntu-20.04' && matrix.python_version == '3.11' }} run: | From 76140aff2bd173f4616f7878c9d0a14e94a1ac54 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Thu, 15 Aug 2024 15:14:29 +0000 Subject: [PATCH 05/12] fix(CI): use the correct Python version for poetry --- .github/workflows/test-and-publish.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-and-publish.yaml b/.github/workflows/test-and-publish.yaml index edd54105..240dda3c 100644 --- a/.github/workflows/test-and-publish.yaml +++ b/.github/workflows/test-and-publish.yaml @@ -162,9 +162,11 @@ jobs: fi echo "Installing python deps" poetry self add "poetry-dynamic-versioning[plugin]" - poetry env use python3 # use the correct Python version we've set up + poetry env use python$PYTHON_VERSION || poetry env use python3 # use the correct Python version we've set up poetry install --no-root --only=dev echo "Installed Dependencies" + env: + PYTHON_VERSION: ${{ matrix.python_version }} - name: Build Docs # only build docs once if: ${{ matrix.os == 'ubuntu-20.04' && matrix.python_version == '3.11' }} run: | From be2f4b232110f929607079ade5e201f49db8885c Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Sat, 17 Aug 2024 21:16:32 +0000 Subject: [PATCH 06/12] fix(CI): remove old virtual environments for poetry --- .github/workflows/test-and-publish.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-and-publish.yaml b/.github/workflows/test-and-publish.yaml index 240dda3c..a3de645e 100644 --- a/.github/workflows/test-and-publish.yaml +++ b/.github/workflows/test-and-publish.yaml @@ -162,11 +162,10 @@ jobs: fi echo "Installing python deps" poetry self add "poetry-dynamic-versioning[plugin]" - poetry env use python$PYTHON_VERSION || poetry env use python3 # use the correct Python version we've set up + poetry env remove --all + poetry env use python3 # use the correct Python version we've set up poetry install --no-root --only=dev echo "Installed Dependencies" - env: - PYTHON_VERSION: ${{ matrix.python_version }} - name: Build Docs # only build docs once if: ${{ matrix.os == 'ubuntu-20.04' && matrix.python_version == '3.11' }} run: | From 2535988261924b32eb4cccd52d67fc7644bf13e6 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Sat, 17 Aug 2024 21:24:31 +0000 Subject: [PATCH 07/12] fix(CI): use the correct Python version for poetry --- .github/workflows/test-and-publish.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-and-publish.yaml b/.github/workflows/test-and-publish.yaml index a3de645e..1382d995 100644 --- a/.github/workflows/test-and-publish.yaml +++ b/.github/workflows/test-and-publish.yaml @@ -162,10 +162,12 @@ jobs: fi echo "Installing python deps" poetry self add "poetry-dynamic-versioning[plugin]" - poetry env remove --all - poetry env use python3 # use the correct Python version we've set up + poetry env remove --all -v + poetry env use python$PYTHON_VERSION || poetry env use python3 # use the correct Python version we've set up poetry install --no-root --only=dev echo "Installed Dependencies" + env: + PYTHON_VERSION: ${{ matrix.python_version }} - name: Build Docs # only build docs once if: ${{ matrix.os == 'ubuntu-20.04' && matrix.python_version == '3.11' }} run: | From 99a9f27da6529947e10bbfb2c642abb9a1dc9ecc Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Sat, 17 Aug 2024 21:32:47 +0000 Subject: [PATCH 08/12] fix(CI): remove old poetry cache --- .github/workflows/test-and-publish.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-and-publish.yaml b/.github/workflows/test-and-publish.yaml index 1382d995..afcadfc9 100644 --- a/.github/workflows/test-and-publish.yaml +++ b/.github/workflows/test-and-publish.yaml @@ -146,6 +146,9 @@ jobs: - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python_version }} + - name: Remove old poetry cache + run: rm -rf ~/.cache/pypoetry + if: ${{ matrix.os == 'pi' }} - name: Setup Poetry uses: snok/install-poetry@v1 with: @@ -162,7 +165,6 @@ jobs: fi echo "Installing python deps" poetry self add "poetry-dynamic-versioning[plugin]" - poetry env remove --all -v poetry env use python$PYTHON_VERSION || poetry env use python3 # use the correct Python version we've set up poetry install --no-root --only=dev echo "Installed Dependencies" From 3d02051cecaf6bfc3483938eda698aa2244a63af Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Sun, 18 Aug 2024 04:34:08 +0000 Subject: [PATCH 09/12] fix: compilation error in `JSObjectProxy.cc` error: cannot initialize return object of type 'bool' with an rvalue of type 'std::nullptr_t' --- src/JSObjectProxy.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/JSObjectProxy.cc b/src/JSObjectProxy.cc index 675219bf..13b3e609 100644 --- a/src/JSObjectProxy.cc +++ b/src/JSObjectProxy.cc @@ -245,7 +245,7 @@ bool JSObjectProxyMethodDefinitions::JSObjectProxy_richcompare_helper(JSObjectPr if (!js::GetPropertyKeys(GLOBAL_CX, *(self->jsObject), JSITER_OWNONLY, &props)) { PyErr_Format(PyExc_SystemError, "%s JSAPI call failed", JSObjectProxyType.tp_name); - return NULL; + return false; } // iterate recursively through members of self and check for equality @@ -442,7 +442,7 @@ PyObject *JSObjectProxyMethodDefinitions::JSObjectProxy_repr(JSObjectProxy *self PyErr_Clear(); } - if (_PyUnicodeWriter_WriteASCIIString(&writer, "", 19) < 0) { + if (_PyUnicodeWriter_WriteASCIIString(&writer, "", 19) < 0) { goto error; } } From d0d8bff57696b414c60c1c71b1adeb0ddb615c54 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Sun, 18 Aug 2024 04:41:31 +0000 Subject: [PATCH 10/12] fix(setup.sh): forcibly compile SpiderMonkey to `clang`'s (cross-)compilation target setup If the target triple is different even by the `vendor` parameter, it be treated differently, and fatal error: 'type_traits' file not found #include See https://clang.llvm.org/docs/CrossCompilation.html#target-triple --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 9cab6c6d..30d1b7ab 100755 --- a/setup.sh +++ b/setup.sh @@ -75,7 +75,7 @@ cd js/src mkdir -p _build cd _build mkdir -p ../../../../_spidermonkey_install/ -../configure \ +../configure --target=$(clang --print-target-triple) \ --prefix=$(realpath $PWD/../../../../_spidermonkey_install) \ --with-intl-api \ $(if [[ "$OSTYPE" != "msys"* ]]; then echo "--without-system-zlib"; fi) \ From 0bb14cf13bce976bdc0274f8bc9cb464efdf63cf Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Sun, 18 Aug 2024 04:49:56 +0000 Subject: [PATCH 11/12] Revert "fix(CI): temporarily fix Windows build" This reverts commit 8e7c55934e2abea9f482e0c6b4748b8fa95c31f5. --- setup.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/setup.sh b/setup.sh index 30d1b7ab..e8467798 100755 --- a/setup.sh +++ b/setup.sh @@ -34,9 +34,7 @@ fi # Install rust compiler echo "Installing rust compiler" curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain 1.76 -if [[ "$OSTYPE" != "msys"* ]]; then # not Windows - . $HOME/.cargo/env -fi +. $HOME/.cargo/env cargo install cbindgen # Setup Poetry echo "Installing poetry" From d5eca269569a8c001b84e7bd58bfd13d68ecce11 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Sun, 18 Aug 2024 04:57:01 +0000 Subject: [PATCH 12/12] fix(CI): fix Windows build for finding the `cargo` executable --- setup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.sh b/setup.sh index e8467798..ed938c74 100755 --- a/setup.sh +++ b/setup.sh @@ -34,15 +34,15 @@ fi # Install rust compiler echo "Installing rust compiler" curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain 1.76 -. $HOME/.cargo/env -cargo install cbindgen +CARGO_BIN="$HOME/.cargo/bin/cargo" # also works for Windows. On Windows this equals to %USERPROFILE%\.cargo\bin\cargo +$CARGO_BIN install cbindgen # Setup Poetry echo "Installing poetry" curl -sSL https://install.python-poetry.org | python3 - --version "1.7.1" if [[ "$OSTYPE" == "msys"* ]]; then # Windows POETRY_BIN="$APPDATA/Python/Scripts/poetry" else - POETRY_BIN=`echo ~/.local/bin/poetry` # expand tilde + POETRY_BIN="$HOME/.local/bin/poetry" fi $POETRY_BIN self add 'poetry-dynamic-versioning[plugin]' echo "Done installing dependencies"