Compiling ren-c with zig?

Has anyone tried to compile ren-c with zig? ( ).

They claim to be able to compile c-code using zig cc , and have an impressive list of cross compilation targets, wasm among them.

1 Like

Given that I'm back at coding with a bit more enthusiasm right now, I thought it would probably be worth it to take a crack at building Ren-C with Zig again.

Lo and behold, I managed to generate an x86_64 executable on Linux via Zig. Woo. :partying_face:

It also had test parity with GCC builds (at the moment a lot of failures, but no crashes).

I hacked through it in both C++ and C compilation modes.

While this may sound great, be prepared for a bit of disappointment...

That cross-compilation comes from the fact that Zig is dependent on LLVM (~169 MiB), just as Emscripten is.

There was a roadmap document in 2020 about letting go of the "training wheels". And circa October 2022, an issue on their GitHub offers "reasons why one want an LLVM-less binary", painting an optimistic picture:

  • The executable is 4.4 MiB instead of 169 MiB.

  • Bootstrapping it only requires a C compiler instead of requiring a modern C++ compiler, Python 3, bash, and CMake (also C++).

    • This would make it much easier to obtain a Zig compiler on a new operating system or a limited environment such as a calculator.

But that's still some future vision. They say currently "Zig is not very useful without enabling LLVM extensions." I think this just means that they're like every other project (including Red, including Ren-C)... talking about a future thing when that future may be very very far off.

It certainly doesn't hurt to have Ren-C's deep vetting for standards show it building successfully on yet another compiler. And if that compiler does perchance make a decision aiming in the same vicinity as Ren-C (e.g. "we're going to focus on Wasm, vs requiring to target every esoteric LLVM emitter") it may make a better choice than other toolchains.

But for the moment, their Wasm doesn't have the integration Emscripten provides, and it's not that much thinner so long as the LLVM dependency is there.