From b6c3fbadf635bbcded51d5da9d06656fe8a6c929 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Fri, 29 Nov 2024 22:15:23 +0000 Subject: [PATCH 01/24] fix(CI): failed to find an adequate linker --- .github/workflows/test-and-publish.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test-and-publish.yaml b/.github/workflows/test-and-publish.yaml index cccd0aa0..dfbef4b3 100644 --- a/.github/workflows/test-and-publish.yaml +++ b/.github/workflows/test-and-publish.yaml @@ -88,6 +88,9 @@ jobs: if: ${{ matrix.os == 'macos-13' && steps.cache-spidermonkey.outputs.cache-hit != 'true' }} # SpiderMonkey requires XCode SDK version at least 13.3 run: sudo xcode-select -switch /Applications/Xcode_14.3.app + - name: Setup XCode + if: ${{ matrix.os == 'macos-14' && steps.cache-spidermonkey.outputs.cache-hit != 'true' }} + run: sudo xcode-select -switch /Applications/Xcode_15.0.app - name: Build spidermonkey if: ${{ steps.cache-spidermonkey.outputs.cache-hit != 'true' }} run: ./setup.sh From 0d9cedb9a66caf78a9ed75aa7ff6b3e0ab33e0c2 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Fri, 29 Nov 2024 22:26:06 +0000 Subject: [PATCH 02/24] test --- .github/workflows/test-and-publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-and-publish.yaml b/.github/workflows/test-and-publish.yaml index dfbef4b3..7fa9b9c7 100644 --- a/.github/workflows/test-and-publish.yaml +++ b/.github/workflows/test-and-publish.yaml @@ -90,7 +90,7 @@ jobs: run: sudo xcode-select -switch /Applications/Xcode_14.3.app - name: Setup XCode if: ${{ matrix.os == 'macos-14' && steps.cache-spidermonkey.outputs.cache-hit != 'true' }} - run: sudo xcode-select -switch /Applications/Xcode_15.0.app + run: sudo xcode-select -switch /Applications/Xcode_16.1.app - name: Build spidermonkey if: ${{ steps.cache-spidermonkey.outputs.cache-hit != 'true' }} run: ./setup.sh From 3ac3c595df2eaf80dd42f3c513b64aa1b0aefc32 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Fri, 29 Nov 2024 22:55:00 +0000 Subject: [PATCH 03/24] fix(CI): always use ld64 for the linker on macOS --- setup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.sh b/setup.sh index bbe1b272..578e4cf7 100755 --- a/setup.sh +++ b/setup.sh @@ -63,6 +63,7 @@ sed -i'' -e 's/return JS::GetWeakRefsEnabled() == JS::WeakRefSpecifier::Disabled sed -i'' -e 's/return !IsIteratorHelpersEnabled()/return false/' ./js/src/vm/GlobalObject.cpp # forcibly enable iterator helpers 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 -E -i'' -e 's/target.kernel == "Darwin"$/False/' ./build/moz.configure/toolchain.configure # always use ld64 for the linker on macOS because lld is not available in the CI machine cd js/src mkdir -p _build cd _build From b0f0f9b15011297c18d4589a6050f450f61b6e96 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Fri, 29 Nov 2024 23:18:54 +0000 Subject: [PATCH 04/24] fix(CI): always use ld64 for the linker on macOS because lld is not available in the CI machine See also: https://searchfox.org/mozilla-central/rev/e741c34/build/moz.configure/toolchain.configure#1889 --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 578e4cf7..7a059f83 100755 --- a/setup.sh +++ b/setup.sh @@ -63,7 +63,6 @@ sed -i'' -e 's/return JS::GetWeakRefsEnabled() == JS::WeakRefSpecifier::Disabled sed -i'' -e 's/return !IsIteratorHelpersEnabled()/return false/' ./js/src/vm/GlobalObject.cpp # forcibly enable iterator helpers 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 -E -i'' -e 's/target.kernel == "Darwin"$/False/' ./build/moz.configure/toolchain.configure # always use ld64 for the linker on macOS because lld is not available in the CI machine cd js/src mkdir -p _build cd _build @@ -75,6 +74,7 @@ mkdir -p ../../../../_spidermonkey_install/ --disable-debug-symbols \ --disable-jemalloc \ --disable-tests \ + $(if [[ "$OSTYPE" == "darwin"* ]]; then echo "--enable-linker=ld64"; fi) \ --enable-optimize make -j$CPUS echo "Done building spidermonkey" From 67d6a9efa62bc659dd9bedc443a1ebb21000879a Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Fri, 29 Nov 2024 23:30:29 +0000 Subject: [PATCH 05/24] test --- .github/workflows/test-and-publish.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/test-and-publish.yaml b/.github/workflows/test-and-publish.yaml index 7fa9b9c7..cccd0aa0 100644 --- a/.github/workflows/test-and-publish.yaml +++ b/.github/workflows/test-and-publish.yaml @@ -88,9 +88,6 @@ jobs: if: ${{ matrix.os == 'macos-13' && steps.cache-spidermonkey.outputs.cache-hit != 'true' }} # SpiderMonkey requires XCode SDK version at least 13.3 run: sudo xcode-select -switch /Applications/Xcode_14.3.app - - name: Setup XCode - if: ${{ matrix.os == 'macos-14' && steps.cache-spidermonkey.outputs.cache-hit != 'true' }} - run: sudo xcode-select -switch /Applications/Xcode_16.1.app - name: Build spidermonkey if: ${{ steps.cache-spidermonkey.outputs.cache-hit != 'true' }} run: ./setup.sh From c6ecce98d852895487ccbd1740d5eeef8f3e6bf7 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Fri, 29 Nov 2024 23:44:11 +0000 Subject: [PATCH 06/24] test --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 7a059f83..6c9f9b5e 100755 --- a/setup.sh +++ b/setup.sh @@ -18,6 +18,7 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then # Linux elif [[ "$OSTYPE" == "darwin"* ]]; then # macOS brew update || true # allow failure brew install cmake pkg-config wget unzip coreutils # `coreutils` installs the `realpath` command + brew install lld elif [[ "$OSTYPE" == "msys"* ]]; then # Windows echo "Dependencies are not going to be installed automatically on Windows." else @@ -74,7 +75,6 @@ mkdir -p ../../../../_spidermonkey_install/ --disable-debug-symbols \ --disable-jemalloc \ --disable-tests \ - $(if [[ "$OSTYPE" == "darwin"* ]]; then echo "--enable-linker=ld64"; fi) \ --enable-optimize make -j$CPUS echo "Done building spidermonkey" From b18d3507c6f1002378221f9e1196824922e05e6d Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Sat, 30 Nov 2024 06:59:27 +0000 Subject: [PATCH 07/24] test --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 6c9f9b5e..9ae5bc60 100755 --- a/setup.sh +++ b/setup.sh @@ -18,7 +18,7 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then # Linux elif [[ "$OSTYPE" == "darwin"* ]]; then # macOS brew update || true # allow failure brew install cmake pkg-config wget unzip coreutils # `coreutils` installs the `realpath` command - brew install lld + brew install llvm@14 elif [[ "$OSTYPE" == "msys"* ]]; then # Windows echo "Dependencies are not going to be installed automatically on Windows." else From ba6926d07d22fb64fa0189243885939d0c2abba5 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Sat, 30 Nov 2024 07:23:27 +0000 Subject: [PATCH 08/24] test --- setup.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 9ae5bc60..eff45d14 100755 --- a/setup.sh +++ b/setup.sh @@ -18,7 +18,7 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then # Linux elif [[ "$OSTYPE" == "darwin"* ]]; then # macOS brew update || true # allow failure brew install cmake pkg-config wget unzip coreutils # `coreutils` installs the `realpath` command - brew install llvm@14 + brew install llvm@15 elif [[ "$OSTYPE" == "msys"* ]]; then # Windows echo "Dependencies are not going to be installed automatically on Windows." else @@ -68,6 +68,7 @@ cd js/src mkdir -p _build cd _build mkdir -p ../../../../_spidermonkey_install/ +$(if [[ "$OSTYPE" == "darwin"* ]]; then echo "LD=$(brew --prefix llvm@15)/bin/lld HOST_LD=$(brew --prefix llvm@15)/bin/lld"; fi) \ ../configure --target=$(clang --print-target-triple) \ --prefix=$(realpath $PWD/../../../../_spidermonkey_install) \ --with-intl-api \ From f9fc207225b902f0c97530f9f2a5d58342c2f568 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Sat, 30 Nov 2024 07:51:57 +0000 Subject: [PATCH 09/24] test --- setup.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.sh b/setup.sh index eff45d14..2786c12f 100755 --- a/setup.sh +++ b/setup.sh @@ -54,7 +54,6 @@ cd firefox-source 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/"install-name-tool"/"install_name_tool"/' ./moz.configure # `install-name-tool` does not exist, but we have `install_name_tool` 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 @@ -68,9 +67,9 @@ cd js/src mkdir -p _build cd _build mkdir -p ../../../../_spidermonkey_install/ -$(if [[ "$OSTYPE" == "darwin"* ]]; then echo "LD=$(brew --prefix llvm@15)/bin/lld HOST_LD=$(brew --prefix llvm@15)/bin/lld"; fi) \ ../configure --target=$(clang --print-target-triple) \ --prefix=$(realpath $PWD/../../../../_spidermonkey_install) \ + $(if [[ "$OSTYPE" == "darwin"* ]]; then echo "--with-toolchain-prefix=$(brew --prefix llvm@15)/bin/"; fi) \ --with-intl-api \ $(if [[ "$OSTYPE" != "msys"* ]]; then echo "--without-system-zlib"; fi) \ --disable-debug-symbols \ From 85511d54de412af3386e839bb914e2c8e624599d Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Sat, 30 Nov 2024 08:43:13 +0000 Subject: [PATCH 10/24] test --- setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.sh b/setup.sh index 2786c12f..5a89081b 100755 --- a/setup.sh +++ b/setup.sh @@ -18,7 +18,7 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then # Linux elif [[ "$OSTYPE" == "darwin"* ]]; then # macOS brew update || true # allow failure brew install cmake pkg-config wget unzip coreutils # `coreutils` installs the `realpath` command - brew install llvm@15 + brew install lld elif [[ "$OSTYPE" == "msys"* ]]; then # Windows echo "Dependencies are not going to be installed automatically on Windows." else @@ -69,7 +69,7 @@ cd _build mkdir -p ../../../../_spidermonkey_install/ ../configure --target=$(clang --print-target-triple) \ --prefix=$(realpath $PWD/../../../../_spidermonkey_install) \ - $(if [[ "$OSTYPE" == "darwin"* ]]; then echo "--with-toolchain-prefix=$(brew --prefix llvm@15)/bin/"; fi) \ + $(if [[ "$OSTYPE" == "darwin"* ]]; then echo "--with-toolchain-prefix=$(brew --prefix llvm)/bin/"; fi) \ --with-intl-api \ $(if [[ "$OSTYPE" != "msys"* ]]; then echo "--without-system-zlib"; fi) \ --disable-debug-symbols \ From 612b800e7a2bdc7658fd9b063ff14c743cccf3d7 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Mon, 2 Dec 2024 04:59:09 +0000 Subject: [PATCH 11/24] Revert "test" This reverts commit 85511d54de412af3386e839bb914e2c8e624599d. --- setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.sh b/setup.sh index 5a89081b..2786c12f 100755 --- a/setup.sh +++ b/setup.sh @@ -18,7 +18,7 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then # Linux elif [[ "$OSTYPE" == "darwin"* ]]; then # macOS brew update || true # allow failure brew install cmake pkg-config wget unzip coreutils # `coreutils` installs the `realpath` command - brew install lld + brew install llvm@15 elif [[ "$OSTYPE" == "msys"* ]]; then # Windows echo "Dependencies are not going to be installed automatically on Windows." else @@ -69,7 +69,7 @@ cd _build mkdir -p ../../../../_spidermonkey_install/ ../configure --target=$(clang --print-target-triple) \ --prefix=$(realpath $PWD/../../../../_spidermonkey_install) \ - $(if [[ "$OSTYPE" == "darwin"* ]]; then echo "--with-toolchain-prefix=$(brew --prefix llvm)/bin/"; fi) \ + $(if [[ "$OSTYPE" == "darwin"* ]]; then echo "--with-toolchain-prefix=$(brew --prefix llvm@15)/bin/"; fi) \ --with-intl-api \ $(if [[ "$OSTYPE" != "msys"* ]]; then echo "--without-system-zlib"; fi) \ --disable-debug-symbols \ From ac41e4ffc97e70cff9326fb3d4ecf89d9fba20c2 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Mon, 2 Dec 2024 04:59:29 +0000 Subject: [PATCH 12/24] test2 --- setup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.sh b/setup.sh index 2786c12f..9fa812e5 100755 --- a/setup.sh +++ b/setup.sh @@ -19,6 +19,7 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then # macOS brew update || true # allow failure brew install cmake pkg-config wget unzip coreutils # `coreutils` installs the `realpath` command brew install llvm@15 + brew install lld elif [[ "$OSTYPE" == "msys"* ]]; then # Windows echo "Dependencies are not going to be installed automatically on Windows." else From 9a8b26ef99a707bb996e450fd1f54889025113dd Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Mon, 2 Dec 2024 08:13:07 +0000 Subject: [PATCH 13/24] test 3 --- .github/workflows/test-and-publish.yaml | 9 +++++++++ setup.sh | 2 -- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-and-publish.yaml b/.github/workflows/test-and-publish.yaml index cccd0aa0..dc8131db 100644 --- a/.github/workflows/test-and-publish.yaml +++ b/.github/workflows/test-and-publish.yaml @@ -88,6 +88,15 @@ jobs: if: ${{ matrix.os == 'macos-13' && steps.cache-spidermonkey.outputs.cache-hit != 'true' }} # SpiderMonkey requires XCode SDK version at least 13.3 run: sudo xcode-select -switch /Applications/Xcode_14.3.app + - name: Setup LLVM + if: ${{ (matrix.os == 'macos-13' || matrix.os == 'macos-14') && steps.cache-spidermonkey.outputs.cache-hit != 'true' }} + run: | + brew install llvm@15 + ln -s $(brew --prefix llvm@15)/bin/lld /usr/local/bin/lld + ln -s $(brew --prefix llvm@15)/bin/ld64.lld /usr/local/bin/ld64.lld + ln -s $(brew --prefix llvm@15)/bin/llvm-install-name-tool /usr/local/bin/llvm-install-name-tool + ld64.lld --version + llvm-install-name-tool --version - name: Build spidermonkey if: ${{ steps.cache-spidermonkey.outputs.cache-hit != 'true' }} run: ./setup.sh diff --git a/setup.sh b/setup.sh index 9fa812e5..4d054886 100755 --- a/setup.sh +++ b/setup.sh @@ -18,8 +18,6 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then # Linux elif [[ "$OSTYPE" == "darwin"* ]]; then # macOS brew update || true # allow failure brew install cmake pkg-config wget unzip coreutils # `coreutils` installs the `realpath` command - brew install llvm@15 - brew install lld elif [[ "$OSTYPE" == "msys"* ]]; then # Windows echo "Dependencies are not going to be installed automatically on Windows." else From 9959f61eb6213d0574d3f16b732e342f68ba3d02 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Mon, 2 Dec 2024 08:39:05 +0000 Subject: [PATCH 14/24] test 3a --- setup.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.sh b/setup.sh index 4d054886..f8ef5792 100755 --- a/setup.sh +++ b/setup.sh @@ -68,7 +68,6 @@ cd _build mkdir -p ../../../../_spidermonkey_install/ ../configure --target=$(clang --print-target-triple) \ --prefix=$(realpath $PWD/../../../../_spidermonkey_install) \ - $(if [[ "$OSTYPE" == "darwin"* ]]; then echo "--with-toolchain-prefix=$(brew --prefix llvm@15)/bin/"; fi) \ --with-intl-api \ $(if [[ "$OSTYPE" != "msys"* ]]; then echo "--without-system-zlib"; fi) \ --disable-debug-symbols \ @@ -85,7 +84,7 @@ if [[ "$OSTYPE" == "darwin"* ]]; then # macOS cd ../../../../_spidermonkey_install/lib/ # Set the `install_name` field to use RPATH instead of an absolute path # overrides https://hg.mozilla.org/releases/mozilla-esr102/file/89d799cb/js/src/build/Makefile.in#l83 - install_name_tool -id @rpath/$(basename ./libmozjs*) ./libmozjs* # making it work for whatever name the libmozjs dylib is called + llvm-install-name-tool -id @rpath/$(basename ./libmozjs*) ./libmozjs* # making it work for whatever name the libmozjs dylib is called fi echo "Done installing spidermonkey" From 07c4544d32156d17a555dd33fc2bf2fdbaeaedf0 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Mon, 2 Dec 2024 09:23:09 +0000 Subject: [PATCH 15/24] test 5 --- setup.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/setup.sh b/setup.sh index f8ef5792..b4aa3228 100755 --- a/setup.sh +++ b/setup.sh @@ -62,6 +62,7 @@ sed -i'' -e 's/return JS::GetWeakRefsEnabled() == JS::WeakRefSpecifier::Disabled sed -i'' -e 's/return !IsIteratorHelpersEnabled()/return false/' ./js/src/vm/GlobalObject.cpp # forcibly enable iterator helpers 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|-id $(abspath $(libdir)|-id $(abspath @rpath|' ./js/src/build/Makefile.in # Set the `install_name` field to use RPATH instead of an absolute path cd js/src mkdir -p _build cd _build @@ -80,12 +81,12 @@ echo "Done building spidermonkey" echo "Installing spidermonkey" # install to ../../../../_spidermonkey_install/ make install -if [[ "$OSTYPE" == "darwin"* ]]; then # macOS - cd ../../../../_spidermonkey_install/lib/ - # Set the `install_name` field to use RPATH instead of an absolute path - # overrides https://hg.mozilla.org/releases/mozilla-esr102/file/89d799cb/js/src/build/Makefile.in#l83 - llvm-install-name-tool -id @rpath/$(basename ./libmozjs*) ./libmozjs* # making it work for whatever name the libmozjs dylib is called -fi +# if [[ "$OSTYPE" == "darwin"* ]]; then # macOS +# cd ../../../../_spidermonkey_install/lib/ +# # Set the `install_name` field to use RPATH instead of an absolute path +# # overrides https://hg.mozilla.org/releases/mozilla-esr102/file/89d799cb/js/src/build/Makefile.in#l83 +# llvm-install-name-tool -id @rpath/$(basename ./libmozjs*) ./libmozjs* # making it work for whatever name the libmozjs dylib is called +# fi echo "Done installing spidermonkey" # if this is being ran in the root directory of the PythonMonkey repo, then include dev configurations From ddde5c05b0bf5f6c95d3b00ca97981f62002a272 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Mon, 2 Dec 2024 09:46:58 +0000 Subject: [PATCH 16/24] fixup --- setup.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/setup.sh b/setup.sh index b4aa3228..047c7042 100755 --- a/setup.sh +++ b/setup.sh @@ -62,7 +62,7 @@ sed -i'' -e 's/return JS::GetWeakRefsEnabled() == JS::WeakRefSpecifier::Disabled sed -i'' -e 's/return !IsIteratorHelpersEnabled()/return false/' ./js/src/vm/GlobalObject.cpp # forcibly enable iterator helpers 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|-id $(abspath $(libdir)|-id $(abspath @rpath|' ./js/src/build/Makefile.in # Set the `install_name` field to use RPATH instead of an absolute path +sed -i'' -e 's|-id $(abspath $(libdir)|-id $(abspath @rpath|' ./js/src/build/Makefile.in # Set the `install_name` field of libmozjs dylib to use the RPATH instead of an absolute path cd js/src mkdir -p _build cd _build @@ -81,12 +81,6 @@ echo "Done building spidermonkey" echo "Installing spidermonkey" # install to ../../../../_spidermonkey_install/ make install -# if [[ "$OSTYPE" == "darwin"* ]]; then # macOS -# cd ../../../../_spidermonkey_install/lib/ -# # Set the `install_name` field to use RPATH instead of an absolute path -# # overrides https://hg.mozilla.org/releases/mozilla-esr102/file/89d799cb/js/src/build/Makefile.in#l83 -# llvm-install-name-tool -id @rpath/$(basename ./libmozjs*) ./libmozjs* # making it work for whatever name the libmozjs dylib is called -# fi echo "Done installing spidermonkey" # if this is being ran in the root directory of the PythonMonkey repo, then include dev configurations From 7df8b9345a0e4fca63e98c68d235a1afe495e4f2 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Mon, 2 Dec 2024 09:53:51 +0000 Subject: [PATCH 17/24] fix ld --- .github/workflows/test-and-publish.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/test-and-publish.yaml b/.github/workflows/test-and-publish.yaml index dc8131db..e4fb0884 100644 --- a/.github/workflows/test-and-publish.yaml +++ b/.github/workflows/test-and-publish.yaml @@ -177,6 +177,13 @@ jobs: echo "Installed Dependencies" env: PYTHON_VERSION: ${{ matrix.python_version }} + - name: Setup LLVM + if: ${{ matrix.os == 'macos-13' || matrix.os == 'macos-14' }} + run: | + brew install llvm@15 + ln -s $(brew --prefix llvm@15)/bin/lld /usr/local/bin/lld + ln -s $(brew --prefix llvm@15)/bin/ld64.lld /usr/local/bin/ld64.lld + ld64.lld --version - name: Build Docs # only build docs once if: ${{ matrix.os == 'ubuntu-20.04' && matrix.python_version == '3.11' }} run: | From 8d6f9d1ec894ac35abcdb2abd1fef4371000794f Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Mon, 2 Dec 2024 10:08:42 +0000 Subject: [PATCH 18/24] fix lld --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1577c299..bf9d3264 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,6 +91,7 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) set(PYTHONLIBS_VERSION_STRING ${Python_VERSION}) set(PYTHON_INCLUDE_DIR ${Python_INCLUDE_DIRS}) set(PYTHON_LIBRARIES ${Python_LIBRARIES}) + set(CMAKE_LINKER_TYPE "LLD") elseif(UNIX) find_package(Python 3.8 COMPONENTS Interpreter Development REQUIRED) set(Python_FIND_VIRTUALENV FIRST) # (require cmake >= v3.15 and this is the default) use the Python version configured by pyenv if available From 0ad66820778f5aaeeadfebcfa2ada3771c21a7f5 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Fri, 29 Nov 2024 23:18:54 +0000 Subject: [PATCH 19/24] fix(CI): always use ld64 for the linker on macOS because lld is not available in the CI machine See also: https://searchfox.org/mozilla-central/rev/e741c34/build/moz.configure/toolchain.configure#1889 --- setup.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/setup.sh b/setup.sh index 047c7042..032c7876 100755 --- a/setup.sh +++ b/setup.sh @@ -49,6 +49,8 @@ echo "Done downloading spidermonkey source code" echo "Building spidermonkey" 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 @@ -63,6 +65,8 @@ 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|-id $(abspath $(libdir)|-id $(abspath @rpath|' ./js/src/build/Makefile.in # Set the `install_name` field of libmozjs dylib to use the RPATH instead of an absolute path +sed -i'' -e 's/-fuse-ld=ld/-ld64/' ./build/moz.configure/toolchain.configure # the classic linker can be explicitly requested using the `-ld64` flag. See https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Linking + cd js/src mkdir -p _build cd _build @@ -74,6 +78,7 @@ mkdir -p ../../../../_spidermonkey_install/ --disable-debug-symbols \ --disable-jemalloc \ --disable-tests \ + $(if [[ "$OSTYPE" == "darwin"* ]]; then echo "--enable-linker=ld64"; fi) \ --enable-optimize make -j$CPUS echo "Done building spidermonkey" From 769f317933f5000d57a5c25bdd63aa04e7b9a71b Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Mon, 2 Dec 2024 10:39:00 +0000 Subject: [PATCH 20/24] remove lld --- .github/workflows/test-and-publish.yaml | 16 ---------------- CMakeLists.txt | 1 - 2 files changed, 17 deletions(-) diff --git a/.github/workflows/test-and-publish.yaml b/.github/workflows/test-and-publish.yaml index e4fb0884..cccd0aa0 100644 --- a/.github/workflows/test-and-publish.yaml +++ b/.github/workflows/test-and-publish.yaml @@ -88,15 +88,6 @@ jobs: if: ${{ matrix.os == 'macos-13' && steps.cache-spidermonkey.outputs.cache-hit != 'true' }} # SpiderMonkey requires XCode SDK version at least 13.3 run: sudo xcode-select -switch /Applications/Xcode_14.3.app - - name: Setup LLVM - if: ${{ (matrix.os == 'macos-13' || matrix.os == 'macos-14') && steps.cache-spidermonkey.outputs.cache-hit != 'true' }} - run: | - brew install llvm@15 - ln -s $(brew --prefix llvm@15)/bin/lld /usr/local/bin/lld - ln -s $(brew --prefix llvm@15)/bin/ld64.lld /usr/local/bin/ld64.lld - ln -s $(brew --prefix llvm@15)/bin/llvm-install-name-tool /usr/local/bin/llvm-install-name-tool - ld64.lld --version - llvm-install-name-tool --version - name: Build spidermonkey if: ${{ steps.cache-spidermonkey.outputs.cache-hit != 'true' }} run: ./setup.sh @@ -177,13 +168,6 @@ jobs: echo "Installed Dependencies" env: PYTHON_VERSION: ${{ matrix.python_version }} - - name: Setup LLVM - if: ${{ matrix.os == 'macos-13' || matrix.os == 'macos-14' }} - run: | - brew install llvm@15 - ln -s $(brew --prefix llvm@15)/bin/lld /usr/local/bin/lld - ln -s $(brew --prefix llvm@15)/bin/ld64.lld /usr/local/bin/ld64.lld - ld64.lld --version - name: Build Docs # only build docs once if: ${{ matrix.os == 'ubuntu-20.04' && matrix.python_version == '3.11' }} run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index bf9d3264..1577c299 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,7 +91,6 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) set(PYTHONLIBS_VERSION_STRING ${Python_VERSION}) set(PYTHON_INCLUDE_DIR ${Python_INCLUDE_DIRS}) set(PYTHON_LIBRARIES ${Python_LIBRARIES}) - set(CMAKE_LINKER_TYPE "LLD") elseif(UNIX) find_package(Python 3.8 COMPONENTS Interpreter Development REQUIRED) set(Python_FIND_VIRTUALENV FIRST) # (require cmake >= v3.15 and this is the default) use the Python version configured by pyenv if available From 99d4076eedd9a60ca989959a61676d7cb0436386 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Mon, 2 Dec 2024 10:48:22 +0000 Subject: [PATCH 21/24] fix ld64 linker --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 032c7876..3e8ae5e3 100755 --- a/setup.sh +++ b/setup.sh @@ -65,7 +65,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|-id $(abspath $(libdir)|-id $(abspath @rpath|' ./js/src/build/Makefile.in # Set the `install_name` field of libmozjs dylib to use the RPATH instead of an absolute path -sed -i'' -e 's/-fuse-ld=ld/-ld64/' ./build/moz.configure/toolchain.configure # the classic linker can be explicitly requested using the `-ld64` flag. See https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Linking +sed -i'' -e 's/"-fuse-ld=ld"/"-ld64" if c_compiler.version >= "15.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 cd js/src mkdir -p _build From a09aea88acb38e3d3b1a2c6122418006d9045387 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Mon, 2 Dec 2024 11:03:03 +0000 Subject: [PATCH 22/24] test --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 3e8ae5e3..9a7b20e6 100755 --- a/setup.sh +++ b/setup.sh @@ -65,7 +65,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|-id $(abspath $(libdir)|-id $(abspath @rpath|' ./js/src/build/Makefile.in # Set the `install_name` field of libmozjs dylib to use the RPATH instead of an absolute path -sed -i'' -e 's/"-fuse-ld=ld"/"-ld64" if c_compiler.version >= "15.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/"-fuse-ld=ld"/"-ld64" if True 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 cd js/src mkdir -p _build From 015ed97ca4f23e08ef9315d9a4753f6290b68e7c Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Mon, 2 Dec 2024 11:19:13 +0000 Subject: [PATCH 23/24] host linker should be lld --- .github/workflows/test-and-publish.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/test-and-publish.yaml b/.github/workflows/test-and-publish.yaml index cccd0aa0..0fcad267 100644 --- a/.github/workflows/test-and-publish.yaml +++ b/.github/workflows/test-and-publish.yaml @@ -88,6 +88,13 @@ jobs: if: ${{ matrix.os == 'macos-13' && steps.cache-spidermonkey.outputs.cache-hit != 'true' }} # SpiderMonkey requires XCode SDK version at least 13.3 run: sudo xcode-select -switch /Applications/Xcode_14.3.app + - name: Setup LLVM + if: ${{ (matrix.os == 'macos-13' || matrix.os == 'macos-14') && steps.cache-spidermonkey.outputs.cache-hit != 'true' }} + run: | + brew install llvm@15 + ln -s $(brew --prefix llvm@15)/bin/lld /usr/local/bin/lld + ln -s $(brew --prefix llvm@15)/bin/ld64.lld /usr/local/bin/ld64.lld + ld64.lld --version - name: Build spidermonkey if: ${{ steps.cache-spidermonkey.outputs.cache-hit != 'true' }} run: ./setup.sh From 770151e7d1f31cdff653ff68205db2a231695f4d Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Mon, 2 Dec 2024 11:21:07 +0000 Subject: [PATCH 24/24] c_compiler.version --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 9a7b20e6..fc3f38d8 100755 --- a/setup.sh +++ b/setup.sh @@ -65,7 +65,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|-id $(abspath $(libdir)|-id $(abspath @rpath|' ./js/src/build/Makefile.in # Set the `install_name` field of libmozjs dylib to use the RPATH instead of an absolute path -sed -i'' -e 's/"-fuse-ld=ld"/"-ld64" if True 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/"-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 cd js/src mkdir -p _build