Bug 1381741 - Only fail gold detection when --enable-gold is specified; r=glandium
authorGregory Szorc <gps@mozilla.com>
Thu, 20 Jul 2017 08:24:36 -0700
changeset 418763 90bb95e8afc8b9ce2d1c3f2c9675d8d0b171e3d2
parent 418762 4e8a7ad99f9f2377aa2a226e3a94550d9edfb607
child 418764 7b16c219d018fb48f72c64bb7a9c225b23624e15
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1381741, 1351109
milestone56.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 1381741 - Only fail gold detection when --enable-gold is specified; r=glandium developer_options (!--enable-release) implies to search for and prefer the gold linker. As part of porting gold detection to moz.configure in d0e782180741 (bug 1351109), the logic inadvertently changed to require gold when either --enable-gold or !--enable-release were present. This commit relaxes the requirement to find gold when only --enable-gold is true. MozReview-Commit-ID: HTBicWNUkvy
build/moz.configure/toolchain.configure
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -1100,28 +1100,29 @@ option('--enable-gold',
 @checking('for ld', lambda x: x.KIND)
 @imports('os')
 @imports('shutil')
 def enable_gold(enable_gold_option, c_compiler, developer_options, build_env):
     linker = None
     # Used to check the kind of linker
     version_check = ['-Wl,--version']
     cmd_base = c_compiler.wrapper + [c_compiler.compiler] + c_compiler.flags
-    if enable_gold_option or developer_options:
+
+    def resolve_gold():
         # Try to force the usage of gold
         targetDir = os.path.join(build_env.topobjdir, 'build', 'unix', 'gold')
 
         gold_detection_arg = '-print-prog-name=ld.gold'
         gold = check_cmd_output(c_compiler.compiler, gold_detection_arg).strip()
         if not gold:
-            die('Could not find gold')
+            return
 
         goldFullPath = find_program(gold)
         if goldFullPath is None:
-            die('Could not find gold')
+            return
 
         if os.path.exists(targetDir):
             shutil.rmtree(targetDir)
         os.makedirs(targetDir)
         os.symlink(goldFullPath, os.path.join(targetDir, 'ld'))
 
         linker = ['-B', targetDir]
         cmd = cmd_base + linker + version_check
@@ -1130,16 +1131,26 @@ def enable_gold(enable_gold_option, c_co
             return namespace(
                 KIND='gold',
                 LINKER_FLAG=linker,
             )
         else:
             # The -B trick didn't work, removing the directory
             shutil.rmtree(targetDir)
 
+    if enable_gold_option or developer_options:
+        result = resolve_gold()
+
+        if result:
+            return result
+        # gold is only required if --enable-gold is used.
+        elif enable_gold_option:
+            die('Could not find gold')
+        # Else fallthrough.
+
     cmd = cmd_base + version_check
     cmd_output = check_cmd_output(*cmd).decode('utf-8')
     # using decode because ld can be localized and python will
     # have problems with french accent for example
     if 'GNU ld' in cmd_output:
         # We are using the normal linker
         return namespace(
             KIND='bfd'