From 5521f862758bccb6079156dfaf85dabac8197310 Mon Sep 17 00:00:00 2001 From: Luther Monson Date: Wed, 27 May 2026 22:57:20 -0700 Subject: [PATCH] Define LEXBOR_STATIC in ext/lexbor/config.w32 for static linkage 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. Add AC_DEFINE("LEXBOR_STATIC", 1, ...) in ext/lexbor/config.w32 so the symbol is placed in main/config.w.h and seen by every PHP source file that includes php.h before lexbor headers. This covers ext/uri and any future consumer with one definition, in the right place for configuration intent. This change lives entirely in PHP-owned configuration (no modification to the vendored ext/lexbor/lexbor/ tree), so it survives lexbor library upgrades without re-application. --- NEWS | 5 +++++ ext/lexbor/config.w32 | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/NEWS b/NEWS index ae3cae760320..dfbb312863a4 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) +- Lexbor: + . Define LEXBOR_STATIC in ext/lexbor/config.w32 so consumers of the + bundled lexbor headers (ext/uri etc.) do not see LXB_API as + __declspec(dllimport) on Windows static builds. (Luther Monson) + - Zlib: . Fixed memory leak if deflate initialization fails and there is a dict. (ndossche) diff --git a/ext/lexbor/config.w32 b/ext/lexbor/config.w32 index e75798e06187..288d37dec62a 100644 --- a/ext/lexbor/config.w32 +++ b/ext/lexbor/config.w32 @@ -27,4 +27,11 @@ ADD_FLAG("CFLAGS_LEXBOR", "/D LEXBOR_BUILDING /utf-8"); AC_DEFINE("HAVE_LEXBOR", 1, "Define to 1 if the PHP extension 'lexbor' is available."); +// PHP bundles lexbor statically (EXTENSION above, false /* never shared */), +// so consumers of lexbor headers (e.g. ext/uri) must not see LXB_API as +// __declspec(dllimport) on Windows. AC_DEFINE places LEXBOR_STATIC in +// main/config.w.h so every PHP source file picks it up before including +// lexbor headers via php.h. +AC_DEFINE("LEXBOR_STATIC", 1, "Define to 1 to disable dllimport on lexbor headers for PHP's static bundle."); + PHP_INSTALL_HEADERS("ext/lexbor", "php_lexbor.h lexbor/");