[RFC] 3.0 Updates - Zig Support
[RFC] 3.0 Updates - Zig Support
In current 2.x version, we regard zig as an alternative build toolchain. Based on our previous ideas, we will use ZigToolchain as the default build toolchain for Linux in version 3.0. This process will be virtually seamless for the normal build workflow, requiring almost no modifications.
However, given the current stability of the toolchain, whether to retain support for the old toolchain in version 3.0 is a big question mark.
Because gcc/clang has stood the test of time and solutions can be found for most situations, while ziglang is still in version 0.x, but SPC currently uses it almost perfectly, so we're unsure whether to officially abandon other build solutions.
This is because, to date, SPC, whether used to build PHP, extensions, or other packages, has aimed to build portable binaries; we won't invest too much effort in building ordinary, dynamically linked, and non-portable binaries.
If you have any question or have better suggestions, please leave comment here with quote.
We can't abandon gcc because of the performance in php < 8.5.
We could deprecate clang, but there's not really a point as everything clang needs is covered with our zig support.
currently the zig linker can not handle thin archive. so i have issues to build wayland for my sdl project
i not know if any other extension is affected.
https://github.com/ziglang/zig/issues/25694
@henderkes What are your thoughts on linux default toolchain for v3? This could impact the module refactoring of our hosted pre-built libraries (and drop SPC_LIBC right?)
Optimally, default for 8.5+ is zig, default for <=8.4 should remain gcc.
For dropping SPC_LIBC I think that's okay. If someone wants musl binaries compiled with gcc they'll just have to use alpine.
@crazywhalecc I think we should switch the macOS default to Zig as well. We actually only need to support Zig on macOS.
Advantages:
- no need to install a ton of brew packages, which takes time
- we get an up-to-date clang toolchain (would fix current tailcall clang crashes)
- we don't need to support older versions of clang or macos, because zig runs the same no matter where you run it and ignores system libraries
Disadvantages:
- none?