Bug 1515528 - Prefer link to lld-link when building with msvc rather than clang-cl. r=froydnj
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 11 Jan 2019 00:20:26 +0000
changeset 453418 a426ddd23654e1f3b801d864aa1a686fc22d8e4f
parent 453366 65326bd78f839f71f6c38d1b8a8e8b0cf10746e1
child 453419 eb83a8375b871fcd39ba97d37509320a2e98a406
push id35357
push usernerli@mozilla.com
push dateFri, 11 Jan 2019 21:54:07 +0000
treeherdermozilla-central@0ce024c91511 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1515528
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 1515528 - Prefer link to lld-link when building with msvc rather than clang-cl. r=froydnj While it was preferable to use lld-link with msvc for performance reasons when we defaulted to compile with msvc, now that we build with clang-cl by default, it's now better to use msvc's linker when using msvc's compiler, especially for aarch64, which is the last place where we actually need msvc. Differential Revision: https://phabricator.services.mozilla.com/D15262
build/moz.configure/windows.configure
--- a/build/moz.configure/windows.configure
+++ b/build/moz.configure/windows.configure
@@ -450,20 +450,36 @@ def valid_mt(path):
     except subprocess.CalledProcessError:
         pass
     raise FatalCheckError('%s is not Microsoft Manifest Tool')
 
 
 set_config('MSMANIFEST_TOOL', depends(valid_mt)(lambda x: bool(x)))
 
 
-link = check_prog('LINKER', ('lld-link.exe', 'link.exe'),
+@template
+def linker_progs_for(host_or_target):
+    compiler = {
+        host: host_c_compiler,
+        target: c_compiler,
+    }[host_or_target]
+
+    @depends(compiler)
+    def linker_progs(compiler):
+        if compiler.type == 'msvc':
+            return ('link', 'lld-link')
+        if compiler.type == 'clang-cl':
+            return ('lld-link', 'link')
+    return linker_progs
+
+
+link = check_prog('LINKER', linker_progs_for(target),
                   paths=toolchain_search_path)
 
-host_link = check_prog('HOST_LINKER', ('lld-link.exe', 'link.exe'),
+host_link = check_prog('HOST_LINKER', linker_progs_for(host),
                        paths=toolchain_search_path)
 
 add_old_configure_assignment('LINKER', link)
 
 
 check_prog('MAKECAB', ('makecab.exe',))