Bug 1697929 - Make mach work in the spidermonkey release package r=firefox-build-system-reviewers,glandium
authorSteve Fink <sfink@mozilla.com>
Mon, 19 Apr 2021 14:21:43 +0000
changeset 576551 043a215fa9f1a19cb53e78f25e283124ade90a93
parent 576550 ea7ee8ec0172c60f3513ad6addb40af89f45a556
child 576552 00fce1d7c7853bb350dc771f23a216ca9622c7eb
push id38389
push userdluca@mozilla.com
push dateMon, 19 Apr 2021 22:16:26 +0000
treeherdermozilla-central@e2fb29057e4c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfirefox-build-system-reviewers, glandium
bugs1697929
milestone89.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1697929 - Make mach work in the spidermonkey release package r=firefox-build-system-reviewers,glandium Differential Revision: https://phabricator.services.mozilla.com/D108129
js/src/make-source-package.py
python/mozbuild/mozbuild/controller/clobber.py
taskcluster/scripts/builder/build-sm-package.sh
--- a/js/src/make-source-package.py
+++ b/js/src/make-source-package.py
@@ -108,18 +108,21 @@ print("    MOZJS_MAJOR_VERSION = {}".for
 print("    MOZJS_MINOR_VERSION = {}".format(minor_version))
 print("    MOZJS_PATCH_VERSION = {}".format(patch_version))
 print("    MOZJS_ALPHA = {}".format(alpha))
 print("")
 
 rsync_filter_list = """
 # Top-level config and build files
 
++ /aclocal.m4
++ /client.mk
 + /configure.py
 + /LICENSE
++ /mach
 + /Makefile.in
 + /moz.build
 + /moz.configure
 + /test.mozbuild
 + /.babel-eslint.rc.js
 + .eslintignore
 + .eslintrc.js
 + .flake8
@@ -154,36 +157,44 @@ rsync_filter_list = """
 + /mozglue/moz.build
 + /mozglue/static/**
 
 + /tools/rb/fix_stacks.py
 + /tools/fuzzing/moz.build
 + /tools/fuzzing/interface/**
 + /tools/fuzzing/registry/**
 + /tools/fuzzing/libfuzzer/**
++ /tools/fuzzing/*.mozbuild
 
 # Build system and dependencies
 
 + /Cargo.lock
 + /build/**
 + /config/**
 + /python/**
 
 + /.cargo/config.in
 
 - /third_party/python/gyp
 + /third_party/python/**
 + /third_party/rust/**
 
 + /layout/tools/reftest/reftest/**
 
++ /testing/mach_commands.py
 + /testing/moz.build
 + /testing/mozbase/**
 + /testing/performance/**
++ /testing/web-platform/*.ini
++ /testing/web-platform/*.py
++ /testing/web-platform/meta/streams/**
++ /testing/web-platform/mozilla/**
++ /testing/web-platform/tests/resources/**
 + /testing/web-platform/tests/streams/**
++ /testing/web-platform/tests/tools/**
 
 + /toolkit/crashreporter/tools/symbolstore.py
 + /toolkit/mozapps/installer/package-name.mk
 
 # SpiderMonkey itself
 
 + /js/src/**
 + /js/app.mozbuild
@@ -191,29 +202,57 @@ rsync_filter_list = """
 + /js/examples/**
 + /js/public/**
 
 + */
 - /**
 """
 
 INSTALL_CONTENT = """\
-Full build documentation for SpiderMonkey is hosted on MDN:
-  https://developer.mozilla.org/en-US/docs/SpiderMonkey/Build_Documentation
+Documentation for SpiderMonkey is available at:
+
+  https://spidermonkey.dev/
+
+In particular, it points to build documentation at
+
+  https://firefox-source-docs.mozilla.org/js/build.html
 
 Note that the libraries produced by the build system include symbols,
 causing the binaries to be extremely large. It is highly suggested that `strip`
 be run over the binaries before deploying them.
 
 Building with default options may be performed as follows:
-  cd js/src
-  mkdir obj
-  cd obj
-  ../configure
-  make # or mozmake on Windows
+
+  ./mach create-mach-environment
+  ./mach build
+
+This will produce a debug build (much more suitable for developing against the
+SpiderMonkey JSAPI). To produce an optimized build:
+
+  export MOZCONFIG=$(pwd)/mozconfig.opt
+  ./mach build
+
+You may edit the mozconfig and mozconfig.opt files to configure your own build
+appropriately.
+"""
+
+MOZCONFIG_DEBUG_CONTENT = """\
+ac_add_options --enable-application=js
+ac_add_options --enable-debug
+ac_add_options --enable-optimize
+ac_add_options --disable-jemalloc
+mk_add_options MOZ_OBJDIR=obj-debug
+"""
+
+MOZCONFIG_OPT_CONTENT = """\
+ac_add_options --enable-application=js
+ac_add_options --disable-debug
+ac_add_options --enable-optimize
+ac_add_options --disable-jemalloc
+mk_add_options MOZ_OBJDIR=obj-opt
 """
 
 README_CONTENT = """\
 This directory contains SpiderMonkey {major_version}.
 
 This release is based on a revision of Mozilla {major_version}:
   https://hg.mozilla.org/releases/
 The changes in the patches/ directory were applied.
@@ -353,40 +392,28 @@ def generate_configure():
                 str(src_old_configure_in_file),
             ],
             stdout=f,
             check=True,
             env=env,
         )
 
 
-def copy_install():
-    """Copy or create INSTALL."""
-
-    staging_install_file = staging_dir / "INSTALL"
-    target_install_file = target_dir / "INSTALL"
-
-    if staging_install_file.exists():
-        shutil.copy2(str(staging_install_file), str(target_install_file))
-    else:
-        with target_install_file.open("w") as f:
-            f.write(INSTALL_CONTENT)
+def copy_file(filename, content):
+    """Copy an existing file from the staging area, or create a new file
+    with the given contents if it does not exist."""
 
-
-def copy_readme():
-    """Copy or create README."""
+    staging_file = staging_dir / filename
+    target_file = target_dir / filename
 
-    staging_readme_file = staging_dir / "README"
-    target_readme_file = target_dir / "README"
-
-    if staging_readme_file.exists():
-        shutil.copy2(str(staging_readme_file), str(target_readme_file))
+    if staging_file.exists():
+        shutil.copy2(str(staging_file), str(target_file))
     else:
-        with target_readme_file.open("w") as f:
-            f.write(README_CONTENT)
+        with target_file.open("w") as f:
+            f.write(content)
 
 
 def copy_patches():
     """Copy patches dir, if it exists."""
 
     staging_patches_dir = staging_dir / "patches"
     top_patches_dir = topsrc_dir / "patches"
     target_patches_dir = target_dir / "patches"
@@ -408,18 +435,20 @@ def remove_python_cache():
 def stage():
     """Stage source tarball content."""
     logging.info("Staging source tarball in {}...".format(target_dir))
 
     create_target_dir()
     sync_files()
     copy_cargo_toml()
     generate_configure()
-    copy_install()
-    copy_readme()
+    copy_file("INSTALL", INSTALL_CONTENT)
+    copy_file("README", README_CONTENT)
+    copy_file("mozconfig", MOZCONFIG_DEBUG_CONTENT)
+    copy_file("mozconfig.opt", MOZCONFIG_OPT_CONTENT)
     copy_patches()
     remove_python_cache()
 
 
 def create_tar():
     """Roll the tarball."""
 
     logging.info("Packaging source tarball at {}...".format(package_file))
--- a/python/mozbuild/mozbuild/controller/clobber.py
+++ b/python/mozbuild/mozbuild/controller/clobber.py
@@ -60,27 +60,32 @@ class Clobberer(object):
         self.obj_clobber = os.path.join(topobjdir, "CLOBBER")
         if substs:
             self.substs = substs
         else:
             self.substs = dict()
 
         # Try looking for mozilla/CLOBBER, for comm-central
         if not os.path.isfile(self.src_clobber):
-            self.src_clobber = os.path.join(topsrcdir, "mozilla", "CLOBBER")
-
-        assert os.path.isfile(self.src_clobber)
+            comm_clobber = os.path.join(topsrcdir, "mozilla", "CLOBBER")
+            if os.path.isfile(comm_clobber):
+                self.src_clobber = comm_clobber
 
     def clobber_needed(self):
         """Returns a bool indicating whether a tree clobber is required."""
 
         # No object directory clobber file means we're good.
         if not os.path.exists(self.obj_clobber):
             return False
 
+        # No source directory clobber means we're running from a source package
+        # that doesn't use clobbering.
+        if not os.path.exists(self.src_clobber):
+            return False
+
         # Object directory clobber older than current is fine.
         if os.path.getmtime(self.src_clobber) <= os.path.getmtime(self.obj_clobber):
 
             return False
 
         return True
 
     def clobber_cause(self):
--- a/taskcluster/scripts/builder/build-sm-package.sh
+++ b/taskcluster/scripts/builder/build-sm-package.sh
@@ -20,27 +20,28 @@ pushd $PACKAGE_DIR
 
 tar -xvf $UPLOAD_DIR/mozjs-*.tar.*z*
 
 : ${PYTHON3:=python3}
 
 status=0
 (
     # Build the freshly extracted, packaged SpiderMonkey.
-    cd ./mozjs-*/js/src
+    cd ./mozjs-*
 
     # MOZ_AUTOMATION enforces certain requirements that don't apply to
     # packaged builds. Unset it.
     unset MOZ_AUTOMATION
     # Unsetting MOZ_AUTOMATION prevents this to be set automatically:
     export PATH="$MOZ_FETCHES_DIR/clang/bin:$PATH"
     export SYSROOT="$MOZ_FETCHES_DIR/sysroot"
     export RUSTC="$MOZ_FETCHES_DIR/rustc/bin/rustc"
     export CARGO="$MOZ_FETCHES_DIR/rustc/bin/cargo"
     export CBINDGEN="$MOZ_FETCHES_DIR/cbindgen/cbindgen"
 
-    AUTOMATION=1 $PYTHON3 ./devtools/automation/autospider.py --skip-tests=checks $SPIDERMONKEY_VARIANT
+    ./mach create-mach-environment
+    AUTOMATION=1 $PYTHON3 js/src/devtools/automation/autospider.py --skip-tests=checks $SPIDERMONKEY_VARIANT
 ) || status=$?
 
 # Copy artifacts for upload by TaskCluster
 cp -rL ./mozjs-*/obj-spider/dist/bin/{js,jsapi-tests,js-gdb.py,libmozjs*} $UPLOAD_DIR
 
 exit $status