Skip to content

fix: pick the glibc SDK on glibc hosts, and stop skipping the suite (#215) - #229

Merged
s2x merged 1 commit into
mainfrom
fix/sdk-musl-detection-and-test-command
Sep 29, 2026
Merged

s2x merged 1 commit into
mainfrom
fix/sdk-musl-detection-and-test-command

Conversation

@s2x

@s2x s2x commented Sep 28, 2026

Copy link
Copy Markdown
Member

Follow-up to the #215 work on main. Two problems there made local development on a glibc machine impossible. Both were hit while trying to run the milestone-0.7 issues.

1. fetch_zvec_sdk.sh picked the musl SDK

is_musl() { ls /lib/ld-musl-*.so.1 >/dev/null 2>&1; }

On any glibc host with musl-tools installed that succeeds. The musl SDK got unpacked, and every test failed at ZVec::ffi():

FFI\Exception: Failed loading '.../libzvec_ffi.so'
  (libc.musl-x86_64.so.1: cannot open shared object file: No such file or directory)
$ objdump -p sdk/lib/libzvec.so | grep NEEDED
  NEEDED   libc.musl-x86_64.so.1     # while PHP here is a plain glibc build
$ ldd $(command -v php) | grep -c musl
0

The property that matters is not what the machine has installed but which loader the PHP binary uses, so detection now inspects ldd $(command -v php), falls back to /bin/sh when there is no PHP, and assumes glibc when neither marker is present. PHP_BINARY overrides the probe.

The SDK layout then hid it. copy_if_different in ffi/CMakeLists.txt keeps the previously copied libzvec.so when the incoming one has a different mtime, so a stale musl libzvec.so sat next to a freshly linked adapter and the adapter built and linked fine. rm -rf sdk ffi/build is needed when switching SDKs — now documented.

2. The documented test command skipped 172 of 191 tests

AGENTS.md mandated php run-tests.php -n tests/. -n strips php.ini, and FFI comes from conf.d/20-ffi.ini here rather than being compiled in:

$ php -n -r 'var_dump(extension_loaded("ffi"));'
bool(false)

So the whole suite reported SKIP ... reason: FFI extension not available, and the 16 tests that did run passed — a green-looking summary over almost nothing:

before after
passed 16 189
skipped 172 0
failed 1 0

The real goal is FFI enabled and the legacy zvec extension disabled, which is php run-tests.php -n -d extension=ffi.so tests/. Updated everywhere, plus a note that a run reporting skips is a broken run rather than a pass.

Verification

From a clean tree:

rm -rf sdk ffi/build && ./build_zvec.sh
php run-tests.php -n -d extension=ffi.so tests/
Number of tests : 191               191
Tests skipped   :   0 (  0.0%)
Tests failed    :   0 (  0.0%)
Expected fail   :   2 (  1.0%)
Tests passed    : 189 ( 99.0%)

test_dbs/ is left with only .gitignore.

Note

The Mismatched free() / delete finding from #228 is still open and untouched here.

🤖 Generated with Claude Code

…215)

Two independent problems made `main` unusable for local development on a
glibc machine.

1. fetch_zvec_sdk.sh selected the musl SDK

The musl check was `ls /lib/ld-musl-*.so.1`. On any glibc host with
musl-tools installed that succeeds, so the musl SDK was unpacked and
every single test then failed at ZVec::ffi() with

    libc.musl-x86_64.so.1: cannot open shared object file

The property that matters is not what the machine has but which loader
the PHP binary uses, so the detection now inspects
`ldd $(command -v php)`, falls back to /bin/sh when there is no PHP, and
assumes glibc when neither marker is found. `PHP_BINARY` overrides the
probe.

The SDK layout then hid the problem: `copy_if_different` in
ffi/CMakeLists.txt keeps the previously copied libzvec.so when the new
SDK's copy has a different mtime, so a stale musl libzvec.so sat next to
a freshly linked adapter. Removing sdk/ and ffi/build/ before rebuilding
resolves it, which AGENTS.md now spells out.

2. The documented test command skipped 172 of 191 tests

AGENTS.md mandated `php run-tests.php -n tests/`. `-n` strips php.ini,
and FFI is provided by conf.d/20-ffi.ini here rather than being compiled
in, so FFI disappeared and the whole suite reported SKIP with
"reason: FFI extension not available" -- on a machine where FFI was
available and working. The 16 tests that did run passed, so the failure
mode was a green-looking summary over almost nothing.

The actual goal is FFI enabled *and* the legacy zvec extension disabled,
which is `php run-tests.php -n -d extension=ffi.so tests/`. All test
commands in AGENTS.md and the closing hint in build_zvec.sh updated, with
a note that a run reporting skips is a broken run rather than a pass.

Tests: 191/191, 0 skipped, 0 failed, 2 expected fail, verified from a
clean `rm -rf sdk ffi/build && ./build_zvec.sh`.
@s2x
s2x merged commit b791ee3 into main Sep 29, 2026
6 checks passed
@s2x
s2x deleted the fix/sdk-musl-detection-and-test-command branch September 29, 2026 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant