Repository navigation
fix: unblock hosted builds (Swoole snprintf, static libpq) - #1260
Conversation
|
StaticPHP Test Bot Detected: Extensions: |
henderkes
left a comment
There was a problem hiding this comment.
is there an issue already at swoole-src?
|
Not yet. https://github.com/jcleng/swoole-src/tree/fix/php-snprintf-macro is a forked version for this. This is blocking our build; we should fix it first. |
369af16 to
e76609a
Compare
- Swoole: pre-include libc++ <locale> for the Swoole C++ build (Zig libc++ on Linux uses std::vsnprintf before the macro is undefined), include <cstdio> before php.h, undef PHP's snprintf/vsnprintf macros before nlohmann/json, and restore usleep() in 6.2.3 misc.cc where sw_usleep is not declared on macOS. - pgsql/pdo_pgsql: for PHP < 8.4, pass the full resolved static libpq dependency list as AC_CHECK_LIB's OTHER-LIBRARIES for the PQlibVersion check (libpgcommon/libpgport alone was not enough when libpq is built with OpenSSL/LDAP/zstd/ICU).
e76609a to
158babd
Compare
|
Final CI for |
Why
The
[v3] Build Self-Hosted PHP Binary (Unix)workflow is still red after the staledownloadscaches were cleared. Three independent build failures remain:bulk/gnu-bulk, Linux + macOS, PHP 8.2–8.5)ext-src/swoole_admin_server.ccincludes PHP headers first and then Swoole's bundlednlohmann/json.hpp.php.hincludesmain/snprintf.h, which unconditionally does#define snprintf ap_php_snprintf(same forvsnprintf). nlohmann uses(std::snprintf), so the object-like macro rewrites it tostd::ap_php_snprintfand the C++ build fails.swoole.hincludes libc++<list>→<locale>from inside the PHP header chain. Zig's libc++__locale_dir/support/linux.husesstd::vsnprintf, which the PHP macro has already rewritten tostd::ap_php_vsnprintf. macOS's libc++ does not hit this path.common+bulkPostgreSQL 18 keeps
libpgcommon.a/libpgport.aas separate static archives, and libpq itself references OpenSSL / LDAP / zlib / zstd / ICU depending on how it was built. PHP < 8.4 checks libpq withAC_CHECK_LIB(pq, PQlibVersion, ...), which links only-lpqplus the minimal configureLIBS, so the check fails with undefinedBIO_*/ASN1_*/ldap_*/explicit_bzero/pg_b64_*symbols. PHP 8.4+ usesPHP_SETUP_PGSQL+PGSQL_LIBS(frompg_config --libs) and is unaffected.A fourth issue surfaced while validating on macOS: Swoole 6.2.3
src/core/misc.cccallssw_usleep(), which is defined ininclude/swoole_posix.hbut that translation unit does not include it. Linux pulls it in indirectly; macOS fails withuse of undeclared identifier 'sw_usleep'. Swoole 6.2.2 and master useusleep()there.Changes
src/Package/Extension/swoole.php:-include localeto the PHP C++ flags for Swoole builds, so libc++<locale>is parsed before PHP'svsnprintfmacro is defined.<cstdio>beforephp_swoole_server.hinswoole_admin_server.cc. This declaresstd::snprintfbeforephp.hdefines the macro.#undef snprintf/#undef vsnprintfimmediately before thenlohmann/json.hppinclude.sw_usleep(...)withusleep(...)insrc/core/misc.ccfor Swoole 6.2.3.src/Package/Extension/pgsql.php+src/Package/Extension/pdo_pgsql.php: for PHP < 8.4, compute the same static dependency list used by the final build (SPCConfigUtil::configForResolvedBuild(['postgresql'], $installer)['libs']) and pass it asAC_CHECK_LIB'sOTHER-LIBRARIESargument for thePQlibVersioncheck. The generated configure then links-lpqplus the full static dependency list, matching the final build.Local validation (macOS arm64, PHP 8.3)
Clean build (
buildroot+sourceremoved) with:bin/spc build "pdo_pgsql,pgsql,swoole" --build-cli --dl-with-php=8.3 --debugResult: BUILD SUCCESSFUL, including the
pgsql,pdo_pgsqlandswoolesmoke tests.checking for PQlibVersion in -lpq... yes(before this PR:no→ configure error).swoole_admin_server.cccompiles; nostd::ap_php_snprintf/ missingstd::snprintferrors.src/core/misc.cccompiles after thesw_usleep→usleeppatch.composer analyse— no errors.composer test— 468 tests pass (the local untrackedtests/StaticPHP/Package/ZipTest.phpwas excluded; it is unrelated to this branch and currently fails againstv3).CI iterations
BIO_*/ldap_*undefined symbols. Root cause: CI uses--with-suggested-libs --with-suggested-exts, so libpq is built with OpenSSL/LDAP and-lpgcommon -lpgportalone was not enough. Fixed by passing the full resolved static dependency list.__locale_dir/support/linux.h: no member named 'ap_php_vsnprintf'. Fixed by pre-including libc++<locale>.158babd7).Scope
This does not change the compiler-rt downloader. The missing
compiler-rt-21.1.0.src.tar.xzon the mirror is an operational gap (the publishing workflow only backfills the latest zig) and is no longer hit after the stale caches were cleared; the next run resolves zig 0.17 / compiler-rt 22.1.8.