fix(build): re-enable x86 hardware intrinsics (SHA-NI, PCLMUL, AVX2)#36
Merged
Conversation
The spc fork env.ini places -fvisibility-inlines-hidden (C++-only) in
PHP_MAKE_EXTRA_CFLAGS. GCC warns on every C compile, php-src's
AX_GCC_FUNC_ATTRIBUTE macro treats any stderr as "unsupported", and
HAVE_FUNC_ATTRIBUTE_TARGET/IFUNC come back undefined -- so every Linux
SDK ever shipped had ALL x86 intrinsic resolvers compiled out:
- SHA-NI sha256: measured 2.7x slower than FrankenPHP/docker builds
(540ns vs 200ns per 64-byte digest)
- PCLMUL crc32c: 2.2x slower
- every ZEND_INTRIN_* resolver (SSSE3/SSE4.2/AVX2/AVX512 incl. base64)
Verified via nm on shipped tarballs (no SHA256_Transform_shani symbol),
an autoconf repro on the almalinux8/gcc-13 builder (236 bytes of stderr
with the flag, 0 without), and an algo matrix where exactly the two
algorithms with attribute-gated hardware paths run 2-3x slow while all
others sit at ratio ~1.0.
Upstream static-php-cli fixed the flag placement on main in May 2026;
until the fork rebases onto that, override PHP_MAKE_EXTRA_CFLAGS via
env (real env vars win over env.ini) with the identical value minus
the one poison token, ${SPC_DEFAULT_CFLAGS} pre-expanded.
Adds a hard guard after staging: x86_64 builds fail unless
HAVE_FUNC_ATTRIBUTE_TARGET is defined in php_config.h AND
SHA256_Transform_shani is present in libphp.a -- a soft-sha256 SDK can
never ship silently again.
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.
Summary
-fvisibility-inlines-hidden) in the spc fork'sPHP_MAKE_EXTRA_CFLAGSmakes GCC warn on every C compile, and php-src'sAX_GCC_FUNC_ATTRIBUTEtreats any stderr as "attribute unsupported" --HAVE_FUNC_ATTRIBUTE_TARGET/IFUNCcome back undefined, so SHA-NI sha256 (measured 2.7x slow), PCLMUL crc32c (2.2x), and the SSSE3/AVX2ZEND_INTRINpaths (incl. base64) never build.SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGSvia env in the Linux build script (env beats env.ini) with the identical flag set minus the poison token, pre-expanded. No fork change needed -- upstream spc already fixed the placement on their main; the fork inherits it whenever it rebases.HAVE_FUNC_ATTRIBUTE_TARGETis defined andSHA256_Transform_shaniis present inlibphp.a.Evidence
nmon shipped8.4.22 linux-x86_64{,-gnu}tarballs: noSHA256_Transform_shani,php_config.hhas/* #undef HAVE_FUNC_ATTRIBUTE_TARGET */Test plan
linux-x86_64-gnu+linux-x86_64builds for 8.4 from this branch