Skip to content

Commit da128c4

Browse files
committed
Default LEXBOR_STATIC in bundled lexbor for Windows static builds
PHP bundles lexbor as a static-only extension (ext/lexbor/config.w32 declares EXTENSION("lexbor", ..., false /* never shared */)). On Windows, ext/lexbor/lexbor/core/def.h defaults LXB_API to __declspec(dllimport) when LEXBOR_STATIC is not defined, which causes LNK2019 unresolved external symbol errors for every lxb_* function referenced from consumers (ext/uri today, potentially others later) when PHP itself is linked statically without a runtime DLL. Default LEXBOR_STATIC at the top of the vendored def.h so the PHP-bundled copy is always static-API regardless of consumer. The existing #ifndef-guarded block below this addition is preserved verbatim so the change is functionally a no-op for callers that already set LEXBOR_STATIC explicitly. This is a vendor patch to a copy of upstream lexbor and will need to be re-applied on the next lexbor upgrade (most recent was v2.7.0 per 8.5.6 NEWS); the patch is three lines and intentionally adjacent to the existing LEXBOR_STATIC handling so it is unlikely to drift.
1 parent 7260b27 commit da128c4

2 files changed

Lines changed: 13 additions & 0 deletions

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+
- Lexbor:
10+
. Default LEXBOR_STATIC in the bundled lexbor headers so consumers
11+
(ext/uri etc.) do not see LXB_API as __declspec(dllimport) on
12+
Windows static builds. (Luther Monson)
13+
914
- Zlib:
1015
. Fixed memory leak if deflate initialization fails and there is a dict.
1116
(ndossche)

ext/lexbor/lexbor/core/def.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@
3232

3333
#define LEXBOR_MEM_ALIGN_STEP sizeof(void *)
3434

35+
/* PHP bundles lexbor as a static-only extension
36+
* (ext/lexbor/config.w32 declares EXTENSION(..., false / * never shared * /)).
37+
* Force the static API decoration so consumers (ext/uri, etc.) do not see
38+
* __declspec(dllimport) on Windows and fail to link. */
39+
#ifndef LEXBOR_STATIC
40+
#define LEXBOR_STATIC
41+
#endif
42+
3543
#ifndef LEXBOR_STATIC
3644
#ifdef _WIN32
3745
#ifdef LEXBOR_BUILDING

0 commit comments

Comments
 (0)