Skip to content

Link mimalloc into binaries embedding PHP - #1253

Merged
crazywhalecc merged 1 commit into
crazywhalecc:v3from
dunglas:fix/mimalloc-link
Oct 11, 2026
Merged

crazywhalecc merged 1 commit into
crazywhalecc:v3from
dunglas:fix/mimalloc-link

Conversation

@dunglas

@dunglas dunglas commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Builds with mimalloc compile libmimalloc.a but never link it, so the resulting binaries silently keep the system allocator.

Since 01a1db85, SPCConfigUtil::configForResolvedBuild() builds the link line from the dependency closure of the target instead of every resolved package. Nothing depends on mimalloc, so it drops out of that closure and the existing "mimalloc must come first" handling never triggers. This affects frankenphp as well as the php cli, micro and embed targets.

This PR adds mimalloc to the php link override when it was resolved. Every binary that links PHP gets it, while shared extensions and library builds, whose closures don't go through php, are unchanged. A unit test covers both sides, and it fails without the change.

Checked with FrankenPHP static musl builds (arm64, PHP 8.5.11) using a spc binary built from this branch:

Build CGO_LDFLAGS from frankenphp build-info MIMALLOC_VERBOSE=1 frankenphp version
without mimalloc -L.../buildroot/lib -lphp ... no output
mimalloc v2 -L.../buildroot/lib .../buildroot/lib/libmimalloc.a -lphp ... mimalloc: v2.5.2, release
mimalloc v3 -L.../buildroot/lib .../buildroot/lib/libmimalloc.a -lphp ... mimalloc: v3.5.4, release

With the current nightly, the mimalloc builds look like the first row.

Checklist before merging

  • If you modified *.php or *.yml, run them locally to ensure your changes are valid:
    • composer cs-fix
    • composer analyse
    • composer test
    • bin/spc dev:lint-config (no config changes)

Since the link closure only walks dependencies of the target, and
nothing depends on mimalloc, MIMALLOC builds compiled libmimalloc.a but
never linked it, so the binaries kept the system allocator.
@crazywhalecc
crazywhalecc merged commit c2b02e4 into crazywhalecc:v3 Oct 11, 2026
8 checks passed
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.

3 participants