static-php-cli icon indicating copy to clipboard operation
static-php-cli copied to clipboard

[RFC] 3.0 drop musl toolchain

Open henderkes opened this issue 2 months ago • 6 comments

I would like to drop musl toolchain support for 3.0. It's a pain to compile, it's still an old gcc 13 version and it forces us to host our own black box binaries.

Php compiled statically against musl is slow. Users can compile php staticallly linked against musl with zig.

The only benefit the musl toolchain has is compiling on a glibc system without docker and getting slightly better performance than with zig for php <8.5. Even then it's slower than using docker to use alpine. In my eyes, that's just not worth it.

henderkes avatar Dec 05 '25 07:12 henderkes

Compared to musl-toolchain deprecation, I'm more concerned about how we handle the maintenance of spc-*-docker. Removing musl-toolchain is straightforward in 3.0, I never thought it would be difficult to manage. But after we making zig as first-class citizen, there's no need to keep this docker scripts though.

crazywhalecc avatar Dec 05 '25 08:12 crazywhalecc

Compared to musl-toolchain deprecation, I'm more concerned about how we handle the maintenance of spc-*-docker. Removing musl-toolchain is straightforward in 3.0, I never thought it would be difficult to manage. But after we making zig as first-class citizen, there's no need to keep this docker scripts though.

We never know if gcc will pull ahead of clang again. For php 8.2-8.4 gcc still produces ~35% faster php binaries. That's why I think we have to keep support for alpine gccnative.

henderkes avatar Dec 05 '25 08:12 henderkes

Since musl-toolchain is still available, I think we should first discuss what the default toolchain should be for non-Alpine distros. Which toolchains to retain and remove support for will depend on this.

The default solution should, in any case, be able to be built without Docker. And I prefer we don't have to pursue ultimate performance in the default way is built.

crazywhalecc avatar Dec 05 '25 08:12 crazywhalecc

And I prefer we don't have to pursue ultimate performance in the default way is built.

Then there is no reason to keep musl toolchain at all. Zig can build it and is much less maintenance.

Since musl-toolchain is still available, I think we should first discuss what the default toolchain should be for non-Alpine distros. Which toolchains to retain and remove support for will depend on this.

My vote is for gcc 15 for php <= 8.4, zig for php >= 8.5. That's just what gives the best performance and we maintain both anyway.

Except on macOS, I guess. The homebrew gcc 15 toolchain is defective in my testing, so might have to use ClangNative always.

henderkes avatar Dec 05 '25 09:12 henderkes

My vote is for gcc 15 for php <= 8.4, zig for php >= 8.5. That's just what gives the best performance and we maintain both anyway.

The toolchain is at a much lower level than the PHP version, so it's best not to automatically select a toolchain based on the PHP version.

I prefer to use ZigToolchain as the default, but CI and documentation recommend manually specifying the corresponding build method for fastest results. In other words: I vote for Zig as the default, keep alpine-docker, and remove support for gnu-docker and musl-toolchain (for this RFC)

crazywhalecc avatar Dec 05 '25 09:12 crazywhalecc

That's sensible as well, I agree with your choices.

-> Linux: Zig (default), GccNative on musl and glibc are supported. Alpine docker stays, gnu docker removed.

-> MacOS: ClangToolchain also supported, can Zig become the default? I'm not sure if you've implemented Zig support for macOS yet.

henderkes avatar Dec 05 '25 10:12 henderkes