feat(nts): resolver shim + EMBEDDING.md in NTS tarballs, shared-embed variant - #44
Merged
Conversation
… variant
Two integration gaps reported by PAM building against the NTS SDK:
1. Linking lib/libphp.a on glibc >= 2.34 (Ubuntu 22.04+) fails with
undefined __dn_expand / __res_nsearch / __dn_skipname. libphp.a is
compiled against glibc 2.28, which still exported those unversioned
compat aliases; 2.34 moved libresolv into libc and dropped them. NTS
tarballs now ship embed/resolver_shim.c (from ephpm, MIT, maps the
underscored names to the public resolver API) plus EMBEDDING.md
documenting the link line via the relocatable bin/php-config.
2. PAM's build detects only a shared libphp. New platform entries
linux-{x86_64,aarch64}-gnu-nts-shared set
SPC_CMD_VAR_PHP_EMBED_TYPE=shared (env-driven in spc rc18
src/Package/Target/php/unix.php, no fork patch), producing
php-sdk-<ver>-linux-<arch>-gnu-nts-shared.tar.gz with lib/libphp.so
(dependencies statically linked in, versioned lib + symlink) instead
of libphp.a. Staging, the x86_64 intrinsics guard, and the release
body updated accordingly; ZTS guard unchanged (php_config.h).
versions.json: shared platforms added to platforms_nts so watch-php
keeps them current for minors_nts once assets exist.
- libphp.so in the shared tarball is a plain file, not a versioned symlink (rc18 only versions it when a -release is set, which this build does not). - The shared library's resolver references are versioned (__dn_expand@GLIBC_2.2.5, confirmed via readelf on the shtest build), so the shim really is static-only; say how to check. - Document the ~15 undefined C++ runtime refs in libphp.so: the loading process needs libstdc++.so.6.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two integration gaps reported by PAM building against the NTS SDK.
1. Static link fails on glibc >= 2.34: undefined __dn_expand / __res_nsearch / __dn_skipname
lib/libphp.ais compiled against glibc 2.28, which still exported the unversioned resolver compat aliases that PHP'sext/standard/dns.creferences. glibc 2.34 moved libresolv into libc and dropped them, so linking on Ubuntu 22.04+ / Debian 12+ / RHEL 9+ fails.NTS tarballs (
-gnu-ntsand-gnu-nts-shared) now shipembed/resolver_shim.c(from ephpm, MIT, attribution in the header — maps the underscored names to the public resolver API) and anEMBEDDING.mddocumenting the link line via the relocatablebin/php-config.Reproduced and verified in an ubuntu:22.04 (glibc 2.35) container against the v8.4.24 x86_64 NTS tarball:
undefined reference to '__dn_expand'(ext/standard/dns.c), link exit 1embed-ok 8.4.24 zts=02. Shared-embed NTS variant for consumers that only detect libphp.so
PAM's build detects
libphp.so/.dylib, not.a. New platform entrieslinux-{x86_64,aarch64}-gnu-nts-sharedsetSPC_CMD_VAR_PHP_EMBED_TYPE=shared— env-driven in spc rc18 (src/Package/Target/php.php:274,php/unix.php:368), no fork patch — producingphp-sdk-<ver>-linux-<arch>-gnu-nts-shared.tar.gzwithlib/libphp.so(dependencies statically linked in; no dependency archives shipped). Staging, the x86_64 SHA-NI intrinsics guard, and the release body are adapted; the ZTS guard (php_config.h) applies unchanged.versions.jsonadds the shared platforms toplatforms_ntsso watch-php keeps them current forminors_nts.Validation (test tag v8.4.24-shtest, x86_64, both runs green, tag deleted after)
embed/resolver_shim.c+EMBEDDING.md(tar listing)lib/libphp.so+ bundledlibstdc++.a,embed/+EMBEDDING.md, no.adependency archivesnm -D:php_embed_init/php_embed_shutdownexported#define ZTS 1inphp_config.h(NTS)readelf --dyn-syms: resolver refs are versioned (__dn_expand@GLIBC_2.2.5), so the shim is genuinely static-onlysapi=embed zts=0 opcache_loaded=1 opcache_active=1— OPcache activates under the embed SAPI, proving the rc18SPC_OPCACHE_EXTRA_SAPISallowlist injection end to end (opcache_active=0is what an un-whitelisted SAPI produces on 8.4)ZendAcceleratorliterals are only valid on the unlinked object (.amember) — the linker's literal merging deduplicatesembed/litespeedin the final.so, which is why the functional gate is the evidence hereWhat PAM should be told
-gnu-nts): compileembed/resolver_shim.cfrom the tarball into the embed build; link line viabin/php-config --includes/--libs. Required on any glibc >= 2.34 host.php-sdk-<ver>-linux-<arch>-gnu-nts-shared.tar.gz;lib/libphp.soworks with their existing shared-library detection,-lphp, no shim needed. The loading process needslibstdc++.so.6at runtime.aarch64 shared is unvalidated so far — x86_64 first per plan; the aarch64 leg differs only in runner/arch, and its static NTS twin is proven on both arches.