]> granicus.if.org Git - php/commitdiff
Rework the VS version evaluation
authorAnatol Belski <ab@php.net>
Sun, 31 Mar 2019 12:18:12 +0000 (14:18 +0200)
committerAnatol Belski <ab@php.net>
Sun, 31 Mar 2019 12:26:00 +0000 (14:26 +0200)
For the latest versions, refer also to the Visual Studio version, not to
the exact toolset version. The latest Visual Studio versions are moving
fast and the method existed previously is not sutable to keep up
anymore. Instead of refering to the exact toolset, it refers to the
Visual Studio version and implies the latest toolset available there.
That is still not ideal, another situation can arise where VS version is
not changed, but the toolset version is. It might be better to refer to
it a generic way in the future or even omit at all, and improve the
internal compatibility checks instead.

win32/build/confutils.js

index ab97a0afff974e8b40ad51182b926fef01ff0f4b..7a33ce6cfed682ac06f0f742e9aaefae6e709043 100644 (file)
@@ -35,7 +35,8 @@ var VCVERS = -1;
 var CLANGVERS = -1;
 var INTELVERS = -1;
 var COMPILER_NUMERIC_VERSION = -1;
-var COMPILER_NAME = "unknown";
+var COMPILER_NAME_LONG = "unknown";
+var COMPILER_NAME_SHORT = "unknown";
 var PHP_OBJECT_OUT_DIR = "";
 var PHP_CONFIG_PROFILE = "no";
 var PHP_SANITIZER = "no";
@@ -71,31 +72,6 @@ var headers_install = new Array();
 /* Store unknown configure options */
 var INVALID_CONFIG_ARGS = new Array();
 
-/* Mapping CL version > human readable name */
-var VC_VERSIONS = new Array();
-VC_VERSIONS[1700] = 'MSVC11 (Visual C++ 2012)';
-VC_VERSIONS[1800] = 'MSVC12 (Visual C++ 2013)';
-VC_VERSIONS[1900] = 'MSVC14 (Visual C++ 2015)';
-VC_VERSIONS[1910] = 'MSVC15 (Visual C++ 2017)';
-VC_VERSIONS[1911] = 'MSVC15 (Visual C++ 2017)';
-VC_VERSIONS[1912] = 'MSVC15 (Visual C++ 2017)';
-VC_VERSIONS[1913] = 'MSVC15 (Visual C++ 2017)';
-VC_VERSIONS[1914] = 'MSVC15 (Visual C++ 2017)';
-VC_VERSIONS[1915] = 'MSVC15 (Visual C++ 2017)';
-VC_VERSIONS[1916] = 'MSVC15 (Visual C++ 2017)';
-
-var VC_VERSIONS_SHORT = new Array();
-VC_VERSIONS_SHORT[1700] = 'VC11';
-VC_VERSIONS_SHORT[1800] = 'VC12';
-VC_VERSIONS_SHORT[1900] = 'VC14';
-VC_VERSIONS_SHORT[1910] = 'VC15';
-VC_VERSIONS_SHORT[1911] = 'VC15';
-VC_VERSIONS_SHORT[1912] = 'VC15';
-VC_VERSIONS_SHORT[1913] = 'VC15';
-VC_VERSIONS_SHORT[1914] = 'VC15';
-VC_VERSIONS_SHORT[1915] = 'VC15';
-VC_VERSIONS_SHORT[1916] = 'VC15';
-
 if (PROGRAM_FILES == null) {
        PROGRAM_FILES = "C:\\Program Files";
 }
@@ -1975,7 +1951,7 @@ function write_summary()
        }
        ar[k++] = ['Build type', PHP_DEBUG == "yes" ? "Debug" : "Release"];
        ar[k++] = ['Thread Safety', PHP_ZTS == "yes" ? "Yes" : "No"];
-       ar[k++] = ['Compiler', COMPILER_NAME];
+       ar[k++] = ['Compiler', COMPILER_NAME_LONG];
        ar[k++] = ['Architecture', X64 ? 'x64' : 'x86'];
        if (PHP_PGO == "yes") {
                ar[k++] = ['Optimization', "PGO"];
@@ -2956,56 +2932,41 @@ function toolset_setup_compiler()
        }
 
        COMPILER_NUMERIC_VERSION = toolset_get_compiler_version();
-       COMPILER_NAME = toolset_get_compiler_name();
+       COMPILER_NAME_LONG = toolset_get_compiler_name();
+       COMPILER_NAME_SHORT = toolset_get_compiler_name(true);
 
        if (VS_TOOLSET) {
-               /* For the record here: */
-               // 1200 is VC6
-               // 1300 is vs.net 2002
-               // 1310 is vs.net 2003
-               // 1400 is vs.net 2005
-               // 1500 is vs.net 2008
-               // 1600 is vs.net 2010
-               // 1700 is vs.net 2011
-               // 1800 is vs.net 2012
-               // 1900 is vs.net 2015
-               // 1910 is vs.net 2017
-               // Which version of the compiler do we have?
                VCVERS = COMPILER_NUMERIC_VERSION;
 
-               if (VCVERS < 1700) {
-                       ERROR("Unsupported MS C++ Compiler, VC11 (2011) minimum is required");
-               }
-
-               if (undefined == COMPILER_NAME) {
+               if ("unknown" == COMPILER_NAME_LONG) {
                        var tmp = probe_binary(PHP_CL);
                        COMPILER_NAME = "MSVC " + tmp + ", untested";
 
                        WARNING("Using unknown MSVC version " + tmp);
 
-                       AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version");
+                       AC_DEFINE('COMPILER', COMPILER_NAME_LONG, "Detected compiler version");
                        DEFINE("PHP_COMPILER_SHORT", tmp);
                        AC_DEFINE('PHP_COMPILER_ID', tmp, "Compiler compatibility ID");
                } else {
-                       AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version");
-                       DEFINE("PHP_COMPILER_SHORT", VC_VERSIONS_SHORT[VCVERS]);
-                       AC_DEFINE('PHP_COMPILER_ID', VC_VERSIONS_SHORT[VCVERS], "Compiler compatibility ID");
+                       AC_DEFINE('COMPILER', COMPILER_NAME_LONG, "Detected compiler version");
+                       DEFINE("PHP_COMPILER_SHORT", COMPILER_NAME_SHORT.toLowerCase());
+                       AC_DEFINE('PHP_COMPILER_ID', COMPILER_NAME_SHORT.toUpperCase(), "Compiler compatibility ID");
                }
        } else if (CLANG_TOOLSET) {
                CLANGVERS = COMPILER_NUMERIC_VERSION;
 
-               AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version");
+               AC_DEFINE('COMPILER', COMPILER_NAME_LONG, "Detected compiler version");
                DEFINE("PHP_COMPILER_SHORT", "clang");
                AC_DEFINE('PHP_COMPILER_ID', "clang"); /* XXX something better were to write here */
 
        } else if (ICC_TOOLSET) {
                INTELVERS = COMPILER_NUMERIC_VERSION;
 
-               AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version");
+               AC_DEFINE('COMPILER', COMPILER_NAME_LONG, "Detected compiler version");
                DEFINE("PHP_COMPILER_SHORT", "icc");
                AC_DEFINE('PHP_COMPILER_ID', "icc"); /* XXX something better were to write here */
        }
-       STDOUT.WriteLine("  Detected compiler " + COMPILER_NAME);
+       STDOUT.WriteLine("  Detected compiler " + COMPILER_NAME_LONG);
 }
 
 function toolset_setup_project_tools()
@@ -3130,17 +3091,32 @@ function toolset_get_compiler_version()
 }
 
 /* Get compiler name if the toolset is supported */
-function toolset_get_compiler_name()
+function toolset_get_compiler_name(short)
 {
        var version;
+       short = !!short;
 
        if (VS_TOOLSET) {
-               var name = undefined;
+               var name = "unknown";
 
                version = probe_binary(PHP_CL).substr(0, 5).replace('.', '');
 
-               if (undefined != VC_VERSIONS[version]) {
-                       name = VC_VERSIONS[version];
+               if (version >= 1930) {
+                       return name;
+               } if (version >= 1920) {
+                       /* NOTE - VS is intentional. Due to changes in recent Visual Studio
+                                               versioning scheme refering to the exact VC++ version is
+                                               hardly predictable. From this version on, it refers to 
+                                               Visual Studio version and implies the default toolset.
+                                               When new versions are introduced, adapt also checks in
+                                               php_win32_image_compatible(), if needed. */
+                       name = short ? "VS16" : "Visual C++ 2019";
+               } else if (version >= 1910) {
+                       name = short ? "VC15" : "Visual C++ 2017";
+               } else if (version >= 1900) {
+                       name = short ? "VC14" : "Visual C++ 2015";
+               } else {
+                       ERROR("Unsupported Visual C++ compiler " + version);
                }
 
                return name;
@@ -3211,16 +3187,29 @@ function toolset_setup_codegen_arch()
 
 function toolset_setup_linker()
 {
+       var lnk = false;
        if (VS_TOOLSET) {
-               return PATH_PROG('link', null);
+               lnk = PATH_PROG('link', null);
        } else if (CLANG_TOOLSET) {
                //return PATH_PROG('lld', WshShell.Environment("Process").Item("PATH"), "LINK");
-               return PATH_PROG('link', WshShell.Environment("Process").Item("PATH"));
+               lnk = PATH_PROG('link', WshShell.Environment("Process").Item("PATH"));
        } else if (ICC_TOOLSET) {
-               return PATH_PROG('xilink', WshShell.Environment("Process").Item("PATH"), "LINK");
+               lnk = PATH_PROG('xilink', WshShell.Environment("Process").Item("PATH"), "LINK");
        }
 
-       ERROR("Unsupported toolset");
+       if (!lnk) {
+               ERROR("Unsupported toolset");
+       }
+
+       var ver = probe_binary(lnk);
+
+       var major = ver.substr(0, 2);
+       var minor = ver.substr(3, 2);
+
+       AC_DEFINE('PHP_LINKER_MAJOR', major, "Linker major version", false);
+       AC_DEFINE('PHP_LINKER_MINOR', minor, "Linker minor version", false);
+
+       return lnk;
 }
 
 function toolset_setup_common_cflags()
@@ -3409,7 +3398,7 @@ function toolset_setup_common_ldlags()
 function toolset_setup_common_libs()
 {
        // urlmon.lib ole32.lib oleaut32.lib uuid.lib gdi32.lib winspool.lib comdlg32.lib
-       DEFINE("LIBS", "kernel32.lib ole32.lib user32.lib advapi32.lib shell32.lib ws2_32.lib Dnsapi.lib psapi.lib bcrypt.lib");
+       DEFINE("LIBS", "kernel32.lib ole32.lib user32.lib advapi32.lib shell32.lib ws2_32.lib Dnsapi.lib psapi.lib bcrypt.lib imagehlp.lib");
 }
 
 function toolset_setup_build_mode()