Spidermonkey build: cherry-pick an upstream commit to create thin archives

This saves a sizeable amount of disk space during the build, by not creating
a very large libjs_static.a (~1.5 GB) that contains a copy of all the symbols
in the object files generated during the build.

Upstream bug: https://bugzilla.mozilla.org/show_bug.cgi?id=2008085
Upstream commit: https://hg.mozilla.org/mozilla-central/rev/a924182c4e55

Note that the upstream commit doesn't apply cleanly to Spidermonkey 128.13.0,
it had to be rebased.
This commit is contained in:
Olivier Tilloy 2026-01-21 13:14:41 +01:00 committed by Ralph Sennhauser
parent 13453a3c7b
commit 6436ba3af9
3 changed files with 71 additions and 1 deletions

View file

@ -9,7 +9,7 @@ cd "$(dirname "$0")"
PV=128.13.0
FOLDER="mozjs-${PV}"
# If same-version changes are needed, increment this.
LIB_VERSION="${PV}+wfg4"
LIB_VERSION="${PV}+wfg5"
LIB_NAME="mozjs128"
build_archive()
@ -100,6 +100,12 @@ rm -Rf "${FOLDER}"
# Do not let mach install tools in the user's home, create a disposable folder
export MOZBUILD_STATE_PATH="${MOZBUILD_STATE_PATH:=$(pwd)/mozbuild-state}"
if [ "${OS}" != "Darwin" ]; then
# Make thin archives to save disk space
# The AR_FLAGS customization point is provided and honored by mach
export AR_FLAGS="--thin"
fi
if [ -n "$PROFILE" ]; then
CONF_OPTS="$CONF_OPTS
--enable-profiling

View file

@ -0,0 +1,61 @@
# HG changeset patch
# User serge-sans-paille <sguelton@mozilla.com>
# Date 1768903043 0
# Node ID a924182c4e55e19b1b8dbd5904e8f9ca99e79b98
# Parent cd5449e09b6cd3e3b0bb1f2d6d8a8048e8883535
Bug 2008085 - Provide AR_FLAGS customization point r=glandium
In a similar way to other customization flags.
That way users can specify `--thin` if they want to to reduce disk
pressure.
Differential Revision: https://phabricator.services.mozilla.com/D278841
diff --git a/build/moz.configure/toolchain.configure b/build/moz.configure/toolchain.configure
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -4,6 +4,13 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+option(
+ env="AR_FLAGS",
+ help="Extra flags for creating static archives",
+ nargs=1,
+ default="",
+)
+
# Code optimization
# ==============================================================
@@ -3346,12 +3353,14 @@
if not toolchain_prefix:
toolchain_prefix = dependable(None)
- @depends(toolchain_prefix, c_compiler)
- def ar_config(toolchain_prefix, c_compiler):
+ @depends(toolchain_prefix, c_compiler, "AR_FLAGS")
+ @imports(_from="mozbuild.shellutil", _import="split")
+ def ar_config(toolchain_prefix, c_compiler, env_flags):
+ extra_ar_flags = tuple(split(env_flags[0]))
if c_compiler.type == "clang-cl":
return namespace(
names=("llvm-lib",),
- flags=("-llvmlibthin", "-out:$@"),
+ flags=("-llvmlibthin", "-out:$@") + extra_ar_flags,
)
names = tuple("%s%s" % (p, "ar") for p in (toolchain_prefix or ()) + ("",))
@@ -3368,7 +3377,7 @@
return namespace(
names=names,
- flags=("crs", "$@"),
+ flags=("crs",) + extra_ar_flags + ("$@",),
)
return ar_config

View file

@ -47,3 +47,6 @@ patch -p1 <"${PATCHES}"/SuppressDanglingPointerWarning.patch
# Fix building with python 3.14
patch -p1 <"${PATCHES}"/FixPython3_14.diff
# Cherry-pick an upstream commit to allow passing custom flags to ar
patch -p1 <"${PATCHES}"/UpstreamCustomARFlags.patch