Skip to content

Commit 3678a0a

Browse files
authored
Bump spidermonkey (#6)
* Bump spidermonkey to the version included with firefox 107 * Update the build script to use mach for everything, instead of autospider.py * Remove the call to apt-get update from the build-engine.sh script
1 parent 3e87caf commit 3678a0a

File tree

5 files changed

+92
-48
lines changed

5 files changed

+92
-48
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
if: steps.sm-cache.outputs.cache-hit != 'true'
3131
run: |
3232
mkdir dist
33+
sudo apt-get update -y
3334
bash ./build-engine.sh release
3435
tar -a -cf dist/spidermonkey-wasm-static-lib_release.tar.gz release
3536
rm -rf release obj-release

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
/release
55
/debug
66
/dist
7+
/mozconfig-*
78
.DS_Store
89
.vscode

build-engine.sh

Lines changed: 80 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,110 @@
11
#!/usr/bin/env bash
2-
set -ex
2+
3+
set -euo pipefail
4+
set -x
35

46
working_dir="$(pwd)"
57
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
68

7-
# Ensure apt-get is current, because otherwise bootstrapping might fail
8-
sudo apt-get update -y
9+
mode="${1:-release}"
10+
mozconfig="${working_dir}/mozconfig-${mode}"
11+
objdir="obj-$mode"
12+
outdir="$mode"
13+
14+
cat << EOF > "$mozconfig"
15+
ac_add_options --enable-project=js
16+
ac_add_options --enable-application=js
17+
ac_add_options --target=wasm32-unknown-wasi
18+
ac_add_options --disable-stdcxx-compat
19+
ac_add_options --without-system-zlib
20+
ac_add_options --without-intl-api
21+
ac_add_options --disable-jit
22+
ac_add_options --disable-shared-js
23+
ac_add_options --disable-shared-memory
24+
ac_add_options --disable-tests
25+
ac_add_options --disable-clang-plugin
26+
ac_add_options --enable-jitspew
27+
ac_add_options --enable-optimize
28+
ac_add_options --enable-js-streams
29+
ac_add_options --prefix=${working_dir}/${objdir}/dist
30+
mk_add_options MOZ_OBJDIR=${working_dir}/${objdir}
31+
EOF
32+
33+
case "$mode" in
34+
release)
35+
echo "ac_add_options --disable-debug" >> "$mozconfig"
36+
;;
37+
38+
debug)
39+
echo "ac_add_options --enable-debug" >> "$mozconfig"
40+
;;
41+
42+
*)
43+
echo "Unknown build type: $mode"
44+
exit 1
45+
;;
46+
esac
47+
948

1049
# Ensure the Rust version matches that used by Gecko, and can compile to WASI
11-
rustup update 1.57.0
12-
rustup default 1.57.0
1350
rustup target add wasm32-wasi
1451

15-
if [[ ! -a gecko-dev ]]
16-
then
52+
fetch_commits=
53+
if [[ ! -a gecko-dev ]]; then
1754

1855
# Clone Gecko repository at the required revision
1956
mkdir gecko-dev
20-
cd gecko-dev
2157

22-
git init
23-
git remote add --no-tags -t wasi-embedding origin $(cat $script_dir/gecko-repository)
24-
cd ..
58+
git -C gecko-dev init
59+
git -C gecko-dev remote add --no-tags -t wasi-embedding \
60+
origin "$(cat "$script_dir/gecko-repository")"
61+
62+
fetch_commits=1
2563
fi
2664

27-
cd gecko-dev
28-
git fetch --depth 1 origin $(cat $script_dir/gecko-revision)
29-
git checkout FETCH_HEAD
65+
target_rev="$(cat "$script_dir/gecko-revision")"
66+
if [[ -n "$fetch_commits" ]] || \
67+
[[ "$(git -C gecko-dev rev-parse HEAD)" != "$target_rev" ]]; then
68+
git -C gecko-dev fetch --depth 1 origin "$target_rev"
69+
git -C gecko-dev checkout FETCH_HEAD
70+
fi
3071

31-
# Use Gecko's build system bootstrapping to ensure all dependencies are installed
32-
./mach bootstrap --application-choice=js
72+
# Use Gecko's build system bootstrapping to ensure all dependencies are
73+
# installed
74+
cd gecko-dev
75+
./mach --no-interactive bootstrap --application-choice=js --no-system-changes
3376

34-
# ... except, that doesn't install the wasi-sysroot, which we need, so we do that manually.
77+
# ... except, that doesn't install the wasi-sysroot, which we need, so we do
78+
# that manually.
3579
cd ~/.mozbuild
3680
python3 \
37-
${working_dir}/gecko-dev/mach \
81+
"${working_dir}/gecko-dev/mach" \
82+
--no-interactive \
3883
artifact \
3984
toolchain \
4085
--bootstrap \
4186
--from-build \
4287
sysroot-wasm32-wasi
4388

44-
cd ${working_dir}
45-
46-
mode="release"
47-
flags="--optimize --no-debug --build-only"
48-
if [[ $1 == 'debug' ]]
49-
then
50-
mode="debug"
51-
flags="--optimize --debug"
52-
fi
53-
rust_lib_dir=$mode
54-
objdir=obj-$mode
55-
outdir=$mode
56-
57-
echo $flags $rust_lib_dir
89+
cd "$working_dir"
5890

5991
# Build SpiderMonkey for WASI
60-
MOZ_FETCHES_DIR=~/.mozbuild CC=~/.mozbuild/clang/bin/clang gecko-dev/js/src/devtools/automation/autospider.py --objdir=$objdir $flags wasi
92+
MOZCONFIG="${mozconfig}" \
93+
MOZ_FETCHES_DIR=~/.mozbuild \
94+
CC=~/.mozbuild/clang/bin/clang \
95+
python3 "${working_dir}/gecko-dev/mach" \
96+
--no-interactive \
97+
build
6198

6299
# Copy header, object, and static lib files
63-
rm -rf $outdir
64-
mkdir -p $outdir/lib
100+
rm -rf "$outdir"
101+
mkdir -p "$outdir/lib"
102+
103+
cd "$objdir"
104+
cp -Lr dist/include "../$outdir"
105+
106+
while read -r file; do
107+
cp "$file" "../$outdir/lib"
108+
done < "$script_dir/object-files.list"
65109

66-
cd $objdir
67-
cp -Lr dist/include ../$outdir
68-
cp $(cat $script_dir/object-files.list) ../$outdir/lib
69-
cp js/src/build/libjs_static.a wasm32-wasi/${rust_lib_dir}/libjsrust.a ../$outdir/lib
110+
cp js/src/build/libjs_static.a "wasm32-wasi/${mode}/libjsrust.a" "../$outdir/lib"

download-engine.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
#!/usr/bin/env bash
2-
set -e
2+
3+
set -euo pipefail
34

45
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
56

67
# # Get github repository url
7-
gh_url='https://github.'$(cd $script_dir && git remote get-url origin | cut -f2 -d. | tr ':' /)
8+
gh_url='https://github.'$(cd "$script_dir" && git remote get-url origin | cut -f2 -d. | tr ':' /)
89

910
mode="release"
1011
if [[ $1 == "debug" ]]
1112
then
1213
mode="debug"
1314
fi
1415

15-
git_rev=`cd $script_dir && git rev-parse HEAD`
16-
file=spidermonkey-wasm-static-lib_${mode}.tar.gz
17-
bundle_url=${gh_url}/releases/download/rev_${git_rev}/${file}
16+
git_rev="$(git -C "$script_dir" rev-parse HEAD)"
17+
file="spidermonkey-wasm-static-lib_${mode}.tar.gz"
18+
bundle_url="${gh_url}/releases/download/rev_${git_rev}/${file}"
1819

19-
curl --fail -L -O $bundle_url
20-
tar xf $file
21-
rm $file
20+
curl --fail -L -O "$bundle_url"
21+
tar xf "$file"
22+
rm "$file"

gecko-revision

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
885df10c4eea15d6fed25d476c895ad3aafc248f
1+
a0083bb748d3d416d9085e144d2359519e96e2d9

0 commit comments

Comments
 (0)