Skip to content

Drop support for building with old Visual Studio versions #15403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 26 additions & 67 deletions win32/build/confutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -3064,7 +3056,9 @@ function toolset_get_compiler_version()

if (VS_TOOLSET) {
version = probe_binary(PHP_CL).substr(0, 5).replace('.', '');

if (version < 1920) {
ERROR("Building with MSC_VER " + version + " is no longer supported");
}
return version;
} else if (CLANG_TOOLSET) {
var command = 'cmd /c ""' + PHP_CL + '" -v"';
Expand Down Expand Up @@ -3105,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) {
Expand All @@ -3116,20 +3110,14 @@ 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;
} else if (CLANG_TOOLSET || ICC_TOOLSET) {
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");
Expand Down Expand Up @@ -3271,47 +3259,25 @@ 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");
}
} else if (1900 == VCVERS) {
var subver1900 = probe_binary(PHP_CL).substr(6);
if (subver1900 >= 24241) {
ADD_FLAG('CFLAGS', "/Qspectre");
}
}
/* Mitigations for CVE-2017-5753. */
ADD_FLAG('CFLAGS', "/Qspectre");
}
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");
}
}

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");
Expand Down Expand Up @@ -3436,10 +3402,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.
Expand Down Expand Up @@ -3610,13 +3574,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 + '" ');
}
}
}
Expand Down
Loading