You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[v3][macOS] xcaddy link fails with <initial-undefines> due to non-Mach-O symbol fragments in libphp.a.dynsym #1294
When compiling FrankenPHP (or embedding PHP) on macOS using static-php-cli v3 (spc craft), spc fails at the buildFrankenphpForUnix stage:
Building frankenphp: building with xcaddy
[EXEC] go clean -cache
[EXEC] xcaddy build --output frankenphp --with github.com/dunglas/frankenphp=...
✘ Command execution failed: Command exited with non-zero code: 1
-------------------- Module error info --------------------
Failed module: Target Package 'frankenphp'
Failed stage: build -> buildFrankenphpForUnix
Failed command: xcaddy build --output frankenphp ...
- Exit code: 1
Inside dist/log/spc.shell.log, the underlying Apple clang / ld error is:
Undefined symbols for architecture x86_64:
"10", referenced from:
<initial-undefines>
"Init", referenced from:
<initial-undefines>
"lue", referenced from:
<initial-undefines>
"st_sort", referenced from:
<initial-undefines>
"y_rinit", referenced from:
<initial-undefines>
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1
<initial-undefines> indicates that Apple's ld was asked to export symbols via -Wl,-exported_symbols_list,/path/to/libphp.a.dynsym that do not exist in any linked object file.
In src/StaticPHP/Util/System/UnixUtil.php: UnixUtil::exportDynamicSymbols() runs nm -g --defined-only -P libphp.a.
BSD ar Header Limits on macOS: In BSD ar, the ar_hdr.ar_name field has a fixed 16-character limit. Long member names (e.g., php_basic_early_rinit.o, zend_llist_sort.o) use BSD extended name headers (#1/<len>). When nm processes the archive, member headers or line continuations that do not end strictly with .o: or .o]: are parsed by strtok($line, " \t"), leaking line fragments like 10, Init, lue, st_sort, y_rinit into $defined.
Darwin Mach-O Symbol Convention: In Mach-O C ABI, all valid C symbols generated by compilers start with a leading underscore (_). Strings without a leading _ cannot be valid exported C symbols on Darwin.
Apple's ld treats -Wl,-exported_symbols_list strictly: any entry without a matching symbol in the linked objects causes linking to abort immediately. (GNU ld on Linux is lenient with --dynamic-list, which is why this does not break on Linux).
Note on Testing & Debugging
Note
All testing, reproduction, and debugging for this issue and the corresponding PRs were conducted with the assistance of AI (Google Antigravity).
Activity