-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix GH-15534: Build failure for libxml2 2.9.0 - 2.9.3 #15536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The xmlDictPtr was moved before the includes in libxml2 2.9.4 so the <libxml/dict.h> can be included directly but for earlier versions the <libxml/tree.h> needs to be included before. Since PHP requires libxml2 2.9.0 or later and this also fixes builds on Solaris 10.
Honestly, I think support for these old libxml versions should just be dropped. The early 2.9.x versions have quite some memory corruption bugs and they're also 8 years old. |
Yes, installing all these various versions is very cumbersome. I have major issues installing somehow "fresher" libxml2 version on Solaris 10 :D |
Then, let's try bumping the minimum version to 2.9.4 as noted in the issue by @cmb69 I've appended a new commit then. |
If we bump the requirement, we should check that on Windows, too (just in case somebody actually tries to build with libxml2 < 2.9.4). If all else fails, we could use I would suggest to wait a bit with merging, though (PHP 8.4.0beta4 is only next week). |
In |
The following should do ext/libxml/config.w32 | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/ext/libxml/config.w32 b/ext/libxml/config.w32
index 416ae1f136..d836f0efcb 100644
--- a/ext/libxml/config.w32
+++ b/ext/libxml/config.w32
@@ -9,13 +9,19 @@ if (PHP_LIBXML == "yes") {
CHECK_HEADER_ADD_INCLUDE("libxml/tree.h", "CFLAGS_LIBXML", PHP_PHP_BUILD + "\\include\\libxml2") &&
ADD_EXTENSION_DEP('libxml', 'iconv')) {
- EXTENSION("libxml", "libxml.c mime_sniff.c", false /* never shared */, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
- AC_DEFINE("HAVE_LIBXML", 1, "Define to 1 if the PHP extension 'libxml' is available.");
- ADD_FLAG("CFLAGS_LIBXML", "/D LIBXML_STATIC /D LIBXML_STATIC_FOR_DLL /D HAVE_WIN32_THREADS ");
- if (!PHP_LIBXML_SHARED) {
- ADD_DEF_FILE("ext\\libxml\\php_libxml2.def");
+ if (GREP_HEADER("libxml/xmlversion.h", "#define\\s+LIBXML_VERSION\\s+(\\d+)", PHP_PHP_BUILD + "\\include\\libxml2") &&
+ +RegExp.$1 >= 20904) {
+
+ EXTENSION("libxml", "libxml.c mime_sniff.c", false /* never shared */, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
+ AC_DEFINE("HAVE_LIBXML", 1, "Define to 1 if the PHP extension 'libxml' is available.");
+ ADD_FLAG("CFLAGS_LIBXML", "/D LIBXML_STATIC /D LIBXML_STATIC_FOR_DLL /D HAVE_WIN32_THREADS ");
+ if (!PHP_LIBXML_SHARED) {
+ ADD_DEF_FILE("ext\\libxml\\php_libxml2.def");
+ }
+ PHP_INSTALL_HEADERS("ext/libxml", "php_libxml.h");
+ } else {
+ WARNING("libxml support can't be enabled, libxml version >= 2.9.4 required");
}
- PHP_INSTALL_HEADERS("ext/libxml", "php_libxml.h");
} else {
WARNING("libxml support can't be enabled, iconv or libxml are missing")
PHP_LIBXML = "no" Feel free to commit this @petk. (Isn't that a wonderful programming language? No need for ugly return values; you just can get the matches from a nice global variable. ;) |
I don't know if our process "allows" bumping the version this late into the 8.4 development cycle, but if we can then fine by me. |
Hehehe. :D Ok, then Windows changes added in the appended commit. Thanks @cmb69 Edit: Patch also seems to be working fine on Windows. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering, here we're still waiting or can this be merged now already? :D |
IMO, this can be merged. Feel free to do so! |
ADD_FLAG("CFLAGS_LIBXML", "/D LIBXML_STATIC /D LIBXML_STATIC_FOR_DLL /D HAVE_WIN32_THREADS "); | ||
if (!PHP_LIBXML_SHARED) { | ||
ADD_DEF_FILE("ext\\libxml\\php_libxml2.def"); | ||
if (GREP_HEADER("libxml/xmlversion.h", "#define\\s+LIBXML_VERSION\\s+(\\d+)", PHP_PHP_BUILD + "\\include\\libxml2") && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@petk @cmb69 This change assumes that xmlversion.h is in include/libxml2/libxml/xmlversion.h which is most likely not the case. The most likely place for xmlversion.h is include/libxml. With LIBXML_VERSION 20914 I got the warning that I did not have the required libxml version.
Dropping the \\libxml2
in the last argument of GREP_HEADER did the trick. Or dropping the libxml/
in the first argument and putting the headers in include/libxml2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. The GREP_HEADER function should be adjusted a bit, yes. Because the CHECK_HEADER_ADD_INCLUDE checks the include flags by appending them to the other flags, and this one works by a single file path only. It already checks the flags but only the empty PHP_EXTRA_INCLUDES variable (probably)...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CHECK_HEADER_ADD_INCLUDE is smart enough to first check in the main include directory. With the headers in include/libxml it will find the headers. In my case:
Checking for libxml/parser.h ... ../win64build\include
Checking for libxml/tree.h ... ../win64build\include
for the x64 build
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PHP_PHP_BUILD + "\\include\\libxml2"
in CHECK_HEADER_ADD_INCLUDE has been there for ages. I can see it there in PHP 7.0. In PHP 5.6 it simply was
CHECK_HEADER_ADD_INCLUDE("libxml/parser.h", "CFLAGS_LIBXML")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm testing something like this now:
diff --git a/win32/build/confutils.js b/win32/build/confutils.js
index 95a4e5ce3c..b652a497d1 100644
--- a/win32/build/confutils.js
+++ b/win32/build/confutils.js
@@ -965,6 +965,11 @@ function GREP_HEADER(header_name, regex, path_to_check)
if (!c) {
/* look in the include path */
+ if (path_to_check == null) {
+ path_to_check = php_usual_include_suspects;
+ } else {
+ path_to_check += ";" + php_usual_include_suspects;
+ }
var p = search_paths(header_name, path_to_check, "INCLUDE");
if (typeof(p) == "string") {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change assumes that xmlversion.h is in include/libxml2/libxml/xmlversion.h which is most likely not the case. The most likely place for xmlversion.h is include/libxml. With LIBXML_VERSION 20914 I got the warning that I did not have the required libxml version.
From where did you get these libraries? I've checked a couple from windows.php.net, and even one from http://xmlsoft.org/sources/win32/64bit/, and there is always include/libxml2/libxml/*.h.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not have my build machine at hand, but I probably just used https://github.com/winlibs/libxml2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://windows.php.net/downloads/php-sdk/deps/archives/vc11/x64/libxml2-2.9.4-1-vc11-x64.zip
And updates after that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for digging this out. So we need to fix this for best compatibility with other builds. I'll have a look at @petk's PR (thanks for that!) soon (probably the weekend).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The xmlDictPtr was moved before the includes in libxml2 2.9.4 so the <libxml/dict.h> can be included directly but for earlier versions the <libxml/tree.h> needs to be included before. Since PHP requires libxml2 2.9.0 or later and this also fixes builds on Solaris 10.