From 1300017cdca025648a79ea07eaf46c6095f9d291 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 13 Jul 2017 08:18:02 +0200 Subject: [PATCH 1/6] cleanup discontinued target --- win32/build/Makefile | 3 --- 1 file changed, 3 deletions(-) diff --git a/win32/build/Makefile b/win32/build/Makefile index aa8f78302e3..da484af3938 100644 --- a/win32/build/Makefile +++ b/win32/build/Makefile @@ -210,9 +210,6 @@ snap: build-snap build-devel build-dist $(BUILD_DIR)\deplister.exe: win32\build\deplister.c $(CC) /Fo$(BUILD_DIR)\ /Fd$(BUILD_DIR)\ /Fp$(BUILD_DIR)\ /FR$(BUILD_DIR) /Fe$(BUILD_DIR)\deplister.exe win32\build\deplister.c imagehlp.lib -msi-installer: dist - $(BUILD_DIR)\php.exe ..\php-installer\build-installer.php "$(BUILD_DIR)" "$(PHPDLL)" "$(SAPI_TARGETS)" "$(EXT_TARGETS)" "$(PECL_TARGETS)" - # need to redirect, since INSTALL is a file in the root... install: really-install install-sdk From d9f72886aac8b51819d41b873c4ec1f0eea3e88a Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 13 Jul 2017 09:19:07 +0200 Subject: [PATCH 2/6] extend comment --- win32/build/confutils.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/win32/build/confutils.js b/win32/build/confutils.js index e47aa0d5c6c..bf393b04f65 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -46,7 +46,8 @@ var PHP_TEST_INI_EXT_EXCLUDE = ""; var PHP_MAKEFILE_FRAGMENTS = PHP_SRC_DIR + "\\Makefile.fragments.w32"; -/* Care also about NTDDI_VERSION and _WIN32_WINNT in config.w32.h.in */ +/* Care also about NTDDI_VERSION and _WIN32_WINNT in config.w32.h.in + and manifest. */ var WINVER = "0x0601"; /* 7/2008r2 */ // There's a minimum requirement for re2c.. From bc16deee83bf1eda1e212078d875644b2834a928 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 13 Jul 2017 11:58:09 +0200 Subject: [PATCH 3/6] Revert "Enable whole program optimization for builds without PGO, too" This reverts commit f052e99df6f4b3bc4e2a1e9717ee36339a33f33b. There appear to be link issues with upcoming 19.11 and /LTCG, prefer wider dependency compatibility. --- win32/build/confutils.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/win32/build/confutils.js b/win32/build/confutils.js index bf393b04f65..1aeb94010f2 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -1229,9 +1229,6 @@ function SAPI(sapiname, file_list, makefiletarget, cflags, obj_dir) } ldflags += " /PGD:$(PGOPGD_DIR)\\" + makefiletarget.substring(0, makefiletarget.indexOf(".")) + ".pgd"; - } else if (PHP_DEBUG != "yes") { - ADD_FLAG('CFLAGS_' + SAPI, "/GL"); - ADD_FLAG('LDFLAGS_' + SAPI, "/LTCG:INCREMENTAL"); } if (MODE_PHPIZE) { @@ -1432,9 +1429,6 @@ function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir) ADD_FLAG('CFLAGS_' + EXT, "/GL /O2"); ldflags = " /PGD:$(PGOPGD_DIR)\\" + dllname.substring(0, dllname.indexOf(".")) + ".pgd"; - } else if (PHP_DEBUG != "yes") { - ADD_FLAG('CFLAGS_' + EXT, "/GL"); - ADD_FLAG('LDFLAGS_' + EXT, "/LTCG:INCREMENTAL"); } MFO.WriteLine("$(BUILD_DIR)\\" + libname + ": $(BUILD_DIR)\\" + dllname); @@ -1477,9 +1471,6 @@ function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir) ADD_FLAG("STATIC_EXT_CFLAGS", "/GL /O2"); static_pgo_enabled = true; } - } else if (PHP_DEBUG != "yes") { - ADD_FLAG("STATIC_EXT_CFLAGS", "/GL"); - ADD_FLAG('STATIC_EXT_LDFLAGS', "/LTCG:INCREMENTAL"); } /* find the header that declares the module pointer, From 613102bd678ab72fca412ce089e942bc33eb4046 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 13 Jul 2017 12:16:30 +0200 Subject: [PATCH 4/6] add next vc15 toolset to the list --- win32/build/confutils.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 1aeb94010f2..32faad028ed 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -68,12 +68,14 @@ VC_VERSIONS[1700] = 'MSVC11 (Visual C++ 2012)'; VC_VERSIONS[1800] = 'MSVC12 (Visual C++ 2013)'; VC_VERSIONS[1900] = 'MSVC14 (Visual C++ 2015)'; VC_VERSIONS[1910] = 'MSVC15 (Visual C++ 2017)'; +VC_VERSIONS[1911] = 'MSVC15 (Visual C++ 2017)'; var VC_VERSIONS_SHORT = new Array(); VC_VERSIONS_SHORT[1700] = 'VC11'; VC_VERSIONS_SHORT[1800] = 'VC12'; VC_VERSIONS_SHORT[1900] = 'VC14'; VC_VERSIONS_SHORT[1910] = 'VC15'; +VC_VERSIONS_SHORT[1911] = 'VC15'; if (PROGRAM_FILES == null) { PROGRAM_FILES = "C:\\Program Files"; From 0782a7fc6314c8bd3cbfd57f12d0479bf9cc8dc7 Mon Sep 17 00:00:00 2001 From: Francois Laupretre Date: Thu, 13 Jul 2017 14:27:19 +0200 Subject: [PATCH 5/6] Fixed bug #74866 extension_dir = "./ext" now use current directory for base --- Zend/zend_extensions.c | 19 +++++++++++--- Zend/zend_extensions.h | 1 + ext/standard/dl.c | 59 ++++++++++++++++++++++++++---------------- ext/standard/dl.h | 1 + main/php_ini.c | 17 ++++++++---- 5 files changed, 66 insertions(+), 31 deletions(-) diff --git a/Zend/zend_extensions.c b/Zend/zend_extensions.c index ceda2a3e8db..e556eb07bcd 100644 --- a/Zend/zend_extensions.c +++ b/Zend/zend_extensions.c @@ -29,8 +29,6 @@ int zend_load_extension(const char *path) { #if ZEND_EXTENSIONS_SUPPORT DL_HANDLE handle; - zend_extension *new_extension; - zend_extension_version_info *extension_version_info; handle = DL_LOAD(path); if (!handle) { @@ -43,6 +41,22 @@ int zend_load_extension(const char *path) #endif return FAILURE; } + return zend_load_extension_handle(handle, path); +#else + fprintf(stderr, "Extensions are not supported on this platform.\n"); +/* See http://support.microsoft.com/kb/190351 */ +#ifdef ZEND_WIN32 + fflush(stderr); +#endif + return FAILURE; +#endif +} + +int zend_load_extension_handle(DL_HANDLE handle, const char *path) +{ +#if ZEND_EXTENSIONS_SUPPORT + zend_extension *new_extension; + zend_extension_version_info *extension_version_info; extension_version_info = (zend_extension_version_info *) DL_FETCH_SYMBOL(handle, "extension_version_info"); if (!extension_version_info) { @@ -62,7 +76,6 @@ int zend_load_extension(const char *path) return FAILURE; } - /* allow extension to proclaim compatibility with any Zend version */ if (extension_version_info->zend_extension_api_no != ZEND_EXTENSION_API_NO &&(!new_extension->api_no_check || new_extension->api_no_check(ZEND_EXTENSION_API_NO) != SUCCESS)) { if (extension_version_info->zend_extension_api_no > ZEND_EXTENSION_API_NO) { diff --git a/Zend/zend_extensions.h b/Zend/zend_extensions.h index caeb3a263b4..ee9912c73f4 100644 --- a/Zend/zend_extensions.h +++ b/Zend/zend_extensions.h @@ -145,6 +145,7 @@ void zend_shutdown_extensions(void); BEGIN_EXTERN_C() ZEND_API int zend_load_extension(const char *path); +ZEND_API int zend_load_extension_handle(DL_HANDLE handle, const char *path); ZEND_API int zend_register_extension(zend_extension *new_extension, DL_HANDLE handle); ZEND_API zend_extension *zend_get_extension(const char *extension_name); ZEND_API size_t zend_extensions_op_array_persist_calc(zend_op_array *op_array); diff --git a/ext/standard/dl.c b/ext/standard/dl.c index 5adae805ce6..e9a107cc96a 100644 --- a/ext/standard/dl.c +++ b/ext/standard/dl.c @@ -76,6 +76,31 @@ PHPAPI PHP_FUNCTION(dl) #if defined(HAVE_LIBDL) +/* {{{ php_load_shlib + */ +PHPAPI void *php_load_shlib(char *path, char **errp) +{ + void *handle; + char *err; + + handle = DL_LOAD(path); + if (!handle) { + err = GET_DL_ERROR(); +#ifdef PHP_WIN32 + if (err && (*err)) { + (*errp)=estrdup(err); + LocalFree(err); + } else { + (*errp) = estrdup(""); + } +#else + (*errp) = estrdup(err); + GET_DL_ERROR(); /* free the buffer storing the error */ +#endif + } + return handle; +} + /* {{{ php_load_extension */ PHPAPI int php_load_extension(char *filename, int type, int start_now) @@ -109,6 +134,7 @@ PHPAPI int php_load_extension(char *filename, int type, int start_now) libpath = estrdup(filename); } else if (extension_dir && extension_dir[0]) { int extension_dir_len = (int)strlen(extension_dir); + char *err1, *err2; slash_suffix = IS_SLASH(extension_dir[extension_dir_len-1]); /* Try as filename first */ if (slash_suffix) { @@ -117,8 +143,9 @@ PHPAPI int php_load_extension(char *filename, int type, int start_now) spprintf(&libpath, 0, "%s%c%s", extension_dir, DEFAULT_SLASH, filename); /* SAFE */ } - if (VCWD_ACCESS(libpath, F_OK)) { - /* If file does not exist, consider as extension name and build file name */ + handle = php_load_shlib(libpath, &err1); + if (!handle) { + /* Now, consider 'filename' as extension name and build file name */ char *orig_libpath = libpath; if (slash_suffix) { @@ -127,37 +154,23 @@ PHPAPI int php_load_extension(char *filename, int type, int start_now) spprintf(&libpath, 0, "%s%c" PHP_SHLIB_EXT_PREFIX "%s." PHP_SHLIB_SUFFIX, extension_dir, DEFAULT_SLASH, filename); /* SAFE */ } - if (VCWD_ACCESS(libpath, F_OK)) { - php_error(error_type, "Cannot access dynamic library '%s' (tried : %s, %s)", - filename, orig_libpath, libpath); + handle = php_load_shlib(libpath, &err2); + if (!handle) { + php_error_docref(NULL, error_type, "Unable to load dynamic library '%s' (tried: %s (%s), %s (%s))", + filename, orig_libpath, err1, libpath, err2); efree(orig_libpath); + efree(err1); efree(libpath); + efree(err2); return FAILURE; } efree(orig_libpath); + efree(err1); } } else { return FAILURE; /* Not full path given or extension_dir is not set */ } - /* load dynamic symbol */ - handle = DL_LOAD(libpath); - if (!handle) { -#ifdef PHP_WIN32 - char *err = GET_DL_ERROR(); - if (err && (*err != '\0')) { - php_error_docref(NULL, error_type, "Unable to load dynamic library '%s' - %s", libpath, err); - LocalFree(err); - } else { - php_error_docref(NULL, error_type, "Unable to load dynamic library '%s' - %s", libpath, "Unknown reason"); - } -#else - php_error_docref(NULL, error_type, "Unable to load dynamic library '%s' - %s", libpath, GET_DL_ERROR()); - GET_DL_ERROR(); /* free the buffer storing the error */ -#endif - efree(libpath); - return FAILURE; - } efree(libpath); get_module = (zend_module_entry *(*)(void)) DL_FETCH_SYMBOL(handle, "get_module"); diff --git a/ext/standard/dl.h b/ext/standard/dl.h index 642fb81fc42..d2e32e4e459 100644 --- a/ext/standard/dl.h +++ b/ext/standard/dl.h @@ -25,6 +25,7 @@ PHPAPI int php_load_extension(char *filename, int type, int start_now); PHPAPI void php_dl(char *file, int type, zval *return_value, int start_now); +PHPAPI void *php_load_shlib(char *path, char **errp); /* dynamic loading functions */ PHPAPI PHP_FUNCTION(dl); diff --git a/main/php_ini.c b/main/php_ini.c index 98896a5f866..4e013c8acab 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -362,10 +362,12 @@ static void php_load_zend_extension_cb(void *arg) if (IS_ABSOLUTE_PATH(filename, length)) { zend_load_extension(filename); } else { + DL_HANDLE handle; char *libpath; char *extension_dir = INI_STR("extension_dir"); int extension_dir_len = (int)strlen(extension_dir); int slash_suffix = IS_SLASH(extension_dir[extension_dir_len-1]); + char *err1, *err2; /* Try as filename first */ if (slash_suffix) { spprintf(&libpath, 0, "%s%s", extension_dir, filename); /* SAFE */ @@ -373,7 +375,8 @@ static void php_load_zend_extension_cb(void *arg) spprintf(&libpath, 0, "%s%c%s", extension_dir, DEFAULT_SLASH, filename); /* SAFE */ } - if (VCWD_ACCESS(libpath, F_OK)) { + handle = (DL_HANDLE)php_load_shlib(libpath, &err1); + if (!handle) { /* If file does not exist, consider as extension name and build file name */ char *orig_libpath = libpath; @@ -383,18 +386,22 @@ static void php_load_zend_extension_cb(void *arg) spprintf(&libpath, 0, "%s%c" PHP_SHLIB_EXT_PREFIX "%s." PHP_SHLIB_SUFFIX, extension_dir, DEFAULT_SLASH, filename); /* SAFE */ } - if (VCWD_ACCESS(libpath, F_OK)) { - php_error(E_CORE_WARNING, "Cannot access Zend extension %s (Tried: %s, %s)\n", - filename, orig_libpath, libpath); + handle = (DL_HANDLE)php_load_shlib(libpath, &err2); + if (!handle) { + php_error(E_CORE_WARNING, "Failed loading Zend extension '%s' (tried: %s (%s), %s (%s))", + filename, orig_libpath, err1, libpath, err2); efree(orig_libpath); + efree(err1); efree(libpath); + efree(err2); return; } efree(orig_libpath); + efree(err1); } - zend_load_extension(libpath); + zend_load_extension_handle(handle, libpath); efree(libpath); } } From 5fb2abd6b01eb6da9c868132982aacadfa793d23 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 13 Jul 2017 14:33:49 +0200 Subject: [PATCH 6/6] fix fold --- ext/standard/dl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/standard/dl.c b/ext/standard/dl.c index e9a107cc96a..d32f02e8e64 100644 --- a/ext/standard/dl.c +++ b/ext/standard/dl.c @@ -100,6 +100,7 @@ PHPAPI void *php_load_shlib(char *path, char **errp) } return handle; } +/* }}} */ /* {{{ php_load_extension */