Bug 1288313 - Ensure the host and target compilers build for the right kernel. r=chmanchester
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 26 Apr 2016 15:38:45 +0900
changeset 348377 ba8cf05d0ee715aabb7b788f2026819a634a50f1
parent 348376 f0889768e16d8713c11ad08579785d4a178d4309
child 348378 51fe63c13c4c257ca63f4adcc6ab2be97183ce69
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschmanchester
bugs1288313
milestone50.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 1288313 - Ensure the host and target compilers build for the right kernel. r=chmanchester
build/moz.configure/toolchain.configure
python/mozbuild/mozbuild/configure/constants.py
python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -192,16 +192,18 @@ def try_preprocess(compiler, language, s
         return check_cmd_output(*cmd)
     finally:
         os.remove(path)
 
 
 @imports(_from='mozbuild.configure.constants', _import='CompilerType')
 @imports(_from='mozbuild.configure.constants',
          _import='CPU_preprocessor_checks')
+@imports(_from='mozbuild.configure.constants',
+         _import='kernel_preprocessor_checks')
 @imports(_from='textwrap', _import='dedent')
 def get_compiler_info(compiler, language):
     '''Returns information about the given `compiler` (command line in the
     form of a list or tuple), in the given `language`.
 
     The returned information includes:
     - the compiler type (msvc, clang-cl, clang or gcc)
     - the compiler version
@@ -245,26 +247,31 @@ def get_compiler_info(compiler, language
         #elif __STDC__
         %STDC_VERSION 198900L
         #endif
     ''')
 
     # While we're doing some preprocessing, we might as well do some more
     # preprocessor-based tests at the same time, to check the toolchain
     # matches what we want.
-    for n, (value, condition) in enumerate(CPU_preprocessor_checks.iteritems()):
-        check += dedent('''\
-            #%(if)s %(condition)s
-            %%CPU %(value)s
-        ''' % {
-            'if': 'elif' if n else 'if',
-            'condition': condition,
-            'value': value,
-        })
-    check += '#endif\n'
+    for name, preprocessor_checks in (
+        ('CPU', CPU_preprocessor_checks),
+        ('KERNEL', kernel_preprocessor_checks),
+    ):
+        for n, (value, condition) in enumerate(preprocessor_checks.iteritems()):
+            check += dedent('''\
+                #%(if)s %(condition)s
+                %%%(name)s %(value)s
+            ''' % {
+                'if': 'elif' if n else 'if',
+                'condition': condition,
+                'name': name,
+                'value': value,
+            })
+        check += '#endif\n'
 
     result = try_preprocess(compiler, language, check)
 
     if not result:
         raise FatalCheckError(
             'Unknown compiler or compiler not supported.')
 
     data = {}
@@ -295,16 +302,17 @@ def get_compiler_info(compiler, language
 
     if version:
         version = Version(version)
 
     return namespace(
         type=type,
         version=version,
         cpu=data.get('CPU'),
+        kernel=data.get('KERNEL'),
         language='C++' if cplusplus else 'C',
         language_version=cplusplus if cplusplus else stdc_version,
     )
 
 
 @imports(_from='mozbuild.shellutil', _import='quote')
 def check_compiler(compiler, language, target):
     info = get_compiler_info(compiler, language)
@@ -357,20 +365,25 @@ def check_compiler(compiler, language, t
                 ('ppc', 'ppc64'),
                 ('sparc', 'sparc64'),
             )
             if (target.cpu, info.cpu) in same_arch_different_bits:
                 append_flag('-m32')
             elif (info.cpu, target.cpu) in same_arch_different_bits:
                 append_flag('-m64')
 
+    if not info.kernel or info.kernel != target.kernel:
+        if info.type == 'clang':
+            append_flag('--target=%s' % target.toolchain)
+
     return namespace(
         type=info.type,
         version=info.version,
         target_cpu=info.cpu,
+        target_kernel=info.kernel,
         flags=flags,
     )
 
 
 @template
 def default_c_compilers(host_or_target):
     '''Template defining the set of default C compilers for the host and
     target platforms.
@@ -563,16 +576,24 @@ def compiler(language, host_or_target, c
 
         if not info.target_cpu or info.target_cpu != host_or_target.cpu:
             raise FatalCheckError(
                 '%s %s compiler target CPU (%s) does not match --%s CPU (%s)'
                 % (host_or_target_str.capitalize(), language,
                    info.target_cpu or 'unknown', host_or_target_str,
                    host_or_target.raw_cpu))
 
+        if not info.target_kernel or (info.target_kernel !=
+                                      host_or_target.kernel):
+            raise FatalCheckError(
+                '%s %s compiler target kernel (%s) does not match --%s kernel (%s)'
+                % (host_or_target_str.capitalize(), language,
+                   info.target_kernel or 'unknown', host_or_target_str,
+                   host_or_target.kernel))
+
         if info.flags:
             raise FatalCheckError(
                 'Unknown compiler or compiler not supported.')
 
         # Compiler version checks
         # ===================================================
         # Check the compiler version here instead of in `compiler_version` so
         # that the `checking` message doesn't pretend the compiler can be used
--- a/python/mozbuild/mozbuild/configure/constants.py
+++ b/python/mozbuild/mozbuild/configure/constants.py
@@ -76,8 +76,21 @@ CPU_preprocessor_checks = OrderedDict((
     ('hppa', '__hppa__'),
     ('sparc64', '__sparc__ && __arch64__'),
     ('sparc', '__sparc__'),
     ('mips64', '__mips64'),
     ('mips32', '__mips__'),
 ))
 
 assert sorted(CPU_preprocessor_checks.keys()) == sorted(CPU.POSSIBLE_VALUES)
+
+kernel_preprocessor_checks = {
+    'Darwin': '__APPLE__',
+    'DragonFly': '__DragonFly__',
+    'FreeBSD': '__FreeBSD__',
+    'kFreeBSD': '__FreeBSD_kernel__',
+    'Linux': '__linux__',
+    'NetBSD': '__NetBSD__',
+    'OpenBSD': '__OpenBSD__',
+    'WINNT': '_WIN32 || __CYGWIN__',
+}
+
+assert sorted(kernel_preprocessor_checks.keys()) == sorted(Kernel.POSSIBLE_VALUES)
--- a/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
+++ b/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
@@ -93,16 +93,38 @@ GCC_PLATFORM_X86_64 = {
         '__i386__': 1,
     },
 }
 
 GCC_PLATFORM_ARM = {
     '__arm__': 1,
 }
 
+GCC_PLATFORM_LINUX = {
+    '__linux__': 1,
+}
+
+GCC_PLATFORM_DARWIN = {
+    '__APPLE__': 1,
+}
+
+GCC_PLATFORM_WIN = {
+    '_WIN32': 1,
+}
+
+GCC_PLATFORM_X86_LINUX = FakeCompiler(GCC_PLATFORM_X86, GCC_PLATFORM_LINUX)
+GCC_PLATFORM_X86_64_LINUX = FakeCompiler(GCC_PLATFORM_X86_64,
+                                         GCC_PLATFORM_LINUX)
+GCC_PLATFORM_ARM_LINUX = FakeCompiler(GCC_PLATFORM_ARM, GCC_PLATFORM_LINUX)
+GCC_PLATFORM_X86_OSX = FakeCompiler(GCC_PLATFORM_X86, GCC_PLATFORM_DARWIN)
+GCC_PLATFORM_X86_64_OSX = FakeCompiler(GCC_PLATFORM_X86_64,
+                                       GCC_PLATFORM_DARWIN)
+GCC_PLATFORM_X86_WIN = FakeCompiler(GCC_PLATFORM_X86, GCC_PLATFORM_WIN)
+GCC_PLATFORM_X86_64_WIN = FakeCompiler(GCC_PLATFORM_X86_64, GCC_PLATFORM_WIN)
+
 
 @memoize
 def CLANG_BASE(version):
     version = Version(version)
     return FakeCompiler({
         '__clang__': 1,
         '__clang_major__': version.major,
         '__clang_minor__': version.minor,
@@ -128,32 +150,35 @@ CLANGXX_3_6 = CLANGXX('3.6.2') + {
     '-std=gnu++11': {
         '__has_feature(cxx_alignof)': '1',
     },
 }
 
 
 def CLANG_PLATFORM(gcc_platform):
     base = {
-        '--target=x86_64-linux-gnu': GCC_PLATFORM_X86_64[None],
-        '--target=x86_64-darwin11.2.0': GCC_PLATFORM_X86_64[None],
-        '--target=i686-linux-gnu': GCC_PLATFORM_X86[None],
-        '--target=i686-darwin11.2.0': GCC_PLATFORM_X86[None],
-        '--target=arm-linux-gnu': GCC_PLATFORM_ARM,
+        '--target=x86_64-linux-gnu': GCC_PLATFORM_X86_64_LINUX[None],
+        '--target=x86_64-darwin11.2.0': GCC_PLATFORM_X86_64_OSX[None],
+        '--target=i686-linux-gnu': GCC_PLATFORM_X86_LINUX[None],
+        '--target=i686-darwin11.2.0': GCC_PLATFORM_X86_OSX[None],
+        '--target=arm-linux-gnu': GCC_PLATFORM_ARM_LINUX[None],
     }
     undo_gcc_platform = {
         k: {symbol: False for symbol in gcc_platform[None]}
         for k in base
     }
     return FakeCompiler(gcc_platform, undo_gcc_platform, base)
 
 
-CLANG_PLATFORM_X86 = CLANG_PLATFORM(GCC_PLATFORM_X86)
-
-CLANG_PLATFORM_X86_64 = CLANG_PLATFORM(GCC_PLATFORM_X86_64)
+CLANG_PLATFORM_X86_LINUX = CLANG_PLATFORM(GCC_PLATFORM_X86_LINUX)
+CLANG_PLATFORM_X86_64_LINUX = CLANG_PLATFORM(GCC_PLATFORM_X86_64_LINUX)
+CLANG_PLATFORM_X86_OSX = CLANG_PLATFORM(GCC_PLATFORM_X86_OSX)
+CLANG_PLATFORM_X86_64_OSX = CLANG_PLATFORM(GCC_PLATFORM_X86_64_OSX)
+CLANG_PLATFORM_X86_WIN = CLANG_PLATFORM(GCC_PLATFORM_X86_WIN)
+CLANG_PLATFORM_X86_64_WIN = CLANG_PLATFORM(GCC_PLATFORM_X86_64_WIN)
 
 
 @memoize
 def VS(version):
     version = Version(version)
     return FakeCompiler({
         None: {
             '_MSC_VER': '%02d%02d' % (version.major, version.minor),
@@ -167,20 +192,23 @@ def VS(version):
 VS_2013u2 = VS('18.00.30501')
 VS_2013u3 = VS('18.00.30723')
 VS_2015 = VS('19.00.23026')
 VS_2015u1 = VS('19.00.23506')
 VS_2015u2 = VS('19.00.23918')
 
 VS_PLATFORM_X86 = {
     '_M_IX86': 600,
+    '_WIN32': 1,
 }
 
 VS_PLATFORM_X86_64 = {
     '_M_X64': 100,
+    '_WIN32': 1,
+    '_WIN64': 1,
 }
 
 # Note: In reality, the -std=gnu* options are only supported when preceded by
 # -Xclang.
 CLANG_CL_3_9 = (CLANG_BASE('3.9.0') + VS('18.00.00000') + DEFAULT_C11 +
                 SUPPORTS_GNU99 + SUPPORTS_GNUXX11) + {
     '*.cpp': {
         '__STDC_VERSION__': False,
@@ -247,28 +275,28 @@ class BaseToolchainTest(BaseConfigureTes
             except SystemExit:
                 self.assertEquals((var, result),
                                   (var, self.out.getvalue().strip()))
                 return
 
 
 class LinuxToolchainTest(BaseToolchainTest):
     PATHS = {
-        '/usr/bin/gcc': GCC_4_9 + GCC_PLATFORM_X86_64,
-        '/usr/bin/g++': GXX_4_9 + GCC_PLATFORM_X86_64,
-        '/usr/bin/gcc-4.7': GCC_4_7 + GCC_PLATFORM_X86_64,
-        '/usr/bin/g++-4.7': GXX_4_7 + GCC_PLATFORM_X86_64,
-        '/usr/bin/gcc-5': GCC_5 + GCC_PLATFORM_X86_64,
-        '/usr/bin/g++-5': GXX_5 + GCC_PLATFORM_X86_64,
-        '/usr/bin/clang': CLANG_3_6 + CLANG_PLATFORM_X86_64,
-        '/usr/bin/clang++': CLANGXX_3_6 + CLANG_PLATFORM_X86_64,
-        '/usr/bin/clang-3.6': CLANG_3_6 + CLANG_PLATFORM_X86_64,
-        '/usr/bin/clang++-3.6': CLANGXX_3_6 + CLANG_PLATFORM_X86_64,
-        '/usr/bin/clang-3.3': CLANG_3_3 + CLANG_PLATFORM_X86_64,
-        '/usr/bin/clang++-3.3': CLANGXX_3_3 + CLANG_PLATFORM_X86_64,
+        '/usr/bin/gcc': GCC_4_9 + GCC_PLATFORM_X86_64_LINUX,
+        '/usr/bin/g++': GXX_4_9 + GCC_PLATFORM_X86_64_LINUX,
+        '/usr/bin/gcc-4.7': GCC_4_7 + GCC_PLATFORM_X86_64_LINUX,
+        '/usr/bin/g++-4.7': GXX_4_7 + GCC_PLATFORM_X86_64_LINUX,
+        '/usr/bin/gcc-5': GCC_5 + GCC_PLATFORM_X86_64_LINUX,
+        '/usr/bin/g++-5': GXX_5 + GCC_PLATFORM_X86_64_LINUX,
+        '/usr/bin/clang': CLANG_3_6 + CLANG_PLATFORM_X86_64_LINUX,
+        '/usr/bin/clang++': CLANGXX_3_6 + CLANG_PLATFORM_X86_64_LINUX,
+        '/usr/bin/clang-3.6': CLANG_3_6 + CLANG_PLATFORM_X86_64_LINUX,
+        '/usr/bin/clang++-3.6': CLANGXX_3_6 + CLANG_PLATFORM_X86_64_LINUX,
+        '/usr/bin/clang-3.3': CLANG_3_3 + CLANG_PLATFORM_X86_64_LINUX,
+        '/usr/bin/clang++-3.3': CLANGXX_3_3 + CLANG_PLATFORM_X86_64_LINUX,
     }
     GCC_4_7_RESULT = ('Only GCC 4.8 or newer is supported '
                       '(found version 4.7.3).')
     GXX_4_7_RESULT = GCC_4_7_RESULT
     GCC_4_9_RESULT = CompilerResult(
         flags=['-std=gnu99'],
         version='4.9.3',
         type='gcc',
@@ -556,20 +584,20 @@ class LinuxSimpleCrossToolchainTest(Base
             'CC': 'clang',
         })
 
 
 class LinuxX86_64CrossToolchainTest(BaseToolchainTest):
     HOST = 'i686-pc-linux-gnu'
     TARGET = 'x86_64-pc-linux-gnu'
     PATHS = {
-        '/usr/bin/gcc': GCC_4_9 + GCC_PLATFORM_X86,
-        '/usr/bin/g++': GXX_4_9 + GCC_PLATFORM_X86,
-        '/usr/bin/clang': CLANG_3_6 + CLANG_PLATFORM_X86,
-        '/usr/bin/clang++': CLANGXX_3_6 + CLANG_PLATFORM_X86,
+        '/usr/bin/gcc': GCC_4_9 + GCC_PLATFORM_X86_LINUX,
+        '/usr/bin/g++': GXX_4_9 + GCC_PLATFORM_X86_LINUX,
+        '/usr/bin/clang': CLANG_3_6 + CLANG_PLATFORM_X86_LINUX,
+        '/usr/bin/clang++': CLANGXX_3_6 + CLANG_PLATFORM_X86_LINUX,
     }
     GCC_4_9_RESULT = LinuxToolchainTest.GCC_4_9_RESULT
     GXX_4_9_RESULT = LinuxToolchainTest.GXX_4_9_RESULT
     CLANG_3_6_RESULT = LinuxToolchainTest.CLANG_3_6_RESULT
     CLANGXX_3_6_RESULT = LinuxToolchainTest.CLANGXX_3_6_RESULT
 
     def test_cross_gcc(self):
         self.do_toolchain_test(self.PATHS, {
@@ -595,17 +623,30 @@ class LinuxX86_64CrossToolchainTest(Base
             'host_cxx_compiler': self.CLANGXX_3_6_RESULT,
         }, environ={
             'CC': 'clang',
         })
 
 
 class OSXToolchainTest(BaseToolchainTest):
     HOST = 'x86_64-apple-darwin11.2.0'
-    PATHS = LinuxToolchainTest.PATHS
+    PATHS = {
+        '/usr/bin/gcc': GCC_4_9 + GCC_PLATFORM_X86_64_OSX,
+        '/usr/bin/g++': GXX_4_9 + GCC_PLATFORM_X86_64_OSX,
+        '/usr/bin/gcc-4.7': GCC_4_7 + GCC_PLATFORM_X86_64_OSX,
+        '/usr/bin/g++-4.7': GXX_4_7 + GCC_PLATFORM_X86_64_OSX,
+        '/usr/bin/gcc-5': GCC_5 + GCC_PLATFORM_X86_64_OSX,
+        '/usr/bin/g++-5': GXX_5 + GCC_PLATFORM_X86_64_OSX,
+        '/usr/bin/clang': CLANG_3_6 + CLANG_PLATFORM_X86_64_OSX,
+        '/usr/bin/clang++': CLANGXX_3_6 + CLANG_PLATFORM_X86_64_OSX,
+        '/usr/bin/clang-3.6': CLANG_3_6 + CLANG_PLATFORM_X86_64_OSX,
+        '/usr/bin/clang++-3.6': CLANGXX_3_6 + CLANG_PLATFORM_X86_64_OSX,
+        '/usr/bin/clang-3.3': CLANG_3_3 + CLANG_PLATFORM_X86_64_OSX,
+        '/usr/bin/clang++-3.3': CLANGXX_3_3 + CLANG_PLATFORM_X86_64_OSX,
+    }
     CLANG_3_3_RESULT = LinuxToolchainTest.CLANG_3_3_RESULT
     CLANGXX_3_3_RESULT = LinuxToolchainTest.CLANGXX_3_3_RESULT
     CLANG_3_6_RESULT = LinuxToolchainTest.CLANG_3_6_RESULT
     CLANGXX_3_6_RESULT = LinuxToolchainTest.CLANGXX_3_6_RESULT
     GCC_4_7_RESULT = LinuxToolchainTest.GCC_4_7_RESULT
     GCC_5_RESULT = LinuxToolchainTest.GCC_5_RESULT
     GXX_5_RESULT = LinuxToolchainTest.GXX_5_RESULT
 
@@ -662,28 +703,28 @@ class WindowsToolchainTest(BaseToolchain
     # real Windows paths.
     PATHS = {
         '/opt/VS_2013u2/bin/cl': VS_2013u2 + VS_PLATFORM_X86,
         '/opt/VS_2013u3/bin/cl': VS_2013u3 + VS_PLATFORM_X86,
         '/opt/VS_2015/bin/cl': VS_2015 + VS_PLATFORM_X86,
         '/opt/VS_2015u1/bin/cl': VS_2015u1 + VS_PLATFORM_X86,
         '/usr/bin/cl': VS_2015u2 + VS_PLATFORM_X86,
         '/usr/bin/clang-cl': CLANG_CL_3_9 + CLANG_CL_PLATFORM_X86,
-        '/usr/bin/gcc': GCC_4_9 + GCC_PLATFORM_X86,
-        '/usr/bin/g++': GXX_4_9 + GCC_PLATFORM_X86,
-        '/usr/bin/gcc-4.7': GCC_4_7 + GCC_PLATFORM_X86,
-        '/usr/bin/g++-4.7': GXX_4_7 + GCC_PLATFORM_X86,
-        '/usr/bin/gcc-5': GCC_5 + GCC_PLATFORM_X86,
-        '/usr/bin/g++-5': GXX_5 + GCC_PLATFORM_X86,
-        '/usr/bin/clang': CLANG_3_6 + CLANG_PLATFORM_X86,
-        '/usr/bin/clang++': CLANGXX_3_6 + CLANG_PLATFORM_X86,
-        '/usr/bin/clang-3.6': CLANG_3_6 + CLANG_PLATFORM_X86,
-        '/usr/bin/clang++-3.6': CLANGXX_3_6 + CLANG_PLATFORM_X86,
-        '/usr/bin/clang-3.3': CLANG_3_3 + CLANG_PLATFORM_X86,
-        '/usr/bin/clang++-3.3': CLANGXX_3_3 + CLANG_PLATFORM_X86,
+        '/usr/bin/gcc': GCC_4_9 + GCC_PLATFORM_X86_WIN,
+        '/usr/bin/g++': GXX_4_9 + GCC_PLATFORM_X86_WIN,
+        '/usr/bin/gcc-4.7': GCC_4_7 + GCC_PLATFORM_X86_WIN,
+        '/usr/bin/g++-4.7': GXX_4_7 + GCC_PLATFORM_X86_WIN,
+        '/usr/bin/gcc-5': GCC_5 + GCC_PLATFORM_X86_WIN,
+        '/usr/bin/g++-5': GXX_5 + GCC_PLATFORM_X86_WIN,
+        '/usr/bin/clang': CLANG_3_6 + CLANG_PLATFORM_X86_WIN,
+        '/usr/bin/clang++': CLANGXX_3_6 + CLANG_PLATFORM_X86_WIN,
+        '/usr/bin/clang-3.6': CLANG_3_6 + CLANG_PLATFORM_X86_WIN,
+        '/usr/bin/clang++-3.6': CLANGXX_3_6 + CLANG_PLATFORM_X86_WIN,
+        '/usr/bin/clang-3.3': CLANG_3_3 + CLANG_PLATFORM_X86_WIN,
+        '/usr/bin/clang++-3.3': CLANGXX_3_3 + CLANG_PLATFORM_X86_WIN,
     }
 
     VS_2013u2_RESULT = (
         'This version (18.00.30501) of the MSVC compiler is not supported.\n'
         'You must install Visual C++ 2015 Update 2 or newer in order to build.\n'
         'See https://developer.mozilla.org/en/Windows_Build_Prerequisites')
     VS_2013u3_RESULT = (
         'This version (18.00.30723) of the MSVC compiler is not supported.\n'
@@ -826,125 +867,125 @@ class Windows64ToolchainTest(WindowsTool
     # real Windows paths.
     PATHS = {
         '/opt/VS_2013u2/bin/cl': VS_2013u2 + VS_PLATFORM_X86_64,
         '/opt/VS_2013u3/bin/cl': VS_2013u3 + VS_PLATFORM_X86_64,
         '/opt/VS_2015/bin/cl': VS_2015 + VS_PLATFORM_X86_64,
         '/opt/VS_2015u1/bin/cl': VS_2015u1 + VS_PLATFORM_X86_64,
         '/usr/bin/cl': VS_2015u2 + VS_PLATFORM_X86_64,
         '/usr/bin/clang-cl': CLANG_CL_3_9 + CLANG_CL_PLATFORM_X86_64,
-        '/usr/bin/gcc': GCC_4_9 + GCC_PLATFORM_X86_64,
-        '/usr/bin/g++': GXX_4_9 + GCC_PLATFORM_X86_64,
-        '/usr/bin/gcc-4.7': GCC_4_7 + GCC_PLATFORM_X86_64,
-        '/usr/bin/g++-4.7': GXX_4_7 + GCC_PLATFORM_X86_64,
-        '/usr/bin/gcc-5': GCC_5 + GCC_PLATFORM_X86_64,
-        '/usr/bin/g++-5': GXX_5 + GCC_PLATFORM_X86_64,
-        '/usr/bin/clang': CLANG_3_6 + CLANG_PLATFORM_X86_64,
-        '/usr/bin/clang++': CLANGXX_3_6 + CLANG_PLATFORM_X86_64,
-        '/usr/bin/clang-3.6': CLANG_3_6 + CLANG_PLATFORM_X86_64,
-        '/usr/bin/clang++-3.6': CLANGXX_3_6 + CLANG_PLATFORM_X86_64,
-        '/usr/bin/clang-3.3': CLANG_3_3 + CLANG_PLATFORM_X86_64,
-        '/usr/bin/clang++-3.3': CLANGXX_3_3 + CLANG_PLATFORM_X86_64,
+        '/usr/bin/gcc': GCC_4_9 + GCC_PLATFORM_X86_64_WIN,
+        '/usr/bin/g++': GXX_4_9 + GCC_PLATFORM_X86_64_WIN,
+        '/usr/bin/gcc-4.7': GCC_4_7 + GCC_PLATFORM_X86_64_WIN,
+        '/usr/bin/g++-4.7': GXX_4_7 + GCC_PLATFORM_X86_64_WIN,
+        '/usr/bin/gcc-5': GCC_5 + GCC_PLATFORM_X86_64_WIN,
+        '/usr/bin/g++-5': GXX_5 + GCC_PLATFORM_X86_64_WIN,
+        '/usr/bin/clang': CLANG_3_6 + CLANG_PLATFORM_X86_64_WIN,
+        '/usr/bin/clang++': CLANGXX_3_6 + CLANG_PLATFORM_X86_64_WIN,
+        '/usr/bin/clang-3.6': CLANG_3_6 + CLANG_PLATFORM_X86_64_WIN,
+        '/usr/bin/clang++-3.6': CLANGXX_3_6 + CLANG_PLATFORM_X86_64_WIN,
+        '/usr/bin/clang-3.3': CLANG_3_3 + CLANG_PLATFORM_X86_64_WIN,
+        '/usr/bin/clang++-3.3': CLANGXX_3_3 + CLANG_PLATFORM_X86_64_WIN,
     }
 
     def test_cannot_cross(self):
         paths = {
             '/usr/bin/cl': VS_2015u2 + VS_PLATFORM_X86,
         }
         self.do_toolchain_test(paths, {
             'c_compiler': ('Target C compiler target CPU (x86) '
                            'does not match --target CPU (x86_64)'),
         })
 
 
 class LinuxCrossCompileToolchainTest(BaseToolchainTest):
     TARGET = 'arm-unknown-linux-gnu'
     PATHS = {
-        '/usr/bin/arm-linux-gnu-gcc': GCC_4_9 + GCC_PLATFORM_ARM,
-        '/usr/bin/arm-linux-gnu-g++': GXX_4_9 + GCC_PLATFORM_ARM,
-        '/usr/bin/arm-linux-gnu-gcc-4.7': GCC_4_7 + GCC_PLATFORM_ARM,
-        '/usr/bin/arm-linux-gnu-g++-4.7': GXX_4_7 + GCC_PLATFORM_ARM,
-        '/usr/bin/arm-linux-gnu-gcc-5': GCC_5 + GCC_PLATFORM_ARM,
-        '/usr/bin/arm-linux-gnu-g++-5': GXX_5 + GCC_PLATFORM_ARM,
+        '/usr/bin/arm-linux-gnu-gcc': GCC_4_9 + GCC_PLATFORM_ARM_LINUX,
+        '/usr/bin/arm-linux-gnu-g++': GXX_4_9 + GCC_PLATFORM_ARM_LINUX,
+        '/usr/bin/arm-linux-gnu-gcc-4.7': GCC_4_7 + GCC_PLATFORM_ARM_LINUX,
+        '/usr/bin/arm-linux-gnu-g++-4.7': GXX_4_7 + GCC_PLATFORM_ARM_LINUX,
+        '/usr/bin/arm-linux-gnu-gcc-5': GCC_5 + GCC_PLATFORM_ARM_LINUX,
+        '/usr/bin/arm-linux-gnu-g++-5': GXX_5 + GCC_PLATFORM_ARM_LINUX,
     }
     PATHS.update(LinuxToolchainTest.PATHS)
     ARM_GCC_4_7_RESULT = LinuxToolchainTest.GXX_4_7_RESULT
     ARM_GCC_5_RESULT = LinuxToolchainTest.GCC_5_RESULT + {
         'compiler': '/usr/bin/arm-linux-gnu-gcc-5',
     }
     ARM_GXX_5_RESULT = LinuxToolchainTest.GXX_5_RESULT + {
         'compiler': '/usr/bin/arm-linux-gnu-g++-5',
     }
     CLANG_3_6_RESULT = LinuxToolchainTest.CLANG_3_6_RESULT
     CLANGXX_3_6_RESULT = LinuxToolchainTest.CLANGXX_3_6_RESULT
     GCC_4_9_RESULT = LinuxToolchainTest.GCC_4_9_RESULT
     GXX_4_9_RESULT = LinuxToolchainTest.GXX_4_9_RESULT
 
     PLATFORMS = {
-        'i686-pc-linux-gnu': GCC_PLATFORM_X86,
-        'x86_64-pc-linux-gnu': GCC_PLATFORM_X86_64,
-        'arm-unknown-linux-gnu': GCC_PLATFORM_ARM,
-        'aarch64-unknown-linux-gnu': {
+        'i686-pc-linux-gnu': GCC_PLATFORM_X86_LINUX,
+        'x86_64-pc-linux-gnu': GCC_PLATFORM_X86_64_LINUX,
+        'arm-unknown-linux-gnu': GCC_PLATFORM_ARM_LINUX,
+        'aarch64-unknown-linux-gnu': FakeCompiler(GCC_PLATFORM_LINUX) + {
             '__aarch64__': 1,
         },
-        'ia64-unknown-linux-gnu': {
+        'ia64-unknown-linux-gnu': FakeCompiler(GCC_PLATFORM_LINUX) + {
             '__ia64__': 1,
         },
-        's390x-unknown-linux-gnu': {
+        's390x-unknown-linux-gnu': FakeCompiler(GCC_PLATFORM_LINUX) + {
             '__s390x__': 1,
             '__s390__': 1,
         },
-        's390-unknown-linux-gnu': {
+        's390-unknown-linux-gnu': FakeCompiler(GCC_PLATFORM_LINUX) + {
             '__s390__': 1,
         },
-        'powerpc64-unknown-linux-gnu': {
+        'powerpc64-unknown-linux-gnu': FakeCompiler(GCC_PLATFORM_LINUX) + {
             None: {
                 '__powerpc64__': 1,
                 '__powerpc__': 1,
             },
             '-m32': {
                 '__powerpc64__': False,
             },
         },
-        'powerpc-unknown-linux-gnu': {
+        'powerpc-unknown-linux-gnu': FakeCompiler(GCC_PLATFORM_LINUX) + {
             None: {
                 '__powerpc__': 1,
             },
             '-m64': {
                 '__powerpc64__': 1,
             },
         },
-        'alpha-unknown-linux-gnu': {
+        'alpha-unknown-linux-gnu': FakeCompiler(GCC_PLATFORM_LINUX) + {
             '__alpha__': 1,
         },
-        'hppa-unknown-linux-gnu': {
+        'hppa-unknown-linux-gnu': FakeCompiler(GCC_PLATFORM_LINUX) + {
             '__hppa__': 1,
         },
-        'sparc64-unknown-linux-gnu': {
+        'sparc64-unknown-linux-gnu': FakeCompiler(GCC_PLATFORM_LINUX) + {
             None: {
                 '__arch64__': 1,
                 '__sparc__': 1,
             },
             '-m32': {
                 '__arch64__': False,
             },
         },
-        'sparc-unknown-linux-gnu': {
+        'sparc-unknown-linux-gnu': FakeCompiler(GCC_PLATFORM_LINUX) + {
             None: {
                 '__sparc__': 1,
             },
             '-m64': {
                 '__arch64__': 1,
             },
         },
-        'mips64-unknown-linux-gnuabi64': {
+        'mips64-unknown-linux-gnuabi64': FakeCompiler(GCC_PLATFORM_LINUX) + {
             '__mips64': 1,
             '__mips__': 1,
         },
-        'mips-unknown-linux-gnu': {
+        'mips-unknown-linux-gnu': FakeCompiler(GCC_PLATFORM_LINUX) + {
             '__mips__': 1,
         },
     }
 
     def do_test_cross_gcc_32_64(self, host, target):
         self.HOST = host
         self.TARGET = target
         paths = {
@@ -1138,11 +1179,19 @@ class OSXCrossToolchainTest(BaseToolchai
                 'flags': ['--target=i686-darwin11.2.0'],
             },
             'host_c_compiler': self.CLANG_3_6_RESULT,
             'host_cxx_compiler': self.CLANGXX_3_6_RESULT,
         }, environ={
             'CC': 'clang',
         })
 
+    def test_cannot_osx_cross(self):
+        self.do_toolchain_test(self.PATHS, {
+            'c_compiler': 'Target C compiler target kernel (Linux) does not '
+                          'match --target kernel (Darwin)',
+        }, environ={
+            'CC': 'gcc',
+        })
+
 
 if __name__ == '__main__':
     main()