From ca9747ace3aac92d3b18ec164f05eed1200925f8 Mon Sep 17 00:00:00 2001 From: David Gebler Date: Mon, 1 Feb 2021 14:26:02 +0000 Subject: [PATCH 1/3] Add IL compat flag to Windows builds, see https://github.com/microsoft/php-sdk-binary-tools/issues/72 --- win32/build/config.w32 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/win32/build/config.w32 b/win32/build/config.w32 index 64053cc056367..f1e13b8455fd2 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -130,6 +130,11 @@ ADD_FLAG("ARFLAGS", '/nologo /libpath:"' + php_usual_lib_suspects + '" '); probe_basic_headers(); add_extra_dirs(); +// Allow compatible IL versions, do not require an exact match. +// Prevents build failures where different libs were built with different (but compatible) IL versions. +// See fatal error C1047. +ADD_FLAG("LDFLAGS", "/d2:-AllowCompatibleILVersions "); + //DEFINE("PHP_BUILD", PHP_PHP_BUILD); ARG_WITH("analyzer", "Enable static analyzer. Pass vs for Visual Studio, clang for clang, cppcheck for Cppcheck, pvs for PVS-Studio", "no"); From 7df9c6b12a95699b18a6eb3ac407685911d64788 Mon Sep 17 00:00:00 2001 From: David Gebler Date: Tue, 2 Feb 2021 15:40:50 +0000 Subject: [PATCH 2/3] make compat flag optional for vc17/19/+ --- win32/build/config.w32 | 5 ----- win32/build/confutils.js | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/win32/build/config.w32 b/win32/build/config.w32 index f1e13b8455fd2..64053cc056367 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -130,11 +130,6 @@ ADD_FLAG("ARFLAGS", '/nologo /libpath:"' + php_usual_lib_suspects + '" '); probe_basic_headers(); add_extra_dirs(); -// Allow compatible IL versions, do not require an exact match. -// Prevents build failures where different libs were built with different (but compatible) IL versions. -// See fatal error C1047. -ADD_FLAG("LDFLAGS", "/d2:-AllowCompatibleILVersions "); - //DEFINE("PHP_BUILD", PHP_PHP_BUILD); ARG_WITH("analyzer", "Enable static analyzer. Pass vs for Visual Studio, clang for clang, cppcheck for Cppcheck, pvs for PVS-Studio", "no"); diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 19fbd52aa999c..84a304c9412c6 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -3404,6 +3404,14 @@ function toolset_setup_common_ldlags() ADD_FLAG('LDFLAGS', "/GUARD:CF"); } } + if (VCVERS >= 1910) { + if (PHP_VS_SOFT_LINKING == "yes") { + // Allow compatible IL versions, do not require an exact match. + // Prevents build failures where different libs were built with different (but compatible) IL versions. + // See fatal error C1047. + ADD_FLAG("LDFLAGS", "/d2:-AllowCompatibleILVersions "); + } + } } } @@ -3753,3 +3761,9 @@ function setup_verbosity() CMD_MOD2 = "@"; } } + +try { +ARG_ENABLE('vs-soft-linking', 'Allow linking of libraries built with compatible versions of VS toolset', 'no'); +} catch (e) { + STDOUT.WriteLine("problem: " + e); +} From eaf34d644bdd8969ca18dd6d132aca84e3dafa1e Mon Sep 17 00:00:00 2001 From: David Gebler Date: Tue, 2 Feb 2021 15:44:21 +0000 Subject: [PATCH 3/3] enable vs compat by default --- win32/build/confutils.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 84a304c9412c6..6cbaf41d16679 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -3404,13 +3404,11 @@ function toolset_setup_common_ldlags() ADD_FLAG('LDFLAGS', "/GUARD:CF"); } } - if (VCVERS >= 1910) { - if (PHP_VS_SOFT_LINKING == "yes") { - // Allow compatible IL versions, do not require an exact match. - // Prevents build failures where different libs were built with different (but compatible) IL versions. - // See fatal error C1047. - ADD_FLAG("LDFLAGS", "/d2:-AllowCompatibleILVersions "); - } + if (PHP_VS_LINK_COMPAT != "no") { + // Allow compatible IL versions, do not require an exact match. + // Prevents build failures where different libs were built with different (but compatible) IL versions. + // See fatal error C1047. + ADD_FLAG("LDFLAGS", "/d2:-AllowCompatibleILVersions "); } } } @@ -3763,7 +3761,7 @@ function setup_verbosity() } try { -ARG_ENABLE('vs-soft-linking', 'Allow linking of libraries built with compatible versions of VS toolset', 'no'); +ARG_ENABLE('vs-link-compat', 'Allow linking of libraries built with compatible versions of VS toolset', 'yes'); } catch (e) { STDOUT.WriteLine("problem: " + e); }