Commit ab748d52bff for php.net
commit ab748d52bffbb92cd71f070161de37cc56310a94
Author: Luther Monson <luther.monson@gmail.com>
Date: Fri May 29 00:27:54 2026 -0700
Define LEXBOR_STATIC in CFLAGS_URI for static ext/uri on Windows (#22165)
ext/uri is always built statically (false /* never shared */ in
EXTENSION()) and includes the bundled lexbor headers via /I ext/lexbor.
On Windows, lexbor's LXB_API macro defaults to __declspec(dllimport),
which produces LNK2019 unresolved external symbol errors for every
lxb_* function referenced from ext/uri when PHP itself is linked
statically without a runtime DLL.
Adding /D LEXBOR_STATIC to CFLAGS_URI in ext/uri/config.w32 makes
LXB_API expand to nothing for ext/uri's compilation units. The scope
matches URI_STATIC_BUILD on the same line: per-consumer, because
other lexbor consumers (e.g. ext/dom, which can build as shared)
must decide for themselves whether to disable the dllimport
decoration.
diff --git a/NEWS b/NEWS
index ae3cae76032..d16352c2613 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,11 @@ PHP NEWS
. Fixed bug GH-22121 (Double free in gdImageSetStyle() after
overflow-triggered early return). (iliaal)
+- URI:
+ . Add LEXBOR_STATIC to CFLAGS_URI on Windows so ext/uri does not see
+ LXB_API as __declspec(dllimport) when linked statically into PHP.
+ (Luther Monson)
+
- Zlib:
. Fixed memory leak if deflate initialization fails and there is a dict.
(ndossche)
diff --git a/ext/uri/config.w32 b/ext/uri/config.w32
index 97c10caf098..f26ffac629e 100644
--- a/ext/uri/config.w32
+++ b/ext/uri/config.w32
@@ -2,7 +2,7 @@ EXTENSION("uri", "php_uri.c php_uri_common.c uri_parser_rfc3986.c uri_parser_wha
AC_DEFINE("URI_ENABLE_ANSI", 1, "Define to 1 for enabling ANSI support of uriparser.")
AC_DEFINE("URI_NO_UNICODE", 1, "Define to 1 for disabling unicode support of uriparser.")
-ADD_FLAG("CFLAGS_URI", "/D URI_STATIC_BUILD");
+ADD_FLAG("CFLAGS_URI", "/D URI_STATIC_BUILD /D LEXBOR_STATIC");
ADD_EXTENSION_DEP('uri', 'lexbor');
ADD_SOURCES("ext/uri/uriparser/src", "UriCommon.c UriCompare.c UriCopy.c UriEscape.c UriFile.c UriIp4.c UriIp4Base.c \