Skip to content

Commit b3d6414

Browse files
committed
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] <https://learn.microsoft.com/en-us/cpp/overview/compiler-versions?view=msvc-170> Closes GH-15403.
1 parent a8df3d1 commit b3d6414

File tree

2 files changed

+29
-67
lines changed

2 files changed

+29
-67
lines changed

UPGRADING

+3
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,9 @@ PHP 8.4 UPGRADE NOTES
10851085
12. Windows Support
10861086
========================================
10871087

1088+
* Building with Visual Studio now requires at least Visual Studio 2019 (Visual
1089+
Studio 2022 is recommended, though).
1090+
10881091
* Native AVX-512 builds are now supported (--enable-native-intrinsics=avx512).
10891092

10901093
========================================

win32/build/confutils.js

+26-67
Original file line numberDiff line numberDiff line change
@@ -1249,16 +1249,12 @@ function SAPI(sapiname, file_list, makefiletarget, cflags, obj_dir)
12491249
if (PHP_DEBUG != "yes" && PHP_PGI == "yes") {
12501250
ADD_FLAG('CFLAGS_' + SAPI, "/GL /O2");
12511251
ADD_FLAG('LDFLAGS_' + SAPI, "/LTCG /GENPROFILE");
1252-
if (VCVERS >= 1914) {
1253-
ADD_FLAG('LDFLAGS_' + SAPI, "/d2:-FuncCache1");
1254-
}
1252+
ADD_FLAG('LDFLAGS_' + SAPI, "/d2:-FuncCache1");
12551253
}
12561254
else if (PHP_DEBUG != "yes" && PHP_PGO != "no") {
12571255
ADD_FLAG('CFLAGS_' + SAPI, "/GL /O2");
12581256
ADD_FLAG('LDFLAGS_' + SAPI, "/LTCG /USEPROFILE");
1259-
if (VCVERS >= 1914) {
1260-
ADD_FLAG('LDFLAGS_' + SAPI, "/d2:-FuncCache1");
1261-
}
1257+
ADD_FLAG('LDFLAGS_' + SAPI, "/d2:-FuncCache1");
12621258
}
12631259

12641260
ldflags += " /PGD:$(PGOPGD_DIR)\\" + makefiletarget.substring(0, makefiletarget.indexOf(".")) + ".pgd";
@@ -1461,15 +1457,11 @@ function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir)
14611457
// Add compiler and link flags if PGO options are selected
14621458
if (PHP_DEBUG != "yes" && PHP_PGI == "yes") {
14631459
ADD_FLAG('LDFLAGS_' + EXT, "/LTCG /GENPROFILE");
1464-
if (VCVERS >= 1914) {
1465-
ADD_FLAG('LDFLAGS_' + EXT, "/d2:-FuncCache1");
1466-
}
1460+
ADD_FLAG('LDFLAGS_' + EXT, "/d2:-FuncCache1");
14671461
}
14681462
else if (PHP_DEBUG != "yes" && PHP_PGO != "no") {
14691463
ADD_FLAG('LDFLAGS_' + EXT, "/LTCG /USEPROFILE");
1470-
if (VCVERS >= 1914) {
1471-
ADD_FLAG('LDFLAGS_' + EXT, "/d2:-FuncCache1");
1472-
}
1464+
ADD_FLAG('LDFLAGS_' + EXT, "/d2:-FuncCache1");
14731465
}
14741466

14751467
ADD_FLAG('CFLAGS_' + EXT, "/GL /O2");
@@ -3064,7 +3056,9 @@ function toolset_get_compiler_version()
30643056

30653057
if (VS_TOOLSET) {
30663058
version = probe_binary(PHP_CL).substr(0, 5).replace('.', '');
3067-
3059+
if (version < 1920) {
3060+
ERROR("Building with MSC_VER " + version + " is no longer supported");
3061+
}
30683062
return version;
30693063
} else if (CLANG_TOOLSET) {
30703064
var command = 'cmd /c ""' + PHP_CL + '" -v"';
@@ -3106,7 +3100,7 @@ function toolset_get_compiler_name(short)
31063100
version = probe_binary(PHP_CL).substr(0, 5).replace('.', '');
31073101

31083102
if (version >= 1950) {
3109-
return name;
3103+
// skip
31103104
} else if (version >= 1930) {
31113105
name = short ? "VS17" : "Visual C++ 2022";
31123106
} else if (version >= 1920) {
@@ -3117,20 +3111,14 @@ function toolset_get_compiler_name(short)
31173111
When new versions are introduced, adapt also checks in
31183112
php_win32_image_compatible(), if needed. */
31193113
name = short ? "VS16" : "Visual C++ 2019";
3120-
} else if (version >= 1910) {
3121-
name = short ? "VC15" : "Visual C++ 2017";
3122-
} else if (version >= 1900) {
3123-
name = short ? "VC14" : "Visual C++ 2015";
3124-
} else {
3125-
ERROR("Unsupported Visual C++ compiler " + version);
31263114
}
31273115

31283116
return name;
31293117
} else if (CLANG_TOOLSET || ICC_TOOLSET) {
31303118
var command = 'cmd /c ""' + PHP_CL + '" -v"';
31313119
var full = execute(command + '" 2>&1"');
31323120

3133-
return full.split(/\n/)[0].replace(/\s/g, ' ');
3121+
ERROR(full.split(/\n/)[0].replace(/\s/g, ' '));
31343122
}
31353123

31363124
WARNING("Unsupported toolset");
@@ -3272,47 +3260,25 @@ function toolset_setup_common_cflags()
32723260
ADD_FLAG('CFLAGS', ' /RTC1 ');
32733261
} else {
32743262
if (PHP_DEBUG == "no" && PHP_SECURITY_FLAGS == "yes") {
3275-
/* Mitigations for CVE-2017-5753.
3276-
TODO backport for all supported VS versions when they release it. */
3277-
if (VCVERS >= 1912) {
3278-
var subver1912 = probe_binary(PHP_CL).substr(6);
3279-
if (VCVERS >= 1913 || 1912 == VCVERS && subver1912 >= 25835) {
3280-
ADD_FLAG('CFLAGS', "/Qspectre");
3281-
} else {
3282-
/* Undocumented. */
3283-
ADD_FLAG('CFLAGS', "/d2guardspecload");
3284-
}
3285-
} else if (1900 == VCVERS) {
3286-
var subver1900 = probe_binary(PHP_CL).substr(6);
3287-
if (subver1900 >= 24241) {
3288-
ADD_FLAG('CFLAGS', "/Qspectre");
3289-
}
3290-
}
3263+
/* Mitigations for CVE-2017-5753. */
3264+
ADD_FLAG('CFLAGS', "/Qspectre");
32913265
}
3292-
if (VCVERS >= 1900) {
3293-
if (PHP_SECURITY_FLAGS == "yes") {
3294-
ADD_FLAG('CFLAGS', "/guard:cf");
3295-
}
3266+
if (PHP_SECURITY_FLAGS == "yes") {
3267+
ADD_FLAG('CFLAGS', "/guard:cf");
32963268
}
3297-
if (VCVERS >= 1800) {
3298-
if (PHP_PGI != "yes" && PHP_PGO != "yes") {
3299-
ADD_FLAG('CFLAGS', "/Zc:inline");
3300-
}
3301-
/* We enable /opt:icf only with the debug pack, so /Gw only makes sense there, too. */
3302-
if (PHP_DEBUG_PACK == "yes") {
3303-
ADD_FLAG('CFLAGS', "/Gw");
3304-
}
3269+
if (PHP_PGI != "yes" && PHP_PGO != "yes") {
3270+
ADD_FLAG('CFLAGS', "/Zc:inline");
3271+
}
3272+
/* We enable /opt:icf only with the debug pack, so /Gw only makes sense there, too. */
3273+
if (PHP_DEBUG_PACK == "yes") {
3274+
ADD_FLAG('CFLAGS', "/Gw");
33053275
}
33063276
}
33073277

3308-
if (VCVERS >= 1914) {
3309-
/* This is only in effect for CXX sources, __cplusplus is not defined in C sources. */
3310-
ADD_FLAG("CFLAGS", "/Zc:__cplusplus");
3311-
}
3278+
/* This is only in effect for CXX sources, __cplusplus is not defined in C sources. */
3279+
ADD_FLAG("CFLAGS", "/Zc:__cplusplus");
33123280

3313-
if (VCVERS >= 1914) {
3314-
ADD_FLAG("CFLAGS", "/d2FuncCache1");
3315-
}
3281+
ADD_FLAG("CFLAGS", "/d2FuncCache1");
33163282

33173283
if (VCVERS >= 1930) {
33183284
ADD_FLAG("CFLAGS", "/Zc:preprocessor");
@@ -3438,10 +3404,8 @@ function toolset_setup_common_ldlags()
34383404
ADD_FLAG("PHP_LDFLAGS", "/nodefaultlib:libcmt");
34393405

34403406
if (VS_TOOLSET) {
3441-
if (VCVERS >= 1900) {
3442-
if (PHP_SECURITY_FLAGS == "yes") {
3443-
ADD_FLAG('LDFLAGS', "/GUARD:CF");
3444-
}
3407+
if (PHP_SECURITY_FLAGS == "yes") {
3408+
ADD_FLAG('LDFLAGS', "/GUARD:CF");
34453409
}
34463410
if (PHP_VS_LINK_COMPAT != "no") {
34473411
// Allow compatible IL versions, do not require an exact match.
@@ -3612,13 +3576,8 @@ function add_extra_dirs()
36123576
for (i = 0; i < path.length; i++) {
36133577
f = FSO.GetAbsolutePathName(path[i]);
36143578
if (FSO.FolderExists(f)) {
3615-
if (VS_TOOLSET && VCVERS <= 1200 && f.indexOf(" ") >= 0) {
3616-
ADD_FLAG("LDFLAGS", '/libpath:"\\"' + f + '\\"" ');
3617-
ADD_FLAG("ARFLAGS", '/libpath:"\\"' + f + '\\"" ');
3618-
} else {
3619-
ADD_FLAG("LDFLAGS", '/libpath:"' + f + '" ');
3620-
ADD_FLAG("ARFLAGS", '/libpath:"' + f + '" ');
3621-
}
3579+
ADD_FLAG("LDFLAGS", '/libpath:"' + f + '" ');
3580+
ADD_FLAG("ARFLAGS", '/libpath:"' + f + '" ');
36223581
}
36233582
}
36243583
}

0 commit comments

Comments
 (0)