Skip to content

Commit ab748d5

Browse files
authored
Define LEXBOR_STATIC in CFLAGS_URI for static ext/uri on Windows (php#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.
1 parent c956d6d commit ab748d5

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ PHP NEWS
66
. Fixed bug GH-22121 (Double free in gdImageSetStyle() after
77
overflow-triggered early return). (iliaal)
88

9+
- URI:
10+
. Add LEXBOR_STATIC to CFLAGS_URI on Windows so ext/uri does not see
11+
LXB_API as __declspec(dllimport) when linked statically into PHP.
12+
(Luther Monson)
13+
914
- Zlib:
1015
. Fixed memory leak if deflate initialization fails and there is a dict.
1116
(ndossche)

ext/uri/config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ EXTENSION("uri", "php_uri.c php_uri_common.c uri_parser_rfc3986.c uri_parser_wha
22

33
AC_DEFINE("URI_ENABLE_ANSI", 1, "Define to 1 for enabling ANSI support of uriparser.")
44
AC_DEFINE("URI_NO_UNICODE", 1, "Define to 1 for disabling unicode support of uriparser.")
5-
ADD_FLAG("CFLAGS_URI", "/D URI_STATIC_BUILD");
5+
ADD_FLAG("CFLAGS_URI", "/D URI_STATIC_BUILD /D LEXBOR_STATIC");
66

77
ADD_EXTENSION_DEP('uri', 'lexbor');
88
ADD_SOURCES("ext/uri/uriparser/src", "UriCommon.c UriCompare.c UriCopy.c UriEscape.c UriFile.c UriIp4.c UriIp4Base.c \

0 commit comments

Comments
 (0)