Bug 1443471 - Use correct rust target for mingw clang. r=glandium
authorJacek Caban <jacek@codeweavers.com>
Mon, 25 Jun 2018 19:57:43 +0200
changeset 425773 6c57a7ace8210b62e0573ed629824524ae8eb54b
parent 425772 f1cce2949d239dcec78955bc9f3c729321104148
child 425774 43432e43c201cda24072425fb67d9e31e5a0d5d7
push id34266
push userrgurzau@mozilla.com
push dateWed, 11 Jul 2018 22:03:10 +0000
treeherdermozilla-central@4e729ca38f8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1443471
milestone63.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 1443471 - Use correct rust target for mingw clang. r=glandium MozReview-Commit-ID: G40IanxGWXv
build/moz.configure/rust.configure
python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
--- a/build/moz.configure/rust.configure
+++ b/build/moz.configure/rust.configure
@@ -144,37 +144,37 @@ def rust_supported_targets(rustc):
 @template
 def rust_triple_alias(host_or_target):
     """Template defining the alias used for rustc's --target flag.
     `host_or_target` is either `host` or `target` (the @depends functions
     from init.configure).
     """
     assert host_or_target in (host, target)
 
-    @depends(rustc, host_or_target, building_with_gcc, rust_supported_targets,
+    @depends(rustc, host_or_target, c_compiler, rust_supported_targets,
              when=rust_compiler)
     @imports('os')
     @imports('subprocess')
     @imports(_from='mozbuild.configure.util', _import='LineIO')
     @imports(_from='mozbuild.shellutil', _import='quote')
     @imports(_from='tempfile', _import='mkstemp')
     @imports(_from='textwrap', _import='dedent')
-    def rust_target(rustc, host_or_target, building_with_gcc,
+    def rust_target(rustc, host_or_target, compiler_info,
                     rust_supported_targets):
         # Rust's --target options are similar to, but not exactly the same
         # as, the autoconf-derived targets we use.  An example would be that
         # Rust uses distinct target triples for targetting the GNU C++ ABI
         # and the MSVC C++ ABI on Win32, whereas autoconf has a single
         # triple and relies on the user to ensure that everything is
         # compiled for the appropriate ABI.  We need to perform appropriate
         # munging to get the correct option to rustc.
         # We correlate the autoconf-derived targets with the list of targets
         # rustc gives us with --print target-list.
         if host_or_target.kernel == 'WINNT':
-            if building_with_gcc:
+            if compiler_info.type in ('gcc', 'clang'):
                 host_or_target_os = 'windows-gnu'
             else:
                 host_or_target_os = 'windows-msvc'
             host_or_target_raw_os = host_or_target_os
         else:
             host_or_target_os = host_or_target.os
             host_or_target_raw_os = host_or_target.raw_os
 
--- a/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
+++ b/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
@@ -1550,34 +1550,34 @@ class RustTest(BaseConfigureTest):
             return 0, '\n'.join(rust_targets), ''
         if (len(args) == 6 and args[:2] == ('--crate-type', 'staticlib') and
             args[2].startswith('--target=') and args[3] == '-o'):
             with open(args[4], 'w') as fh:
                 fh.write('foo')
             return 0, '', ''
         raise NotImplementedError('unsupported arguments')
 
-    def get_rust_target(self, target, building_with_gcc=True):
+    def get_rust_target(self, target, compiler_type='gcc'):
         environ = {
             'PATH': os.pathsep.join(
                 mozpath.abspath(p) for p in ('/bin', '/usr/bin')),
         }
 
         paths = {
             mozpath.abspath('/usr/bin/cargo'): self.invoke_cargo,
             mozpath.abspath('/usr/bin/rustc'): self.invoke_rustc,
         }
 
         self.TARGET = target
         sandbox = self.get_sandbox(paths, {}, [], environ)
 
         # Trick the sandbox into not running the target compiler check
-        dep = sandbox._depends[sandbox['building_with_gcc']]
+        dep = sandbox._depends[sandbox['c_compiler']]
         getattr(sandbox, '__value_for_depends')[(dep, False)] = \
-            building_with_gcc
+            CompilerResult(type=compiler_type)
         return sandbox._value_for(sandbox['rust_target_triple'])
 
     def test_rust_target(self):
         # Cases where the output of config.sub matches a rust target
         for straightforward in (
             'x86_64-unknown-dragonfly',
             'aarch64-unknown-freebsd',
             'i686-unknown-freebsd',
@@ -1617,18 +1617,20 @@ class RustTest(BaseConfigureTest):
             ('x86_64-pc-linux-gnu', 'x86_64-unknown-linux-gnu'),
             ('sparcv9-sun-solaris2', 'sparcv9-sun-solaris'),
             ('x86_64-sun-solaris2', 'x86_64-sun-solaris'),
         ):
             self.assertEqual(self.get_rust_target(autoconf), rust)
 
         # Windows
         for autoconf, building_with_gcc, rust in (
-            ('i686-pc-mingw32', False, 'i686-pc-windows-msvc'),
-            ('x86_64-pc-mingw32', False, 'x86_64-pc-windows-msvc'),
-            ('i686-pc-mingw32', True, 'i686-pc-windows-gnu'),
-            ('x86_64-pc-mingw32', True, 'x86_64-pc-windows-gnu'),
+            ('i686-pc-mingw32', 'cl', 'i686-pc-windows-msvc'),
+            ('x86_64-pc-mingw32', 'cl', 'x86_64-pc-windows-msvc'),
+            ('i686-pc-mingw32', 'gcc', 'i686-pc-windows-gnu'),
+            ('x86_64-pc-mingw32', 'gcc', 'x86_64-pc-windows-gnu'),
+            ('i686-pc-mingw32', 'clang', 'i686-pc-windows-gnu'),
+            ('x86_64-pc-mingw32', 'clang', 'x86_64-pc-windows-gnu'),
         ):
             self.assertEqual(self.get_rust_target(autoconf, building_with_gcc), rust)
 
 
 if __name__ == '__main__':
     main()