Aro – Zig's new C compiler

Purpose and Design of Aro

  • Aro is a self-contained C compiler written in Zig, targeting C23 and common GNU extensions.
  • Main goal: remove Zig’s dependency on libclang/LLVM for C while still allowing LLVM as an optional backend.
  • Currently integrated into the Zig repo primarily for translate-c; long-term intent is to replace libclang for parsing C, including for header translation.

Zig Ecosystem and Philosophy

  • Several comments praise Zig’s tooling (cross-compilation, bundled libc, linker) as a major strength, sometimes more impressive than the language itself.
  • Zig is seen as “infrastructure-oriented”: minimal features, strong focus on build, cross-compile, and low-level control, contrasting with “feature-rich” languages.
  • Some see Zig as a good candidate for embedded and systems work; others argue its allocator-centric model perpetuates unsafe C-style memory management, though Zig improves null and pointer safety.

LLVM Independence and Compiler Architecture

  • Removing the LLVM/Clang dependency is a central roadmap item; Aro is one piece, Zig’s self-hosted backends and linker are others.
  • Discussion references data-oriented design in the compiler and ongoing work on fast self-hosted backends and incremental compilation; recent reports say Zig can self-compile without LLVM in under ~10 seconds.
  • Plan: deprecate @cImport in favor of build steps that translate headers to Zig modules.

Status, Limitations, and Tooling

  • Aro currently has limited backend support; full compilation isn’t complete.
  • System header search paths work only on Linux; elsewhere, even stdio.h may fail.
  • Documentation is considered sparse; Zig has its own doc generator using structured comments.

Interop, FFI, and Comparisons

  • Several comments contrast Aro/Zig’s C story with other languages that embed C compilers or parse headers directly.
  • A Bun FFI maintainer is interested in using Aro to infer types from C headers automatically.
  • Some debate whether comments about other languages’ C integration are on-topic, but others view them as useful design comparisons.

Language Features Debates

  • Brief debate on whether Zig should add native complex numbers and richer numeric types.
  • Objection raised that, without operator overloading, user-defined numeric types are awkward, making built-in complex types more compelling.