From: Christoph M. Becker Date: Wed, 27 May 2020 10:01:16 +0000 (+0200) Subject: Drop hard-coded /W3 default in favor of custom CFLAGS X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3a031e0b03f11b40b8b374472336d9a6df4d81b8;p=php Drop hard-coded /W3 default in favor of custom CFLAGS Building with `/W3` shows an awful lot of warnings on Windows, so it's really hard to spot the more important ones. Since it is not possible to override the hard-coded `/W3`, we drop it altogether, so MSVC uses the default `/W1`. Users are encouraged to increase the warning level via the environment variable `CFLAGS` before doing configure. We also enable `/WX` (treat warnings as errors) for AppVeyor CI, using `/W1` for now, since otherwise the build would fail. --- diff --git a/appveyor/build_task.bat b/appveyor/build_task.bat index 124968fe14..91fedae855 100644 --- a/appveyor/build_task.bat +++ b/appveyor/build_task.bat @@ -54,6 +54,8 @@ if "%INTRINSICS%" neq "" set ADD_CONF=%ADD_CONF% --enable-native-intrinsics=%INT set EXT_EXCLUDE_FROM_TEST=snmp,oci8_12c,pdo_oci,pdo_firebird,ldap,imap,ftp if "%OPCACHE%" equ "0" set EXT_EXCLUDE_FROM_TEST=%EXT_EXCLUDE_FROM_TEST%,opcache +set CFLAGS=/W1 /WX + cmd /c configure.bat ^ --enable-snapshot-build ^ --disable-debug-pack ^ diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 9166cdeab6..9d2d578516 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -3207,7 +3207,7 @@ function toolset_setup_common_cflags() // General CFLAGS for building objects DEFINE("CFLAGS", "/nologo $(BASE_INCLUDES) /D _WINDOWS /D WINDOWS=1 \ - /D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /W3 \ + /D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS \ /D _USE_MATH_DEFINES"); if (envCFLAGS) { @@ -3399,7 +3399,7 @@ function toolset_setup_common_libs() function toolset_setup_build_mode() { if (PHP_DEBUG == "yes") { - ADD_FLAG("CFLAGS", "/LDd /MDd /W3 /Od /D _DEBUG /D ZEND_DEBUG=1 " + + ADD_FLAG("CFLAGS", "/LDd /MDd /Od /D _DEBUG /D ZEND_DEBUG=1 " + (X64?"/Zi":"/ZI")); ADD_FLAG("LDFLAGS", "/debug"); // Avoid problems when linking to release libraries that use the release @@ -3411,7 +3411,7 @@ function toolset_setup_build_mode() ADD_FLAG("CFLAGS", "/Zi"); ADD_FLAG("LDFLAGS", "/incremental:no /debug /opt:ref,icf"); } - ADD_FLAG("CFLAGS", "/LD /MD /W3"); + ADD_FLAG("CFLAGS", "/LD /MD"); if (PHP_SANITIZER == "yes" && CLANG_TOOLSET) { ADD_FLAG("CFLAGS", "/Od /D NDebug /D NDEBUG /D ZEND_WIN32_NEVER_INLINE /D ZEND_DEBUG=0"); } else {