Bug 1467327 - Use bootstrapped clang if no system clang is found. r=froydnj draft
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 07 Jun 2018 09:57:36 +0900
changeset 805097 5ee6abc1859d29a39953524895594215bff3e970
parent 805096 26c53d78c90acf544b87d45d2c35ad787d3b586e
push id112557
push userbmo:mh+mozilla@glandium.org
push dateThu, 07 Jun 2018 06:09:50 +0000
reviewersfroydnj
bugs1467327
milestone62.0a1
Bug 1467327 - Use bootstrapped clang if no system clang is found. r=froydnj
build/moz.configure/toolchain.configure
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -633,32 +633,37 @@ def vc_compiler_path(host, target, vs_ma
     paths = data.get(vc_target)
     if not paths:
         return
     return paths
 
 
 @depends(vc_compiler_path)
 @imports('os')
+@imports(_from='os', _import='environ')
 def toolchain_search_path(vc_compiler_path):
+    result = [environ.get('PATH')]
+
     if vc_compiler_path:
-        result = [os.environ.get('PATH')]
         result.extend(vc_compiler_path)
 
-        # 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_clang_path = os.path.join(mozbuild_state_dir, 'clang', 'bin')
-        result.append(bootstrap_clang_path)
+    # Also add in the location to which `mach bootstrap` or
+    # `mach artifact toolchain` installs clang.
+    mozbuild_state_dir = environ.get('MOZBUILD_STATE_PATH',
+                                     os.path.expanduser(os.path.join('~', '.mozbuild')))
+    bootstrap_clang_path = os.path.join(mozbuild_state_dir, 'clang', 'bin')
+    result.append(bootstrap_clang_path)
 
+    if vc_compiler_path:
         # We're going to alter PATH for good in windows.configure, but we also
-        # need to do it for the valid_compiler() check below.
-        os.environ['PATH'] = os.pathsep.join(result)
-        return result
+        # need to do it for the valid_compiler() check below. This is only needed
+        # on Windows, where MSVC needs PATH set to find dlls.
+        environ['PATH'] = os.pathsep.join(result)
+
+    return result
 
 
 @template
 def default_c_compilers(host_or_target):
     '''Template defining the set of default C compilers for the host and
     target platforms.
     `host_or_target` is either `host` or `target` (the @depends functions
     from init.configure.