Zig cc: a better clang?

Check out this article on zig cc.

Here, rather than downloading the x86_64-linux version, which matches the computer I am currently using, I’ll download the Windows version and run it in Wine to show how simple installation is:

andy@ark ~/tmp> wget --quiet https://ziglang.org/builds/zig-windows-x86_64-0.5.0+13d04f996.zip** **andy@ark ~/tmp> unzip -q zig-windows-x86_64-0.5.0+13d04f996.zip
andy@ark ~/tmp> wine64 ./zig-windows-x86_64-0.5.0+13d04f996/zig.exe cc -o hello hello.c -target x86_64-linux
andy@ark ~/tmp> ./hello
Hello, World!

Take a moment to appreciate what just happened here - I downloaded a Windows build of Zig, ran it in Wine, using it to cross compile for Linux, and then ran the binary natively. Computers are fun!

Compare this to downloading Clang, which has 380 MiB Linux-distribution-specific tarballs. Zig’s Linux tarballs are fully statically linked, and therefore work correctly on all Linux distributions. The size difference here comes because the Clang tarball ships with more utilities than a C compiler, as well as pre-compiled static libraries for both LLVM and Clang. Zig does not ship with any pre-compiled libraries; instead it ships with source code, and builds what it needs on-the-fly.

It would probably be a huge source of issues, but it’s fun to contemplate replacing clang with zig cc in the stdenv and just building the entire system with ti :slight_smile: