Skip to content

Commit ea8c004

Browse files
committed
Merge branch 'sccp' into dce
* sccp: fix fold Fixed bug #74866 extension_dir = "./ext" now use current directory for base add next vc15 toolset to the list Revert "Enable whole program optimization for builds without PGO, too" extend comment cleanup discontinued target
2 parents 624f76d + a32a3fb commit ea8c004

File tree

7 files changed

+71
-44
lines changed

7 files changed

+71
-44
lines changed

Zend/zend_extensions.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ int zend_load_extension(const char *path)
2929
{
3030
#if ZEND_EXTENSIONS_SUPPORT
3131
DL_HANDLE handle;
32-
zend_extension *new_extension;
33-
zend_extension_version_info *extension_version_info;
3432

3533
handle = DL_LOAD(path);
3634
if (!handle) {
@@ -43,6 +41,22 @@ int zend_load_extension(const char *path)
4341
#endif
4442
return FAILURE;
4543
}
44+
return zend_load_extension_handle(handle, path);
45+
#else
46+
fprintf(stderr, "Extensions are not supported on this platform.\n");
47+
/* See http://support.microsoft.com/kb/190351 */
48+
#ifdef ZEND_WIN32
49+
fflush(stderr);
50+
#endif
51+
return FAILURE;
52+
#endif
53+
}
54+
55+
int zend_load_extension_handle(DL_HANDLE handle, const char *path)
56+
{
57+
#if ZEND_EXTENSIONS_SUPPORT
58+
zend_extension *new_extension;
59+
zend_extension_version_info *extension_version_info;
4660

4761
extension_version_info = (zend_extension_version_info *) DL_FETCH_SYMBOL(handle, "extension_version_info");
4862
if (!extension_version_info) {
@@ -62,7 +76,6 @@ int zend_load_extension(const char *path)
6276
return FAILURE;
6377
}
6478

65-
6679
/* allow extension to proclaim compatibility with any Zend version */
6780
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)) {
6881
if (extension_version_info->zend_extension_api_no > ZEND_EXTENSION_API_NO) {

Zend/zend_extensions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ void zend_shutdown_extensions(void);
145145

146146
BEGIN_EXTERN_C()
147147
ZEND_API int zend_load_extension(const char *path);
148+
ZEND_API int zend_load_extension_handle(DL_HANDLE handle, const char *path);
148149
ZEND_API int zend_register_extension(zend_extension *new_extension, DL_HANDLE handle);
149150
ZEND_API zend_extension *zend_get_extension(const char *extension_name);
150151
ZEND_API size_t zend_extensions_op_array_persist_calc(zend_op_array *op_array);

ext/standard/dl.c

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,32 @@ PHPAPI PHP_FUNCTION(dl)
7676

7777
#if defined(HAVE_LIBDL)
7878

79+
/* {{{ php_load_shlib
80+
*/
81+
PHPAPI void *php_load_shlib(char *path, char **errp)
82+
{
83+
void *handle;
84+
char *err;
85+
86+
handle = DL_LOAD(path);
87+
if (!handle) {
88+
err = GET_DL_ERROR();
89+
#ifdef PHP_WIN32
90+
if (err && (*err)) {
91+
(*errp)=estrdup(err);
92+
LocalFree(err);
93+
} else {
94+
(*errp) = estrdup("<No message>");
95+
}
96+
#else
97+
(*errp) = estrdup(err);
98+
GET_DL_ERROR(); /* free the buffer storing the error */
99+
#endif
100+
}
101+
return handle;
102+
}
103+
/* }}} */
104+
79105
/* {{{ php_load_extension
80106
*/
81107
PHPAPI int php_load_extension(char *filename, int type, int start_now)
@@ -109,6 +135,7 @@ PHPAPI int php_load_extension(char *filename, int type, int start_now)
109135
libpath = estrdup(filename);
110136
} else if (extension_dir && extension_dir[0]) {
111137
int extension_dir_len = (int)strlen(extension_dir);
138+
char *err1, *err2;
112139
slash_suffix = IS_SLASH(extension_dir[extension_dir_len-1]);
113140
/* Try as filename first */
114141
if (slash_suffix) {
@@ -117,8 +144,9 @@ PHPAPI int php_load_extension(char *filename, int type, int start_now)
117144
spprintf(&libpath, 0, "%s%c%s", extension_dir, DEFAULT_SLASH, filename); /* SAFE */
118145
}
119146

120-
if (VCWD_ACCESS(libpath, F_OK)) {
121-
/* If file does not exist, consider as extension name and build file name */
147+
handle = php_load_shlib(libpath, &err1);
148+
if (!handle) {
149+
/* Now, consider 'filename' as extension name and build file name */
122150
char *orig_libpath = libpath;
123151

124152
if (slash_suffix) {
@@ -127,37 +155,23 @@ PHPAPI int php_load_extension(char *filename, int type, int start_now)
127155
spprintf(&libpath, 0, "%s%c" PHP_SHLIB_EXT_PREFIX "%s." PHP_SHLIB_SUFFIX, extension_dir, DEFAULT_SLASH, filename); /* SAFE */
128156
}
129157

130-
if (VCWD_ACCESS(libpath, F_OK)) {
131-
php_error(error_type, "Cannot access dynamic library '%s' (tried : %s, %s)",
132-
filename, orig_libpath, libpath);
158+
handle = php_load_shlib(libpath, &err2);
159+
if (!handle) {
160+
php_error_docref(NULL, error_type, "Unable to load dynamic library '%s' (tried: %s (%s), %s (%s))",
161+
filename, orig_libpath, err1, libpath, err2);
133162
efree(orig_libpath);
163+
efree(err1);
134164
efree(libpath);
165+
efree(err2);
135166
return FAILURE;
136167
}
137168
efree(orig_libpath);
169+
efree(err1);
138170
}
139171
} else {
140172
return FAILURE; /* Not full path given or extension_dir is not set */
141173
}
142174

143-
/* load dynamic symbol */
144-
handle = DL_LOAD(libpath);
145-
if (!handle) {
146-
#ifdef PHP_WIN32
147-
char *err = GET_DL_ERROR();
148-
if (err && (*err != '\0')) {
149-
php_error_docref(NULL, error_type, "Unable to load dynamic library '%s' - %s", libpath, err);
150-
LocalFree(err);
151-
} else {
152-
php_error_docref(NULL, error_type, "Unable to load dynamic library '%s' - %s", libpath, "Unknown reason");
153-
}
154-
#else
155-
php_error_docref(NULL, error_type, "Unable to load dynamic library '%s' - %s", libpath, GET_DL_ERROR());
156-
GET_DL_ERROR(); /* free the buffer storing the error */
157-
#endif
158-
efree(libpath);
159-
return FAILURE;
160-
}
161175
efree(libpath);
162176

163177
get_module = (zend_module_entry *(*)(void)) DL_FETCH_SYMBOL(handle, "get_module");

ext/standard/dl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
PHPAPI int php_load_extension(char *filename, int type, int start_now);
2727
PHPAPI void php_dl(char *file, int type, zval *return_value, int start_now);
28+
PHPAPI void *php_load_shlib(char *path, char **errp);
2829

2930
/* dynamic loading functions */
3031
PHPAPI PHP_FUNCTION(dl);

main/php_ini.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -362,18 +362,21 @@ static void php_load_zend_extension_cb(void *arg)
362362
if (IS_ABSOLUTE_PATH(filename, length)) {
363363
zend_load_extension(filename);
364364
} else {
365+
DL_HANDLE handle;
365366
char *libpath;
366367
char *extension_dir = INI_STR("extension_dir");
367368
int extension_dir_len = (int)strlen(extension_dir);
368369
int slash_suffix = IS_SLASH(extension_dir[extension_dir_len-1]);
370+
char *err1, *err2;
369371
/* Try as filename first */
370372
if (slash_suffix) {
371373
spprintf(&libpath, 0, "%s%s", extension_dir, filename); /* SAFE */
372374
} else {
373375
spprintf(&libpath, 0, "%s%c%s", extension_dir, DEFAULT_SLASH, filename); /* SAFE */
374376
}
375377

376-
if (VCWD_ACCESS(libpath, F_OK)) {
378+
handle = (DL_HANDLE)php_load_shlib(libpath, &err1);
379+
if (!handle) {
377380
/* If file does not exist, consider as extension name and build file name */
378381
char *orig_libpath = libpath;
379382

@@ -383,18 +386,22 @@ static void php_load_zend_extension_cb(void *arg)
383386
spprintf(&libpath, 0, "%s%c" PHP_SHLIB_EXT_PREFIX "%s." PHP_SHLIB_SUFFIX, extension_dir, DEFAULT_SLASH, filename); /* SAFE */
384387
}
385388

386-
if (VCWD_ACCESS(libpath, F_OK)) {
387-
php_error(E_CORE_WARNING, "Cannot access Zend extension %s (Tried: %s, %s)\n",
388-
filename, orig_libpath, libpath);
389+
handle = (DL_HANDLE)php_load_shlib(libpath, &err2);
390+
if (!handle) {
391+
php_error(E_CORE_WARNING, "Failed loading Zend extension '%s' (tried: %s (%s), %s (%s))",
392+
filename, orig_libpath, err1, libpath, err2);
389393
efree(orig_libpath);
394+
efree(err1);
390395
efree(libpath);
396+
efree(err2);
391397
return;
392398
}
393399

394400
efree(orig_libpath);
401+
efree(err1);
395402
}
396403

397-
zend_load_extension(libpath);
404+
zend_load_extension_handle(handle, libpath);
398405
efree(libpath);
399406
}
400407
}

win32/build/Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,6 @@ snap: build-snap build-devel build-dist
210210
$(BUILD_DIR)\deplister.exe: win32\build\deplister.c
211211
$(CC) /Fo$(BUILD_DIR)\ /Fd$(BUILD_DIR)\ /Fp$(BUILD_DIR)\ /FR$(BUILD_DIR) /Fe$(BUILD_DIR)\deplister.exe win32\build\deplister.c imagehlp.lib
212212

213-
msi-installer: dist
214-
$(BUILD_DIR)\php.exe ..\php-installer\build-installer.php "$(BUILD_DIR)" "$(PHPDLL)" "$(SAPI_TARGETS)" "$(EXT_TARGETS)" "$(PECL_TARGETS)"
215-
216213
# need to redirect, since INSTALL is a file in the root...
217214
install: really-install install-sdk
218215

win32/build/confutils.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ var PHP_TEST_INI_EXT_EXCLUDE = "";
4646

4747
var PHP_MAKEFILE_FRAGMENTS = PHP_SRC_DIR + "\\Makefile.fragments.w32";
4848

49-
/* Care also about NTDDI_VERSION and _WIN32_WINNT in config.w32.h.in */
49+
/* Care also about NTDDI_VERSION and _WIN32_WINNT in config.w32.h.in
50+
and manifest. */
5051
var WINVER = "0x0601"; /* 7/2008r2 */
5152

5253
// There's a minimum requirement for re2c..
@@ -67,12 +68,14 @@ VC_VERSIONS[1700] = 'MSVC11 (Visual C++ 2012)';
6768
VC_VERSIONS[1800] = 'MSVC12 (Visual C++ 2013)';
6869
VC_VERSIONS[1900] = 'MSVC14 (Visual C++ 2015)';
6970
VC_VERSIONS[1910] = 'MSVC15 (Visual C++ 2017)';
71+
VC_VERSIONS[1911] = 'MSVC15 (Visual C++ 2017)';
7072

7173
var VC_VERSIONS_SHORT = new Array();
7274
VC_VERSIONS_SHORT[1700] = 'VC11';
7375
VC_VERSIONS_SHORT[1800] = 'VC12';
7476
VC_VERSIONS_SHORT[1900] = 'VC14';
7577
VC_VERSIONS_SHORT[1910] = 'VC15';
78+
VC_VERSIONS_SHORT[1911] = 'VC15';
7679

7780
if (PROGRAM_FILES == null) {
7881
PROGRAM_FILES = "C:\\Program Files";
@@ -1228,9 +1231,6 @@ function SAPI(sapiname, file_list, makefiletarget, cflags, obj_dir)
12281231
}
12291232

12301233
ldflags += " /PGD:$(PGOPGD_DIR)\\" + makefiletarget.substring(0, makefiletarget.indexOf(".")) + ".pgd";
1231-
} else if (PHP_DEBUG != "yes") {
1232-
ADD_FLAG('CFLAGS_' + SAPI, "/GL");
1233-
ADD_FLAG('LDFLAGS_' + SAPI, "/LTCG:INCREMENTAL");
12341234
}
12351235

12361236
if (MODE_PHPIZE) {
@@ -1431,9 +1431,6 @@ function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir)
14311431
ADD_FLAG('CFLAGS_' + EXT, "/GL /O2");
14321432

14331433
ldflags = " /PGD:$(PGOPGD_DIR)\\" + dllname.substring(0, dllname.indexOf(".")) + ".pgd";
1434-
} else if (PHP_DEBUG != "yes") {
1435-
ADD_FLAG('CFLAGS_' + EXT, "/GL");
1436-
ADD_FLAG('LDFLAGS_' + EXT, "/LTCG:INCREMENTAL");
14371434
}
14381435

14391436
MFO.WriteLine("$(BUILD_DIR)\\" + libname + ": $(BUILD_DIR)\\" + dllname);
@@ -1476,9 +1473,6 @@ function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir)
14761473
ADD_FLAG("STATIC_EXT_CFLAGS", "/GL /O2");
14771474
static_pgo_enabled = true;
14781475
}
1479-
} else if (PHP_DEBUG != "yes") {
1480-
ADD_FLAG("STATIC_EXT_CFLAGS", "/GL");
1481-
ADD_FLAG('STATIC_EXT_LDFLAGS', "/LTCG:INCREMENTAL");
14821476
}
14831477

14841478
/* find the header that declares the module pointer,

0 commit comments

Comments
 (0)