Remix.run Logo
chris_armstrong 2 days ago

If I recall correctly, this is one of the final pieces that allows zig to be used as a fully self-contained cross-compiling C toolchain (once its linker is enabled for more platforms / formats)

olivia-banks 2 days ago | parent [-]

I might be misunderstanding, but I don’t think that's quite accurate. As I understand it, Zig ships a Clang frontend and wraps it with precompiled sysroots. Unless they're developing an LLVM backend, I'm not sure how it could serve as a completely self-contained toolchain.

chris_armstrong 2 days ago | parent | next [-]

zig has a cross-compiler frontend (zig cc) which can be used as a drop-in replacement for a custom sysroot + binutils + gcc for several platforms. I've used it to build OCaml cross-compilers that only depend on zig itself (https://www.chrisarmstrong.dev/posts/ocaml-cross-compilation...).

There are other projects that have used it in a similar way too.

[1] https://actually.fyi/posts/zig-makes-rust-cross-compilation-... [2] https://jcbhmr.com/2024/07/19/zig-cc-cmake/

olivia-banks 2 days ago | parent [-]

Interesting. OCaml cross compilation scared me the one time I considered it, so it's nice to know this is an option. I will be pedantic and say it isn't a replacement for a custom sysroot/binutils/whatnot, since it really just papers over those user-facing details by shipping a prebuilt collection of sysroots and using LLD. They sorta get this for free since they need it for cross-compiling Zig code anyways.

stock_toaster 2 days ago | parent | prev [-]

Zig does have its own native x86_64 backend for debug compilation.

ref: https://ziglang.org/devlog/2025/#2025-06-08

olivia-banks 2 days ago | parent [-]

They're also getting an aarch64 backend soon (or has it already landed)? Really looking forward to this one for development on my Mac!

My point was that Zig uses their backends (which includes their homegrown ones), but since `zig cc` is a wrapper around Clang, it always goes through the `LLVM` path and sidesteps the Zig backend(s).

stock_toaster 2 days ago | parent [-]

Ah. I see what you are saying now. I believe you are correct.