Bug 1437201 - Part 1: Don't try to use target as host with clang for Android. r=froydnj draft
authorNick Alexander <nalexander@mozilla.com>
Fri, 09 Feb 2018 14:32:28 -0800
changeset 754567 3716d4ff7ce2f1e796489e02e312d7554a5b1e6c
parent 754566 cdd73c729a063507b841297520cafb8d20a8dc65
child 754568 bcc4fc72ce49390e1200eb5efbe6ee14fccd016c
push id98924
push usernalexander@mozilla.com
push dateTue, 13 Feb 2018 20:18:37 +0000
Bug 1437201 - Part 1: Don't try to use target as host with clang for Android. r=froydnj The heuristic simply fails for clang as shipped in Android NDKs: those clang binaries can't target any non-Android host. MozReview-Commit-ID: 6AhOJxE3boW
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -774,31 +774,36 @@ def compiler(language, host_or_target, c
     # Derive the host compiler from the corresponding target compiler when no
     # explicit compiler was given and we're not cross compiling. For the C++
     # compiler, though, prefer to derive from the host C compiler when it
     # doesn't match the target C compiler.
     # As a special case, since clang supports all kinds of targets in the same
     # executable, when cross compiling with clang, default to the same compiler
-    # as the target compiler, resetting flags.
+    # as the target compiler, resetting flags.  However, Android NDK clangs do
+    # not function as host compilers -- they're target compilers only -- so
+    # don't use clang target as host if the target OS is Android.
     if host_or_target == host:
         if other_c_compiler is not None:
             args = (c_compiler, other_c_compiler)
             args = ()
-        @depends(provided_compiler, other_compiler, cross_compiling, *args)
-        def provided_compiler(value, other_compiler, cross_compiling, *args):
+        @depends(provided_compiler, other_compiler, cross_compiling,
+                 target, *args)
+        def provided_compiler(value, other_compiler, cross_compiling,
+                              target, *args):
             if value:
                 return value
             c_compiler, other_c_compiler = args if args else (None, None)
             if not cross_compiling and c_compiler == other_c_compiler:
                 return other_compiler
-            if cross_compiling and other_compiler.type == 'clang':
+            if cross_compiling and other_compiler.type == 'clang' and \
+                    target.os != 'Android':
                 return namespace(**{
                     k: [] if k == 'flags' else v
                     for k, v in other_compiler.__dict__.iteritems()
     # Normally, we'd use `var` instead of `_var`, but the interaction with
     # old-configure complicates things, and for now, we a) can't take the plain
     # result from check_prog as CC/CXX/HOST_CC/HOST_CXX and b) have to let