Bug 1371465 - Move MSVS_VERSION to moz.configure and properly define for vs2017; r=glandium
authorGregory Szorc <gps@mozilla.com>
Wed, 14 Jun 2017 16:52:55 -0700
changeset 364238 398d9d49677547b1b9f106370858c925de8c1511
parent 364237 0e13adff6e7eb3551d08f10d36edcdf377d40cbe
child 364239 1bd20be7a42c2d7703db0a1f90586eee8a074ab6
push id32036
push userarchaeopteryx@coole-files.de
push dateFri, 16 Jun 2017 07:47:22 +0000
treeherdermozilla-central@64a2ba65f0d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1371465
milestone56.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 1371465 - Move MSVS_VERSION to moz.configure and properly define for vs2017; r=glandium Before, MSVS was set in old-configure and could only be unset or "2015." We move the definition of the variable to moz.configure and support defining its value as "2017" when VS2017 is being used. As part of this, I discovered that GYP barfs with a "2017" value. This is likely a limitation of the legacy version of GYP we have vendored. Rather than go down the rabbit hole of upgrading GYP, I added code to convert the value to "2015." This preserves existing behavior and unblocks us from setting MSVS_VERSION properly. A warning is emitted to remind us to remove this hack once GYP is upgraded. After this commit, we now generate native VS2017 solutions and projects when building with VS2017. MozReview-Commit-ID: BvNJX3F8qCn
build/moz.configure/toolchain.configure
js/src/old-configure.in
old-configure.in
python/mozbuild/mozbuild/frontend/gyp_reader.py
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -868,16 +868,30 @@ host_c_compiler = compiler('C', host, ot
 host_cxx_compiler = compiler('C++', host, c_compiler=host_c_compiler,
                              other_compiler=cxx_compiler,
                              other_c_compiler=c_compiler)
 
 # Generic compiler-based conditions.
 non_msvc_compiler = depends(c_compiler)(lambda info: info.type != 'msvc')
 building_with_gcc = depends(c_compiler)(lambda info: info.type == 'gcc')
 
+@depends(c_compiler)
+def msvs_version(info):
+    # clang-cl emulates the same version scheme as cl. And MSVS_VERSION needs to
+    # be set for GYP on Windows.
+    if info.type in ('clang-cl', 'msvc'):
+        if info.version >= '19.10':
+            return '2017'
+        elif info.version >= '19.00':
+            return '2015'
+
+    return ''
+
+set_config('MSVS_VERSION', msvs_version)
+
 include('compile-checks.configure')
 
 @depends(have_64_bit,
          try_compile(body='static_assert(sizeof(void *) == 8, "")',
                      check_msg='for 64-bit OS'))
 def check_have_64_bit(have_64_bit, compiler_have_64_bit):
     if have_64_bit != compiler_have_64_bit:
         configure_error('The target compiler does not agree with configure '
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -176,31 +176,29 @@ case "$target" in
 
         AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
         AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
         AC_DEFINE(_USE_MATH_DEFINES) # Otherwise MSVC's math.h doesn't #define M_PI.
 
         case "$CC_VERSION" in
         19*)
             _CC_SUITE=14
-            MSVS_VERSION=2015
             MSVC_C_RUNTIME_DLL=vcruntime140.dll
             MSVC_CXX_RUNTIME_DLL=msvcp140.dll
 
             # C5026: move constructor was implicitly defined as deleted
             CXXFLAGS="$CXXFLAGS -wd5026"
 
             # C5027: move assignment operator was implicitly defined as deleted
             CXXFLAGS="$CXXFLAGS -wd5027"
 
             # -Zc:sizedDealloc- disables C++14 global sized deallocation (see bug 1160146)
             CXXFLAGS="$CXXFLAGS -Zc:sizedDealloc-"
             ;;
         esac
-        AC_SUBST(MSVS_VERSION)
         AC_SUBST(MSVC_C_RUNTIME_DLL)
         AC_SUBST(MSVC_CXX_RUNTIME_DLL)
 
         # Check linker version
         _LD_FULL_VERSION=`"${LINK}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
         _LD_MAJOR_VERSION=`echo ${_LD_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
         if test "$_LD_MAJOR_VERSION" != "$_CC_SUITE"; then
             AC_MSG_ERROR([The linker major version, $_LD_FULL_VERSION,  does not match the compiler suite version, $_CC_SUITE.])
--- a/old-configure.in
+++ b/old-configure.in
@@ -233,17 +233,16 @@ case "$target" in
 
         AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
         AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
         AC_DEFINE(_USE_MATH_DEFINES) # Otherwise MSVC's math.h doesn't #define M_PI.
 
         case "$CC_VERSION" in
         19*)
             _CC_SUITE=14
-            MSVS_VERSION=2015
             MSVC_C_RUNTIME_DLL=vcruntime140.dll
             MSVC_CXX_RUNTIME_DLL=msvcp140.dll
 
             MOZ_CHECK_HEADER(dia2.h, MSVC_HAS_DIA_SDK=1)
             if test -n "$MSVC_HAS_DIA_SDK"; then
                 AC_DEFINE(MSVC_HAS_DIA_SDK)
             fi
 
@@ -270,17 +269,16 @@ case "$target" in
             if test -n "$WIN_UCRT_REDIST_DIR"; then
               if test ! -d "$WIN_UCRT_REDIST_DIR"; then
                 AC_MSG_ERROR([Invalid Windows UCRT Redist directory: ${WIN_UCRT_REDIST_DIR}])
               fi
               WIN_UCRT_REDIST_DIR=`cd "$WIN_UCRT_REDIST_DIR" && pwd -W`
             fi
             ;;
         esac
-        AC_SUBST(MSVS_VERSION)
         AC_SUBST(MSVC_HAS_DIA_SDK)
         AC_SUBST(MSVC_C_RUNTIME_DLL)
         AC_SUBST(MSVC_CXX_RUNTIME_DLL)
 
         AC_DEFINE(HAVE_SEH_EXCEPTIONS)
 
         if test -n "$WIN32_REDIST_DIR"; then
           if test ! -d "$WIN32_REDIST_DIR"; then
--- a/python/mozbuild/mozbuild/frontend/gyp_reader.py
+++ b/python/mozbuild/mozbuild/frontend/gyp_reader.py
@@ -5,16 +5,18 @@
 from __future__ import absolute_import, unicode_literals
 
 import gyp
 import gyp.msvs_emulation
 import sys
 import os
 import time
 import types
+import warnings
+
 import mozpack.path as mozpath
 from mozpack.files import FileFinder
 from .sandbox import alphabetical_sorted
 from .context import (
     ObjDirPath,
     SourcePath,
     TemplateContext,
     VARIABLES,
@@ -367,17 +369,24 @@ class GypProcessor(object):
 
         # gyp expects plain str instead of unicode. The frontend code gives us
         # unicode strings, so convert them.
         path = encode(path)
         if bool(config.substs['_MSC_VER']):
             # This isn't actually used anywhere in this generator, but it's needed
             # to override the registry detection of VC++ in gyp.
             os.environ['GYP_MSVS_OVERRIDE_PATH'] = 'fake_path'
-            os.environ['GYP_MSVS_VERSION'] = config.substs['MSVS_VERSION']
+
+            # TODO bug 1371485 upgrade vendored version of GYP to something that
+            # doesn't barf when MSVS_VERSION==2017.
+            msvs_version = config.substs['MSVS_VERSION']
+            if msvs_version == '2017':
+                warnings.warn('MSVS_VERSION being set to 2015 to appease GYP')
+                msvs_version = '2015'
+            os.environ['GYP_MSVS_VERSION'] = msvs_version
 
         params = {
             b'parallel': False,
             b'generator_flags': {},
             b'build_files': [path],
             b'root_targets': None,
         }