Bug 1253064 - Prefer Clang to GCC in local developer builds. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 31 May 2018 10:16:10 +0900
changeset 420577 07db1154d5b9411004d33cfe5d6a0e842cf15163
parent 420576 5e985e187d857338b2ee3c8ade078cc901897450
child 420578 f82bde34ccde67f3ed2246e992552f8ee0eb8a83
push id34074
push userapavel@mozilla.com
push dateThu, 31 May 2018 10:03:38 +0000
treeherdermozilla-central@d5eed637f5dd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1253064
milestone62.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 1253064 - Prefer Clang to GCC in local developer builds. r=gps For Android targets, we just ignore plain clang, it's unlikely to work.
CLOBBER
build/moz.configure/toolchain.configure
python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
--- a/CLOBBER
+++ b/CLOBBER
@@ -17,9 +17,9 @@
 #
 # Modifying this file will now automatically clobber the buildbot machines \o/
 #
 
 # Are you updating CLOBBER because you think it's needed for your WebIDL
 # changes to stick? As of bug 928195, this shouldn't be necessary! Please
 # don't change CLOBBER for WebIDL changes any more.
 
-Bug 1454912 - Changed out GENERATED_FILES are handled in the RecursiveMake backend
+Bug 1253064 - Prefer Clang to GCC in local developer builds
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -1,14 +1,31 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # 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/.
 
+imply_option('--enable-release', mozilla_official)
+imply_option('--enable-release', depends_if('MOZ_AUTOMATION')(lambda x: True))
+
+js_option('--enable-release',
+          help='Build with more conservative, release engineering-oriented '
+               'options. This may slow down builds.')
+
+
+@depends('--enable-release')
+def developer_options(value):
+    if not value:
+        return True
+
+
+add_old_configure_assignment('DEVELOPER_OPTIONS', developer_options)
+set_config('DEVELOPER_OPTIONS', developer_options)
+
 # PGO
 # ==============================================================
 js_option(env='MOZ_PGO', help='Build with profile guided optimizations')
 
 set_config('MOZ_PGO', depends('MOZ_PGO')(lambda x: bool(x)))
 add_old_configure_assignment('MOZ_PGO', depends('MOZ_PGO')(lambda x: bool(x)))
 
 # Code optimization
@@ -642,31 +659,35 @@ def toolchain_search_path(vc_compiler_pa
 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.
     '''
     assert host_or_target in (host, target)
 
-    @depends(host_or_target, target, toolchain_prefix, android_clang_compiler)
-    def default_c_compilers(host_or_target, target, toolchain_prefix, android_clang_compiler):
+    @depends(host_or_target, target, toolchain_prefix, android_clang_compiler,
+             developer_options)
+    def default_c_compilers(host_or_target, target, toolchain_prefix,
+                            android_clang_compiler, developer_options):
         gcc = ('gcc',)
         if toolchain_prefix and host_or_target is target:
             gcc = tuple('%sgcc' % p for p in toolchain_prefix) + gcc
         # Android sets toolchain_prefix and android_clang_compiler, but
         # we want the latter to take precedence, because the latter can
         # point at clang, which is what we want to use.
         if android_clang_compiler and host_or_target is target:
-            gcc = (android_clang_compiler,) + gcc
+            return (android_clang_compiler,) + gcc
 
         if host_or_target.kernel == 'WINNT':
             return ('cl', 'clang-cl') + gcc + ('clang',)
         if host_or_target.kernel == 'Darwin':
             return ('clang',)
+        if developer_options:
+            return ('clang',) + gcc
         return gcc + ('clang',)
 
     return default_c_compilers
 
 
 @template
 def default_cxx_compilers(c_compiler):
     '''Template defining the set of default C++ compilers for the host and
@@ -1358,33 +1379,16 @@ imply_option('--enable-pie', depends_if(
 # ==============================================================
 
 option(env='RUSTFLAGS',
        nargs=1,
        help='Rust compiler flags')
 set_config('RUSTFLAGS', depends('RUSTFLAGS')(lambda flags: flags))
 
 
-imply_option('--enable-release', mozilla_official)
-imply_option('--enable-release', depends_if('MOZ_AUTOMATION')(lambda x: True))
-
-js_option('--enable-release',
-          help='Build with more conservative, release engineering-oriented '
-               'options. This may slow down builds.')
-
-
-@depends('--enable-release')
-def developer_options(value):
-    if not value:
-        return True
-
-
-add_old_configure_assignment('DEVELOPER_OPTIONS', developer_options)
-set_config('DEVELOPER_OPTIONS', developer_options)
-
 # Rust compiler flags
 # ==============================================================
 
 js_option(env='RUSTC_OPT_LEVEL',
           nargs=1,
           help='Rust compiler optimization level (-C opt-level=%s)')
 
 # --enable-release kicks in full optimizations.
--- a/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
+++ b/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
@@ -351,16 +351,18 @@ class BaseToolchainTest(BaseConfigureTes
           they can be omitted. Likewise for host_cxx_compiler vs.
           cxx_compiler.
         '''
         environ = dict(environ)
         if 'PATH' not in environ:
             environ['PATH'] = os.pathsep.join(
                 mozpath.abspath(p) for p in ('/bin', '/usr/bin'))
 
+        args = args + ['--enable-release']
+
         sandbox = self.get_sandbox(paths, {}, args, environ,
                                    logger=self.logger)
 
         for var in ('c_compiler', 'cxx_compiler', 'host_c_compiler',
                     'host_cxx_compiler'):
             if var in results:
                 result = results[var]
             elif var.startswith('host_'):