# add Aro as a C frontend · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/376d443ae314e6e999fb58fd6d8e8a4adc4fbdeb)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 376d443ae314e6e999fb58fd6d8e8a4adc4fbdeb

Requested commit: 376d443ae314e6e999fb58fd6d8e8a4adc4fbdeb

Commit: 376d443ae314e6e999fb58fd6d8e8a4adc4fbdeb

Tree: fdf08175822edd14d1a985691fe3bc4ed9c8b497

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
add Aro as a C frontend

Problems to solve in this branch before merging:

 * Liveness and AIR printing want a ZIR instance. This issue is
   addressed by #10784.
 * linker: updateFunc / updateDecl want a Module instance which
   currently represents only Zig code. These functions should be changed
   to accept a Compilation, not a Module. The relevant state that it
   needed to touch on Module should be moved to Compilation instead.
 * `Decl` needs to be shared by both the C frontend and the Zig
   frontend. It currently has Zig-only fields and the functions to
   create Decl objects don't really fit the API that the C frontend
   needs.
 * A lot of the incremental compilation infrastructure doesn't quite
   match up, for example Decl objects being owned by Namespaces which is
   a Zig concept. Maybe there could be 1 Namespace globally across all C
   files and 1 more Namespace per C file for functions and globals
   declared `static`.
 * There is common code to be extracted from Sema that is shared with
   Aro frontend. All the helper functions having to do with the
   air_instructions and air_extra arrays.

There are many instances of calling `@panic("TODO")` that need to be
cleaned up.

There is a lot of compiler options that Zig is not communicating to Aro,
for example we do not pass the -D switches that we pass to Clang yet.
Need to audit `addCCArgs` and do the equivalent things for setting up
the Aro Compilation.

The Aro code is copied from https://github.com/Vexu/arocc, commit
7a0e54227e1ea2b2df8aa7bd2b7075f735109317. The only patches are to delete
Codegen and replace it with our own, and to delete main.zig, and add
Type and Value to lib.zig.

I believe the current plan is for main Aro development to happen
upstream on the arocc repository and periodically sync it downstream
with the Zig repository. It's up to @Vexu whether to keep that process
or change it in the future.

```

## Parents

- [04f379dd414184a42412f4497b0573d7612d6730](https://git.cafe/gitcafe/zig/commit/04f379dd414184a42412f4497b0573d7612d6730?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/376d443ae314e6e999fb58fd6d8e8a4adc4fbdeb?format=markdown)
