Bug 1477487 - Part 2: Make |mach bootstrap| for Android recommend toolchain clang and lld. r=agi,froydnj,#firefox-build-system-reviewers
authorNick Alexander <nalexander@mozilla.com>
Thu, 17 Jan 2019 21:30:49 +0000
changeset 454351 bbfe0cbb90b4d17d53773914f2f3753d830af242
parent 454350 b1f74fc90f37ba9bee709ea76754253dda5ef561
child 454352 dc41aecedaac40fa9d7850f7a2bec5631ca5cea6
push id35395
push userebalazs@mozilla.com
push dateFri, 18 Jan 2019 09:38:33 +0000
treeherdermozilla-central@88e2eb73aace [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersagi, froydnj
bugs1477487
milestone66.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 1477487 - Part 2: Make |mach bootstrap| for Android recommend toolchain clang and lld. r=agi,froydnj,#firefox-build-system-reviewers We're seeing all sorts of problems with the NDK toolchain compilers and the various versions of the NDK. In automation we build with r17b and our own toolchain clang; let's try to standardize on that. This patch is ugly because of the evolution of mozboot. Long ago, we passed arguments around and interpolated strings into function names rather than setting members with the application name and whether we're in artifact mode. The places I needed to modify didn't have the right data at the right time so I added it to the bootstrap instance. I don't have the time or energy to use the instance variables through-out: that'll have to be future follow-up. Differential Revision: https://phabricator.services.mozilla.com/D16138
python/mozboot/mozboot/android.py
python/mozboot/mozboot/bootstrap.py
python/mozboot/mozboot/osx.py
python/mozboot/mozboot/stylo.py
--- a/python/mozboot/mozboot/android.py
+++ b/python/mozboot/mozboot/android.py
@@ -44,22 +44,35 @@ output as packages are downloaded and in
 
 MOBILE_ANDROID_MOZCONFIG_TEMPLATE = '''
 Paste the lines between the chevrons (>>> and <<<) into your
 $topsrcdir/mozconfig file, or create the file if it does not exist:
 
 >>>
 # Build GeckoView/Firefox for Android:
 ac_add_options --enable-application=mobile/android
+
+# Targeting the following architecture.  Ensure exactly one --target is uncommented!
+# For regular phones:
 ac_add_options --target=arm-linux-androideabi
+# For newer phones.
+# ac_add_options --target=aarch64-linux-android
+# For x86 emulators (and x86 devices, which are uncommon):
+# ac_add_options --target=i686-linux-android
+# For x86_64 emulators (and x86_64 devices, which are even less common):
+# ac_add_options --target=x86_64-linux-android
 
 {extra_lines}
 # With the following Android SDK and NDK:
 ac_add_options --with-android-sdk="{sdk_path}"
 ac_add_options --with-android-ndk="{ndk_path}"
+
+# With the following compiler toolchain:
+CC="{moz_state_dir}/clang/bin/clang"
+CXX="{moz_state_dir}/clang/bin/clang++"
 <<<
 '''
 
 MOBILE_ANDROID_ARTIFACT_MODE_MOZCONFIG_TEMPLATE = '''
 Paste the lines between the chevrons (>>> and <<<) into your
 $topsrcdir/mozconfig file, or create the file if it does not exist:
 
 >>>
@@ -286,17 +299,17 @@ def ensure_android_packages(sdkmanager_t
         e = subprocess.CalledProcessError(retcode, cmd)
         e.output = output
         raise e
 
     print(output)
 
 
 def suggest_mozconfig(os_name, artifact_mode=False, java_bin_path=None):
-    _mozbuild_path, sdk_path, ndk_path = get_paths(os_name)
+    moz_state_dir, sdk_path, ndk_path = get_paths(os_name)
 
     extra_lines = []
     if java_bin_path:
         extra_lines += [
             '# With the following java:',
             'ac_add_options --with-java-bin-path="{}"'.format(java_bin_path),
         ]
     if extra_lines:
@@ -305,16 +318,17 @@ def suggest_mozconfig(os_name, artifact_
     if artifact_mode:
         template = MOBILE_ANDROID_ARTIFACT_MODE_MOZCONFIG_TEMPLATE
     else:
         template = MOBILE_ANDROID_MOZCONFIG_TEMPLATE
 
     kwargs = dict(
         sdk_path=sdk_path,
         ndk_path=ndk_path,
+        moz_state_dir=moz_state_dir,
         extra_lines='\n'.join(extra_lines),
     )
     print(template.format(**kwargs))
 
 
 def android_ndk_url(os_name, ver=NDK_VERSION):
     # Produce a URL like
     # 'https://dl.google.com/android/repository/android-ndk-$VER-linux-x86_64.zip
--- a/python/mozboot/mozboot/bootstrap.py
+++ b/python/mozboot/mozboot/bootstrap.py
@@ -375,19 +375,20 @@ class Bootstrapper(object):
             print(STYLO_NODEJS_DIRECTORY_MESSAGE.format(statedir=state_dir))
             sys.exit(1)
 
         if not have_clone:
             print(STYLE_NODEJS_REQUIRES_CLONE)
             sys.exit(1)
 
         self.instance.state_dir = state_dir
-        self.instance.ensure_stylo_packages(state_dir, checkout_root)
         self.instance.ensure_node_packages(state_dir, checkout_root)
-        self.instance.ensure_clang_static_analysis_package(checkout_root)
+        if not self.instance.artifact_mode:
+            self.instance.ensure_stylo_packages(state_dir, checkout_root)
+            self.instance.ensure_clang_static_analysis_package(checkout_root)
 
     def check_telemetry_opt_in(self, state_dir):
         # We can't prompt the user.
         if self.instance.no_interactive:
             return
         # Don't prompt if the user already has a setting for this value.
         if self.mach_context is not None and 'telemetry' in self.mach_context.settings.build:
             return
@@ -406,16 +407,19 @@ class Bootstrapper(object):
             prompt_choice = self.instance.prompt_int(prompt=prompt, low=1, high=len(APPLICATIONS))
             name, application = APPLICATIONS_LIST[prompt_choice-1]
         elif self.choice not in APPLICATIONS.keys():
             raise Exception('Please pick a valid application choice: (%s)' %
                             '/'.join(APPLICATIONS.keys()))
         else:
             name, application = APPLICATIONS[self.choice]
 
+        self.instance.application = application
+        self.instance.artifact_mode = 'artifact_mode' in application
+
         if self.instance.no_system_changes:
             state_dir_available, state_dir = self.try_to_create_state_dir()
             # We need to enable the loading of hgrc in case extensions are
             # required to open the repo.
             r = current_firefox_checkout(
                 check_output=self.instance.check_output,
                 env=self.instance._hg_cleanenv(load_hgrc=True),
                 hg=self.instance.which('hg'))
--- a/python/mozboot/mozboot/osx.py
+++ b/python/mozboot/mozboot/osx.py
@@ -516,17 +516,20 @@ class OSXBootstrapper(BaseBootstrapper):
 
         return active_name.lower()
 
     def ensure_clang_static_analysis_package(self, checkout_root):
         self.install_toolchain_static_analysis(checkout_root)
 
     def ensure_stylo_packages(self, state_dir, checkout_root):
         from mozboot import stylo
-        # We installed clang via homebrew earlier.
+        # We installed clang via homebrew earlier.  However, on Android, we're
+        # seeing many compiler errors so we use our own toolchain clang.
+        if 'mobile_android' in self.application:
+            self.install_toolchain_artifact(state_dir, checkout_root, stylo.MACOS_CLANG)
         self.install_toolchain_artifact(state_dir, checkout_root, stylo.MACOS_CBINDGEN)
 
     def ensure_node_packages(self, state_dir, checkout_root):
         # XXX from necessary?
         from mozboot import node
         self.install_toolchain_artifact(state_dir, checkout_root, node.OSX)
 
     def install_homebrew(self):
--- a/python/mozboot/mozboot/stylo.py
+++ b/python/mozboot/mozboot/stylo.py
@@ -3,9 +3,10 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, print_function, unicode_literals
 
 WINDOWS_CLANG = 'win64-clang-cl'
 WINDOWS_CBINDGEN = 'win64-cbindgen'
 LINUX_CLANG = 'linux64-clang'
 LINUX_CBINDGEN = 'linux64-cbindgen'
+MACOS_CLANG = 'macosx64-clang'
 MACOS_CBINDGEN = 'macosx64-cbindgen'