From a2cffb3eb2948ec607d4a1111071b525071e8a9a Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Wed, 14 Aug 2024 13:47:08 +0200 Subject: [PATCH 1/5] Drop support for building with MSC_VER < 1900 `MSC_VER` 1900 refers to Visual Studio 2015[1], and this should be the bare minimum which we support nowadays. If users use an older Visual Studio version, we fail gracefully during `configure`. [1] --- win32/build/confutils.js | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/win32/build/confutils.js b/win32/build/confutils.js index b72950954c0f7..fefbc29821ad7 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -3064,7 +3064,9 @@ function toolset_get_compiler_version() if (VS_TOOLSET) { version = probe_binary(PHP_CL).substr(0, 5).replace('.', ''); - + if (version < 1900) { + ERROR("Building with MSC_VER " + version + " is no longer supported"); + } return version; } else if (CLANG_TOOLSET) { var command = 'cmd /c ""' + PHP_CL + '" -v"'; @@ -3288,19 +3290,15 @@ function toolset_setup_common_cflags() } } } - if (VCVERS >= 1900) { - if (PHP_SECURITY_FLAGS == "yes") { - ADD_FLAG('CFLAGS', "/guard:cf"); - } + if (PHP_SECURITY_FLAGS == "yes") { + ADD_FLAG('CFLAGS', "/guard:cf"); } - if (VCVERS >= 1800) { - if (PHP_PGI != "yes" && PHP_PGO != "yes") { - ADD_FLAG('CFLAGS', "/Zc:inline"); - } - /* We enable /opt:icf only with the debug pack, so /Gw only makes sense there, too. */ - if (PHP_DEBUG_PACK == "yes") { - ADD_FLAG('CFLAGS', "/Gw"); - } + if (PHP_PGI != "yes" && PHP_PGO != "yes") { + ADD_FLAG('CFLAGS', "/Zc:inline"); + } + /* We enable /opt:icf only with the debug pack, so /Gw only makes sense there, too. */ + if (PHP_DEBUG_PACK == "yes") { + ADD_FLAG('CFLAGS', "/Gw"); } } @@ -3436,10 +3434,8 @@ function toolset_setup_common_ldlags() ADD_FLAG("PHP_LDFLAGS", "/nodefaultlib:libcmt"); if (VS_TOOLSET) { - if (VCVERS >= 1900) { - if (PHP_SECURITY_FLAGS == "yes") { - ADD_FLAG('LDFLAGS', "/GUARD:CF"); - } + if (PHP_SECURITY_FLAGS == "yes") { + ADD_FLAG('LDFLAGS', "/GUARD:CF"); } if (PHP_VS_LINK_COMPAT != "no") { // Allow compatible IL versions, do not require an exact match. @@ -3610,13 +3606,8 @@ function add_extra_dirs() for (i = 0; i < path.length; i++) { f = FSO.GetAbsolutePathName(path[i]); if (FSO.FolderExists(f)) { - if (VS_TOOLSET && VCVERS <= 1200 && f.indexOf(" ") >= 0) { - ADD_FLAG("LDFLAGS", '/libpath:"\\"' + f + '\\"" '); - ADD_FLAG("ARFLAGS", '/libpath:"\\"' + f + '\\"" '); - } else { - ADD_FLAG("LDFLAGS", '/libpath:"' + f + '" '); - ADD_FLAG("ARFLAGS", '/libpath:"' + f + '" '); - } + ADD_FLAG("LDFLAGS", '/libpath:"' + f + '" '); + ADD_FLAG("ARFLAGS", '/libpath:"' + f + '" '); } } } From a429a3386b6e81a816002bfc64e7823929ac6dca Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Wed, 14 Aug 2024 13:50:23 +0200 Subject: [PATCH 2/5] Drop support for building with MSC_VER < 1910 `MSC_VER` 1910 refers to Visual Studio 2017 RTW[1], and this should be the bare minimum which we support nowadays. If users use an older Visual Studio version, we fail gracefully during `configure`. [1] --- win32/build/confutils.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/win32/build/confutils.js b/win32/build/confutils.js index fefbc29821ad7..4a41c720cb30c 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -3064,7 +3064,7 @@ function toolset_get_compiler_version() if (VS_TOOLSET) { version = probe_binary(PHP_CL).substr(0, 5).replace('.', ''); - if (version < 1900) { + if (version < 1910) { ERROR("Building with MSC_VER " + version + " is no longer supported"); } return version; @@ -3283,11 +3283,6 @@ function toolset_setup_common_cflags() /* Undocumented. */ ADD_FLAG('CFLAGS', "/d2guardspecload"); } - } else if (1900 == VCVERS) { - var subver1900 = probe_binary(PHP_CL).substr(6); - if (subver1900 >= 24241) { - ADD_FLAG('CFLAGS', "/Qspectre"); - } } } if (PHP_SECURITY_FLAGS == "yes") { From b48c6230f5c528929b8ad586311165568a85efaf Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Wed, 14 Aug 2024 14:08:06 +0200 Subject: [PATCH 3/5] Drop support for building with MSC_VER < 1920 `MSC_VER` 1920 refers to Visual Studio 2019 RTW 16.0[1], and this should be the bare minimum which we support nowadays. If users use an older Visual Studio version, we fail gracefully during `configure`. [1] --- win32/build/confutils.js | 42 +++++++++++----------------------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 4a41c720cb30c..29c1f2074e841 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -1249,16 +1249,12 @@ function SAPI(sapiname, file_list, makefiletarget, cflags, obj_dir) if (PHP_DEBUG != "yes" && PHP_PGI == "yes") { ADD_FLAG('CFLAGS_' + SAPI, "/GL /O2"); ADD_FLAG('LDFLAGS_' + SAPI, "/LTCG /GENPROFILE"); - if (VCVERS >= 1914) { - ADD_FLAG('LDFLAGS_' + SAPI, "/d2:-FuncCache1"); - } + ADD_FLAG('LDFLAGS_' + SAPI, "/d2:-FuncCache1"); } else if (PHP_DEBUG != "yes" && PHP_PGO != "no") { ADD_FLAG('CFLAGS_' + SAPI, "/GL /O2"); ADD_FLAG('LDFLAGS_' + SAPI, "/LTCG /USEPROFILE"); - if (VCVERS >= 1914) { - ADD_FLAG('LDFLAGS_' + SAPI, "/d2:-FuncCache1"); - } + ADD_FLAG('LDFLAGS_' + SAPI, "/d2:-FuncCache1"); } ldflags += " /PGD:$(PGOPGD_DIR)\\" + makefiletarget.substring(0, makefiletarget.indexOf(".")) + ".pgd"; @@ -1461,15 +1457,11 @@ function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir) // Add compiler and link flags if PGO options are selected if (PHP_DEBUG != "yes" && PHP_PGI == "yes") { ADD_FLAG('LDFLAGS_' + EXT, "/LTCG /GENPROFILE"); - if (VCVERS >= 1914) { - ADD_FLAG('LDFLAGS_' + EXT, "/d2:-FuncCache1"); - } + ADD_FLAG('LDFLAGS_' + EXT, "/d2:-FuncCache1"); } else if (PHP_DEBUG != "yes" && PHP_PGO != "no") { ADD_FLAG('LDFLAGS_' + EXT, "/LTCG /USEPROFILE"); - if (VCVERS >= 1914) { - ADD_FLAG('LDFLAGS_' + EXT, "/d2:-FuncCache1"); - } + ADD_FLAG('LDFLAGS_' + EXT, "/d2:-FuncCache1"); } ADD_FLAG('CFLAGS_' + EXT, "/GL /O2"); @@ -3064,7 +3056,8 @@ function toolset_get_compiler_version() if (VS_TOOLSET) { version = probe_binary(PHP_CL).substr(0, 5).replace('.', ''); - if (version < 1910) { + ERROR(version); + if (version < 1920) { ERROR("Building with MSC_VER " + version + " is no longer supported"); } return version; @@ -3273,17 +3266,8 @@ function toolset_setup_common_cflags() ADD_FLAG('CFLAGS', ' /RTC1 '); } else { if (PHP_DEBUG == "no" && PHP_SECURITY_FLAGS == "yes") { - /* Mitigations for CVE-2017-5753. - TODO backport for all supported VS versions when they release it. */ - if (VCVERS >= 1912) { - var subver1912 = probe_binary(PHP_CL).substr(6); - if (VCVERS >= 1913 || 1912 == VCVERS && subver1912 >= 25835) { - ADD_FLAG('CFLAGS', "/Qspectre"); - } else { - /* Undocumented. */ - ADD_FLAG('CFLAGS', "/d2guardspecload"); - } - } + /* Mitigations for CVE-2017-5753. */ + ADD_FLAG('CFLAGS', "/Qspectre"); } if (PHP_SECURITY_FLAGS == "yes") { ADD_FLAG('CFLAGS', "/guard:cf"); @@ -3297,14 +3281,10 @@ function toolset_setup_common_cflags() } } - if (VCVERS >= 1914) { - /* This is only in effect for CXX sources, __cplusplus is not defined in C sources. */ - ADD_FLAG("CFLAGS", "/Zc:__cplusplus"); - } + /* This is only in effect for CXX sources, __cplusplus is not defined in C sources. */ + ADD_FLAG("CFLAGS", "/Zc:__cplusplus"); - if (VCVERS >= 1914) { - ADD_FLAG("CFLAGS", "/d2FuncCache1"); - } + ADD_FLAG("CFLAGS", "/d2FuncCache1"); if (VCVERS >= 1930) { ADD_FLAG("CFLAGS", "/Zc:preprocessor"); From c669a5354ff32be4d9f5466fb9cb521119db6ae7 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Wed, 14 Aug 2024 15:01:36 +0200 Subject: [PATCH 4/5] oops --- win32/build/confutils.js | 1 - 1 file changed, 1 deletion(-) diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 29c1f2074e841..90bb451ed5fb2 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -3056,7 +3056,6 @@ function toolset_get_compiler_version() if (VS_TOOLSET) { version = probe_binary(PHP_CL).substr(0, 5).replace('.', ''); - ERROR(version); if (version < 1920) { ERROR("Building with MSC_VER " + version + " is no longer supported"); } From 1c4b1b0fb25f98f2ae802fa34aa2b47678f0f97c Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Thu, 15 Aug 2024 15:40:46 +0200 Subject: [PATCH 5/5] Remove handling of unsupported VS versions from toolset_get_compiler_name() Since we error out in `toolset_get_compiler_version()` now, there is even no more need to raise an error here. --- win32/build/confutils.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 90bb451ed5fb2..8a2c88dd639ae 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -3099,7 +3099,7 @@ function toolset_get_compiler_name(short) version = probe_binary(PHP_CL).substr(0, 5).replace('.', ''); if (version >= 1950) { - return name; + // skip } else if (version >= 1930) { name = short ? "VS17" : "Visual C++ 2022"; } else if (version >= 1920) { @@ -3110,12 +3110,6 @@ function toolset_get_compiler_name(short) 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; @@ -3123,7 +3117,7 @@ function toolset_get_compiler_name(short) var command = 'cmd /c ""' + PHP_CL + '" -v"'; var full = execute(command + '" 2>&1"'); - return full.split(/\n/)[0].replace(/\s/g, ' '); + ERROR(full.split(/\n/)[0].replace(/\s/g, ' ')); } WARNING("Unsupported toolset");