Skip to content

Commit 800747b

Browse files
authored
Fix the macOS 14 CI (#458)
fix(CI): failed to find an adequate linker on macOS 14 * 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 * The patch for using `install_name_tool` instead of `install-name-tool` is no longer needed
1 parent a5cdd79 commit 800747b

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

.github/workflows/test-and-publish.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ jobs:
8888
if: ${{ matrix.os == 'macos-13' && steps.cache-spidermonkey.outputs.cache-hit != 'true' }}
8989
# SpiderMonkey requires XCode SDK version at least 13.3
9090
run: sudo xcode-select -switch /Applications/Xcode_14.3.app
91+
- name: Setup LLVM
92+
if: ${{ (matrix.os == 'macos-13' || matrix.os == 'macos-14') && steps.cache-spidermonkey.outputs.cache-hit != 'true' }}
93+
run: |
94+
brew install llvm@15
95+
ln -s $(brew --prefix llvm@15)/bin/lld /usr/local/bin/lld
96+
ln -s $(brew --prefix llvm@15)/bin/ld64.lld /usr/local/bin/ld64.lld
97+
ld64.lld --version
9198
- name: Build spidermonkey
9299
if: ${{ steps.cache-spidermonkey.outputs.cache-hit != 'true' }}
93100
run: ./setup.sh

setup.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,12 @@ echo "Done downloading spidermonkey source code"
4949

5050
echo "Building spidermonkey"
5151
cd firefox-source
52+
53+
# Apply patching
5254
# making it work for both GNU and BSD (macOS) versions of sed
5355
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
5456
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
5557
sed -i'' -e '/"winheap.cpp"/d' ./memory/mozalloc/moz.build # https://bugzilla.mozilla.org/show_bug.cgi?id=1802675
56-
sed -i'' -e 's/"install-name-tool"/"install_name_tool"/' ./moz.configure # `install-name-tool` does not exist, but we have `install_name_tool`
5758
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
5859
sed -i'' -e 's/bool js::Unbox/JS_PUBLIC_API bool js::Unbox/g' ./js/src/vm/JSObject.cpp # same here
5960
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
@@ -63,6 +64,9 @@ sed -i'' -e 's/return JS::GetWeakRefsEnabled() == JS::WeakRefSpecifier::Disabled
6364
sed -i'' -e 's/return !IsIteratorHelpersEnabled()/return false/' ./js/src/vm/GlobalObject.cpp # forcibly enable iterator helpers
6465
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
6566
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`
67+
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
68+
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
69+
6670
cd js/src
6771
mkdir -p _build
6872
cd _build
@@ -74,19 +78,14 @@ mkdir -p ../../../../_spidermonkey_install/
7478
--disable-debug-symbols \
7579
--disable-jemalloc \
7680
--disable-tests \
81+
$(if [[ "$OSTYPE" == "darwin"* ]]; then echo "--enable-linker=ld64"; fi) \
7782
--enable-optimize
7883
make -j$CPUS
7984
echo "Done building spidermonkey"
8085

8186
echo "Installing spidermonkey"
8287
# install to ../../../../_spidermonkey_install/
8388
make install
84-
if [[ "$OSTYPE" == "darwin"* ]]; then # macOS
85-
cd ../../../../_spidermonkey_install/lib/
86-
# Set the `install_name` field to use RPATH instead of an absolute path
87-
# overrides https://hg.mozilla.org/releases/mozilla-esr102/file/89d799cb/js/src/build/Makefile.in#l83
88-
install_name_tool -id @rpath/$(basename ./libmozjs*) ./libmozjs* # making it work for whatever name the libmozjs dylib is called
89-
fi
9089
echo "Done installing spidermonkey"
9190

9291
# if this is being ran in the root directory of the PythonMonkey repo, then include dev configurations

0 commit comments

Comments
 (0)