July 20th, 2024

Aro – Zig's new C compiler

Aro is a C compiler integrated into Zig, focusing on fast compilation, low memory usage, and good diagnostics. It supports C up to C23, GNU, MSVC, and Clang extensions. Find more on GitHub.

Read original articleLink Icon
QuestionsSkepticismInterest
Aro – Zig's new C compiler

The GitHub URL provided contains information about Aro, a C compiler designed for fast compilation, low memory usage, and good diagnostics. Aro is integrated into the Zig compiler as an alternative C frontend for `translate-c` and aims to compile C files by translating them to Zig. It supports standard C up to C23 and various extensions from GNU, MSVC, and Clang. Aro offers basic code generation for x86-64 Linux and can successfully generate a "Hello, world!" program. For further information, the Aro GitHub repository can be accessed at https://github.com/Vexu/arocc.

Related

A portable lightweight C FFI for Lua, based on libffi

A portable lightweight C FFI for Lua, based on libffi

A GitHub repository offers a portable lightweight C FFI for Lua, based on libffi. It aims for LuaJIT FFI compatibility, developed in C. Includes features, examples, basic types, build instructions, testing, and acknowledgements.

Zig-style generics are not well-suited for most languages

Zig-style generics are not well-suited for most languages

Zig-style generics, inspired by C++, are critiqued for limited universality. Zig's simplicity contrasts with Rust and Go's constraints. Metaprogramming praised for accessibility, but error messages and compiler support pose challenges. Limited type inference compared to Swift and Rust.

Oxidize – Notes on moving Harfbuzz and Freetype tools and libraries to Rust

Oxidize – Notes on moving Harfbuzz and Freetype tools and libraries to Rust

The "oxidize" project on GitHub aims to migrate tasks from Python & C++ to Rust, such as shaping, rasterization, font compilation, and manipulation. It outlines objectives, priorities, and references. For more details, inquire further.

AxRuntime (AxRT): Creating Applications Using Amiga APIs

AxRuntime (AxRT): Creating Applications Using Amiga APIs

AxRuntime (AxRT) aids developers in creating Amiga applications seamlessly on Linux or Windows using modern tools. Recent updates include AROS ABIv0 version 20220318-1 and AxRuntime version 41.5 in 2023, emphasizing Amiga API compatibility.

Show HN: You can program without loop and recursion and×÷- is all you need

Show HN: You can program without loop and recursion and×÷- is all you need

A language named "Ar" on GitHub, inspired by Blindfolded Arithmetic and Z3, is Turing complete with functions like inc, sub, mul, and div. It implements various operations and aims to compute the Ackermann function, sparking discussions.

AI: What people are saying
The discussion around Aro, a C compiler integrated into Zig, brings up several key points:
  • Clarification that Aro is an independent project by Veikka Tuominen, not officially managed by the Zig Software Foundation.
  • Questions and concerns about Aro's functionality, such as its inability to include standard headers and its value proposition given Zig's dependency on LLVM.
  • Comparisons to other compilers and tools, like D's compiler and TinyCC, highlighting potential use cases and missing features.
  • Interest in Aro's optimization capabilities and its support for C23 and GNU extensions.
  • Criticism of the project's documentation, with calls for more detailed explanations of its purpose and differences from Zig's official frontend.
Link Icon 15 comments
By @AndyKelley - 3 months
I don't think it's accurate to call it "Zig's". This is an independent project started by Veikka Tuominen, a Zig core team member, but it's not owned or managed by ZSF in any way. It's Veikka's project. Don't take that away from him!
By @Jarred - 3 months
One of the features missing in bun:ffi is inferring types for symbols from header files. This would let you import C libraries in JavaScript/TypeScript directly, without having to configure bindings.

We embed TinyCC for FFI, but TinyCC doesn't expose a way to read the types for exported symbols.

Currently, it looks like this:

      import { dlopen, FFIType, suffix } from "bun:ffi";

      // `suffix` is either "dylib", "so", or "dll" depending on the platform
      // you don't have to use "suffix", it's just there for convenience
      const path = `libsqlite3.${suffix}`;

      const {
        symbols: {
          sqlite3_libversion, // the function to call
        },
      } = dlopen(
        path, // a library name or file path
        {
          sqlite3_libversion: {
            // no arguments, returns a string
            args: [],
            returns: FFIType.cstring,
          },
        },
      );
      console.log(`SQLite 3 version: ${sqlite3_libversion()}`);
It would be nicer if it was something like this:

      import {sqlite3_libversion as version} from "sqlite3.h" with {lib: "sqlite3"};
      console.log(`SQLite 3 version: ${version()}`);

Would love to use Aro to do this in the future
By @WalterBright - 3 months
The dlang D compiler includes a full C compiler, so you can mix and match C and D code. You can import C code from D, and D code from C.

    dmd hello.c
    ./hello
    hello world
This helps enormously in binding to existing C libraries.
By @livrem - 3 months
Is this part of the long-term plan for zig to get rid of the dependency on clang/llvm?

https://github.com/ziglang/zig/issues/16270

By @slowmovintarget - 3 months
I'm not all that familiar with the Zig tool chain.

Am I understanding correctly that this is a regular C compiler used as a component of the Zig compiler chain allowing compilation of C files alongside Zig? Or does Zig generate C and therefore need a C compiler under the hood?

Looking at the documentation suggests it is the former, not the latter.

By @Y_Y - 3 months
It would be interesting to see how well it optimizes compared to the established players. The fact that it handles C23 and common GNU extensions is already impressive.
By @sirwhinesalot - 3 months
Very nice, honestly the tooling around Zig is even more impressive than the language itself.
By @lambdaone - 3 months
Zig is amazing. What started as a one-man project is becoming a mature software ecosystem capable of standing on its own as a peer with the major languages.
By @janice1999 - 3 months
There's doesn't appear to a whole lot of comments or documentation in the code. Is this normal for Zig projects? Does it have an equivalent of Sphinx to build docs from code?
By @fefe23 - 3 months
Wait, so you still need zig, and zig still needs LLVM. If you have LLVM, you have clang.

What is the value proposition of this compiler, then?

By @ilayn - 3 months
I hope Zig adds complex numbers before it is too late. It's a pity that they did not steal array syntax and slices from Fortran/Numpy.
By @dist1ll - 3 months
It seems like I can't include standard header files, so it can't compile a common hello world. I guess that'd be useful to mention on the README, or maybe I'm doing something wrong?

    main.c:1:10: fatal error: 'stdio.h' not found
    #include <stdio.h>

It'd be nice if header inclusion, and -l options work. This would allow benchmarking Aro against some other compilers on a wide range of C files. Usually sqlite3.c is my first go-to for stress-testing C compilers.
By @tiffanyh - 3 months
The ReadMe is quite lacking …

- why create a competing front end to Zig?

- what problems is it solving?

- what’s different than the official Zig frontend?

Etc