Description
This solves the last remaining blocker for #16270, which was proving tricky to find a satisfactory solution to.
What users experience right now is these subcommands being provided via a single binary distribution available from ziglang.org/dowload, as a zip or tarball.
Without a compiled version of LLVM and Clang inside the same executable as Zig, the equation shifts. Some proposed solutions are:
- A separately maintained project on a different release schedule that depends on those libraries and provides these subcommands. Downside: there would be multiple binary distributions for people to choose from which represents a slight complexity increase in user experience.
- Subcommands continue to work as before in the main zig binary, however the implementation relies on fetching a package that contains a prebuilt binary that implements translate-c and provides clang. Downside: the tarball/zipfile is not self-contained for these use cases since a subsequent fetch would be needed.
We can imagine combinations of these approaches as well, such as supporting prefetched packages in the zig installation directory and providing downloads that contain clang already prefetched in it.
The fundamental conflict comes down to:
- Some use cases want a minimal Zig that has no Clang or LLVM inside of it.
- Other use cases want extra features that depend on Clang and LLVM.
Having typed this out, I think the solution is clear: both!
A separately maintained project should depend on Zig, Clang, and LLVM, and implement the extra utility on top of those dependencies. ziglang.org will continue to post only zig binaries; those binaries will no longer link against Clang and LLVM. This separate project which may or may not have its own website will post binaries whose invocations will look like zig-extras cc
, zig-extras c++
, zig-extras translate-c
. The project could provide a strict superset of subcommands, making it a drop-in replacement for zig that supports those extra commands. I'm sure at least two dozen geniuses will suggest to name this project "zag".
Meanwhile, serious people will be 100% fine with the zig binary that does not depend on LLVM and Clang because they will have full access to these features via the all-powerful build system, and they already know that zig cc
is a silly gimmick that is completely unnecessary for real world projects. Even so, those subcommands will work with this LLVM-less build of zig, because they will use the build system to fetch and cache the package that provides the necessary functionality.