Commit fa55696
committed
Force function-pointer CPU dispatch for zig builds to fix silent lld crash
Root cause of the intermittent 'Aborted (core dumped) zig-cc' at the
sapi/cli/php LTO link, proven by byte-exact local replay of the CI link
(lld --reproduce) and single-file bisection:
PHP's configure probes __builtin_cpu_supports/__builtin_cpu_init with a
link test that runs under -flto. Whether zig resolves compiler-rt's
__cpu_model in that probe varies by machine, so the result is a per-VM
lottery. When it says yes, zend_portability.h enables
ZEND_INTRIN_*_FUNC_PROTO and mbstring/standard compile
__attribute__((ifunc)) AVX2 resolvers. An ifunc in full-LTO bitcode
crashes zig 0.16's lld (LLVM 21.1.0): during LTO prevailing-symbol
resolution it dereferences a null summary for the local symbol
mb_cut_utf16le (GUID 0x151eb2c1758fcd09 = md5_64 of
'<mbfilter_utf16.c>;mb_cut_utf16le'), and the zig driver swallows the
child's SIGSEGV, leaving no output.
Verified both directions: compiling mbfilter_utf16.o with the cpu
builtins defined produces the ifunc object and the link crashes;
compiling with them off produces the function-pointer object and the
same link succeeds.
Forcing the configure cache vars to no (like the existing avx512
overrides) makes every build take the safe, deterministic
function-pointer dispatch path. Runtime cost is a pointer call instead
of an ifunc-resolved call for a handful of mb/crc32 functions.1 parent 6b998b2 commit fa55696
1 file changed
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
101 | 107 | | |
102 | 108 | | |
103 | 109 | | |
| |||
0 commit comments