Bug 1265627 - Force clang-cl MSVC emulation from moz.configure. r?ted draft
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 19 Apr 2016 15:55:36 +0900
changeset 353148 9df8208f5b20820d305f179f63009b03ffc3e4b9
parent 353147 b4e6a11adf28b9e99cff7ac4d7f17f5e262b950b
child 353149 912c754719142aa1b7276a181cd087777ada1224
push id15882
push userbmo:mh+mozilla@glandium.org
push dateTue, 19 Apr 2016 08:29:52 +0000
reviewersted
bugs1265627
milestone48.0a1
Bug 1265627 - Force clang-cl MSVC emulation from moz.configure. r?ted
build/autoconf/toolchain.m4
build/moz.configure/toolchain.configure
--- a/build/autoconf/toolchain.m4
+++ b/build/autoconf/toolchain.m4
@@ -28,23 +28,16 @@ CLANG_CL=
 if test "$CC_TYPE" = "clang"; then
     GNU_CC=1
     GNU_CXX=1
     CLANG_CC=1
     CLANG_CXX=1
 fi
 if test "$CC_TYPE" = "clang-cl"; then
     CLANG_CL=1
-    # We force clang-cl to emulate Visual C++ 2013 in configure.in, but that
-    # is based on the CLANG_CL variable defined here, so make sure that we're
-    # getting the right version here manually.
-    CC_VERSION=180030723
-    # Build on clang-cl with MSVC 2013 Update 3 with fallback emulation.
-    CFLAGS="$CFLAGS -fms-compatibility-version=18.00.30723 -fallback"
-    CXXFLAGS="$CXXFLAGS -fms-compatibility-version=18.00.30723 -fallback"
 fi
 
 if test "$GNU_CC"; then
     if `$CC -print-prog-name=ld` -v 2>&1 | grep -c GNU >/dev/null; then
         GCC_USE_GNU_LD=1
     fi
 fi
 
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -215,17 +215,17 @@ def get_compiler_info(compiler, language
     # new __cpp_* macros that older clang versions didn't.
     # We then only include the version information when the C++ compiler
     # matches the feature check, so that an unsupported version of clang would
     # have no version number.
     check = dedent('''\
         #if defined(_MSC_VER)
         #if defined(__clang__)
         %COMPILER clang-cl
-        %VERSION _MSC_VER
+        %VERSION _MSC_FULL_VER
         #else
         %COMPILER msvc
         %VERSION _MSC_FULL_VER
         #endif
         #elif defined(__clang__)
         %COMPILER clang
         #  if !__cplusplus || __cpp_static_assert
         %VERSION __clang_major__.__clang_minor__.__clang_patchlevel__
@@ -302,16 +302,24 @@ def check_compiler(compiler, language):
 
     # Note: MSVC, while supporting C++11, still reports 199711L for __cplusplus.
     # Note: this is a strict version check because we used to always add
     # -std=gnu++11.
     if info.language == 'C++' and info.language_version != 201103:
         if info.type in ('clang-cl', 'clang', 'gcc'):
             append_flag('-std=gnu++11')
 
+    # We force clang-cl to emulate Visual C++ 2013 Update 3 with fallback to
+    # cl.exe.
+    if info.type == 'clang-cl' and info.version != '180030723':
+        # Those flags are direct clang-cl flags that don't need -Xclang, add
+        # them directly.
+        flags.append('-fms-compatibility-version=18.00.30723')
+        flags.append('-fallback')
+
     return info.type, info.version, flags
 
 
 @template
 def default_c_compilers(host_or_target):
     '''Template defining the set of default C compilers for the host and
     target platforms.
     `host_or_target` is either `host` or `target` (the @depends functions