Bug 1379341 - Prefer llvm-config from homebrew to mozbuild. r?gps draft
authorRalph Giles <giles@mozilla.com>
Fri, 07 Jul 2017 19:20:34 -0700
changeset 605600 02003dc52f132b2bc339d94db2da075487aa00d9
parent 605597 9e07fe21ae378521f407faec8e6e053a48b735a6
child 636542 01d1558b3c28212686701d425e190e0ada18e000
push id67463
push userbmo:giles@thaumas.net
push dateSat, 08 Jul 2017 02:47:06 +0000
reviewersgps
bugs1379341
milestone56.0a1
Bug 1379341 - Prefer llvm-config from homebrew to mozbuild. r?gps We've had trouble with crashes and hangs on macOS with libclang builds from tooltool, so for local developer builds we prefer the homebrew or macports packages installed by `mach bootstrap`. However, we were searching ~/.mozbuild before the homebrew directory, resulting using the wrong libclang when developers had run `mach bootstrap` before the switch, or anyone who had used `mach artifact toolchain` on macOS. MozReview-Commit-ID: JpLBDNthG6e
toolkit/moz.configure
--- a/toolkit/moz.configure
+++ b/toolkit/moz.configure
@@ -618,31 +618,24 @@ def building_stylo_bindgen(stylo_config,
 # platforms.
 @depends(host)
 @imports('which')
 @imports('os')
 @imports('subprocess')
 def llvm_config_paths(host):
     llvm_config_progs = [
         'llvm-config-4.0',
-        'llvm-config-mp-4.0',   # MacPorts's chosen naming scheme
+        'llvm-config-mp-4.0',   # MacPorts' chosen naming scheme.
         'llvm-config40',
         'llvm-config-3.9',
         'llvm-config39',
         'llvm-config',
     ]
 
-    # Also add in the location to which `mach bootstrap` installs clang.
-    mozbuild_state_dir = os.environ.get('MOZBUILD_STATE_PATH',
-                                        os.path.expanduser(os.path.join('~', '.mozbuild')))
-    bootstrap_llvm_config = os.path.join(mozbuild_state_dir, 'clang', 'bin', 'llvm-config')
-
-    llvm_config_progs.append(bootstrap_llvm_config)
-
-    # Homebrew on OS X doesn't make clang available on PATH, so we have to
+    # Homebrew on macOS doesn't make clang available on PATH, so we have to
     # look for it in non-standard places.
     if host.kernel == 'Darwin':
         try:
             brew = which.which('brew')
             brew_config = subprocess.check_output([brew, 'config']).strip()
 
             for line in brew_config.splitlines():
                 if line.startswith('HOMEBREW_PREFIX'):
@@ -650,16 +643,24 @@ def llvm_config_paths(host):
                     prefix = fields[1] if len(fields) == 2 else ''
                     path = ['opt', 'llvm', 'bin', 'llvm-config']
                     llvm_config_progs.append(os.path.join(prefix, *path))
                     break
         except which.WhichError:
             # Homebrew not installed, which is fine.
             pass
 
+    # Also add in the location to which `mach bootstrap` or
+    # `mach artifact toolchain` installs clang.
+    mozbuild_state_dir = os.environ.get('MOZBUILD_STATE_PATH',
+                                        os.path.expanduser(os.path.join('~', '.mozbuild')))
+    bootstrap_llvm_config = os.path.join(mozbuild_state_dir, 'clang', 'bin', 'llvm-config')
+
+    llvm_config_progs.append(bootstrap_llvm_config)
+
     return llvm_config_progs
 
 llvm_config = check_prog('LLVM_CONFIG', llvm_config_paths,
                          when=building_stylo_bindgen,
                          what='llvm-config', allow_missing=True)
 
 with only_when(building_stylo_bindgen):
     option('--with-libclang-path', nargs=1,