Fix GH-16843: Windows phpize builds ignore source subfolders

phpize builds on Windows ignore the paths of extension sources, and
build all object files in the same folder.  This can't work if there
are multiple source files with the same base name stored in separate
folders and registered as such (e.g. cls/worker.c and src/worker.c).
While extension authors can work around by avoiding duplicate base
names, they may not even be aware of the problem because on POSIX
systems, the object files are usually placed right besides the sources.

Thus we take the relative path (from `configure_module_dirname`) of the
source files into account even for phpize builds.  Since this may break
some extension builds (especially those which use Makefile fragments),
we do not apply this fix to stable branches.

Closes GH-17016.
This commit is contained in:
Christoph M. Becker 2024-12-02 12:56:54 +01:00
parent 85731e8830
commit 03731570cf
No known key found for this signature in database
GPG key ID: D66C9593118BCCB6
3 changed files with 14 additions and 2 deletions

1
NEWS
View file

@ -81,6 +81,7 @@ PHP NEWS
- Windows: - Windows:
. Fixed bug GH-10992 (Improper long path support for relative paths). (cmb, . Fixed bug GH-10992 (Improper long path support for relative paths). (cmb,
nielsdos) nielsdos)
. Fixed bug GH-16843 (Windows phpize builds ignore source subfolders). (cmb)
- XMLWriter: - XMLWriter:
. Improved performance and reduce memory consumption. (nielsdos) . Improved performance and reduce memory consumption. (nielsdos)

View file

@ -166,6 +166,10 @@ PHP 8.5 UPGRADE NOTES
PHP_RELEASE_VERSION are now always numbers. Previously, they have been PHP_RELEASE_VERSION are now always numbers. Previously, they have been
strings for buildconf builds. strings for buildconf builds.
* phpize builds now reflect the source tree in the build dir (like that already
worked for in-tree builds); some extension builds (especially when using
Makefile.frag.w32) may need adjustments.
* --enable-sanitzer is now supported for MSVC builds. This enables ASan and * --enable-sanitzer is now supported for MSVC builds. This enables ASan and
debug assertions, and is supported as of MSVC 16.10 and Windows 10. debug assertions, and is supported as of MSVC 16.10 and Windows 10.

View file

@ -1616,8 +1616,15 @@ function ADD_SOURCES(dir, file_list, target, obj_dir)
if (obj_dir == null) { if (obj_dir == null) {
if (MODE_PHPIZE) { if (MODE_PHPIZE) {
/* In the phpize mode, the subdirs are always relative to BUID_DIR. /* In the phpize mode, the subdirs are always relative to BUID_DIR.
No need to differentiate by extension, only one gets built. */ No need to differentiate by extension, only one gets built.
var build_dir = (dirname ? dirname : "").replace(new RegExp("^..\\\\"), ""); We still need to cater to subfolders, though. */
if (dir.charAt(configure_module_dirname.length) === "\\" &&
dir.substr(0, configure_module_dirname.length) === configure_module_dirname) {
var reldir = dir.substr(configure_module_dirname.length + 1);
var build_dir = (dirname ? (reldir + "\\" + dirname) : reldir).replace(new RegExp("^..\\\\"), "");
} else {
var build_dir = (dirname ? dirname : "").replace(new RegExp("^..\\\\"), "");
}
} else { } else {
var build_dir = (dirname ? (dir + "\\" + dirname) : dir).replace(new RegExp("^..\\\\"), ""); var build_dir = (dirname ? (dir + "\\" + dirname) : dir).replace(new RegExp("^..\\\\"), "");
} }