fix(build): run the target-attribute probe on musl (#51) - #52
Merged
Conversation
php-src configure.ac skips AX_GCC_FUNC_ATTRIBUTE for both ifunc and target on any *-*-*musl* host_alias, and host_alias holds the canonical triple even though nothing passes --host, so on Alpine the probe never runs at all: config.log has no ax_cv_have_func_attribute_target line and php_config.h keeps /* #undef HAVE_FUNC_ATTRIBUTE_TARGET */. Not a CFLAGS problem -- the probe links with zero stderr under the override flags on Alpine gcc 13.2. The exclusion is there for ifunc, which musl really lacks; target alone selects the MINIT-resolved SIMD paths (ZEND_INTRIN_*_FUNC_PTR, PHP_HASH_INTRIN_SHA_RESOLVER). Patch configure.ac in the php-src mirror tarball before spc sees it, and pin the build-phase download to that same tarball with --dl-custom-url. spc download only downloads and spc build force-extracts, so there is no window between them where the extracted tree can be patched; without --dl-custom-url the build phase re-resolves php-src to php.net and checksum-validates it, discarding the patch. Verified on alpine:3.20 with php 8.5.9 ZTS: HAVE_FUNC_ATTRIBUTE_TARGET 1, HAVE_FUNC_ATTRIBUTE_IFUNC still undef, SHA256_Transform_shani present in libphp.a. The shipped 8.5.9 musl tarball has neither. The x86_64 intrinsics guard is now a hard error on musl too.
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.
Closes #51.
Every musl x86_64 SDK since 8.3.31 has shipped with
/* #undef HAVE_FUNC_ATTRIBUTE_TARGET */, so PHP fell back to portable C for SHA-NI, PCLMUL (CRC32) and AVX2. The CFLAGS override in43267a7fixed this on the glibc lane and never did anything on Alpine.Root cause — not CFLAGS
php-src's own
configure.acskips the probe on musl:$host_aliasholds the canonical triplex86_64-pc-linux-musleven though nothing passes--host, so on Alpine the case matches and both probes are skipped —config.loghas noax_cv_have_func_attribute_targetline at all andphp_config.hkeeps the#undef.The exclusion exists for
ifunc, which musl genuinely lacks.targetwas swept into that same exclusion, but it is a pure compiler feature with no libc dependency — the target probe links with zero stderr on Alpine gcc 13.2 under the exact build CFLAGS.targetalone is what selects the non-ifunc, MINIT-resolved SIMD paths (ZEND_INTRIN_*_FUNC_PTRinZend/zend_portability.h,PHP_HASH_INTRIN_SHA_RESOLVERinext/hash/php_hash_sha.h).This looks like an upstream php-src bug —
targetdoes not belong in the ifunc exclusion. Working around it downstream for now; flagging rather than filing upstream.Fix
Inject
AX_GCC_FUNC_ATTRIBUTE([target])unconditionally intoconfigure.ac, leavingifuncgated as php-src intends.The patch goes into the php-src mirror tarball before spc sees it, not the extracted tree:
spc downloadonly downloads, andspc buildforce-extracts, so there is no window between the two commands where/build/source/php-srcexists to patch — an earlier attempt that patched the extracted path failed in CI withconfigure.ac: No such file or directory.spc buildis pinned to that same tarball with--dl-custom-urlso the build phase doesn't re-resolve php-src to php.net (which would discard the patch and fail the upstream SHA256 against our repacked tarball).The x86_64 intrinsics guard is now a hard error on musl too, not a warning.
Verified (artifacts, not job status)
Branch dispatch to
v8.5.9-musl51(tag suffix, since deleted), then inspected the real CI artifacts:HAVE_FUNC_ATTRIBUTE_TARGETHAVE_FUNC_ATTRIBUTE_IFUNCSHA256_Transform_shanicrc32_x86_simd_updatelib/*.a/libstdc++.agnu is unchanged in behaviour (the added probe hits the autoconf cache).
Follow-up
Every shipped musl x86_64 tarball needs a rebuild once this merges: 8.3.32 (gnu+musl), 8.4.23, 8.4.24, 8.5.8, 8.5.9 musl, plus 8.3.33 musl (has
libstdc++.afrom #50 but still no SIMD).