jserv/amacc logo

jserv/amacc

Free

Small C Compiler generating ELF executable Arm architecture, supporting JIT execution

FreeFree tier
Type
Open Source

About jserv/amacc

AMaCC (Arguably Minimalist Arm C Compiler) is a small C compiler that generates ELF executables for the Arm architecture and supports just-in-time (JIT) execution. Built from scratch, it is designed primarily as a pedagogical tool for learning about compilers, linkers, and loaders. AMaCC compiles a subset of C sufficient to self-host on Arm/Linux systems (armv7hf). It employs a combination of recursive descent and operator precedence parsing, generates a stack-based VM intermediate representation, and outputs Arm32 instructions. The compiler supports all C89 statements (except typedef), all C89 expression operators, and data types including char, int, enum, struct, union, and multi-level pointers. It has been verified on Raspberry Pi 2/3/4 and requires the arm-linux-gnueabihf toolchain and QEMU user emulation for testing.

Key Features

Generates ELF executables for Arm (armv7hf) Linux
Just-in-time (JIT) compilation for Arm backend
Self-hosting: can compile its own source code
Supports all C89 statements except typedef
Supports all C89 expression operators
Data types: char, int, enum, struct, union, multi-level pointers
Global and local variable initializations for supported types
Item-by-item array initialization
Variables can be declared anywhere within functions
Stack-based VM intermediate representation (IR)

Pros & Cons

Pros
  • Excellent pedagogical tool with clear codebase
  • Self-hosting capability demonstrates compiler completeness
  • Supports both ELF generation and JIT execution
  • Runs on low-cost Arm hardware like Raspberry Pi
  • Active development with 290 commits and community contributions
  • Documents prerequisites and testing procedures
Cons
  • Only targets 32-bit Arm (armv7hf) Linux systems
  • Does not support all C89 features (e.g., typedef, struct/union assignments)
  • Not suitable for production use; designed for learning
  • Requires Arm toolchain and QEMU for testing on non-Arm systems
  • Limited documentation beyond the README
  • No support for floating-point or aggregate array initialization

Best For

Learning how compilers, linkers, and loaders workTeaching tool for compiler design coursesCompiling C code on Arm-based devices (Raspberry Pi)Research on minimal C compilers and self-hostingEmbedded development where a lightweight C compiler is needed

FAQ

What is AMaCC?
AMaCC (Arguably Minimalist Arm C Compiler) is a small C compiler that generates ELF executables for Arm architecture and supports JIT execution. It is designed as a pedagogical tool for learning compilers, linkers, and loaders.
What architectures does AMaCC support?
AMaCC targets 32-bit Arm architecture (armv7hf with Linux ABI) and has been verified on Raspberry Pi 2/3/4.
Can AMaCC compile itself?
Yes, AMaCC is designed to compile a subset of C necessary to self-host, meaning it can compile its own source code.
What C standard does AMaCC support?
AMaCC supports all C89 statements except typedef, all C89 expression operators, and data types including char, int, enum, struct, union, and multi-level pointers. Some features like struct/union assignments and aggregate array initialization are not supported.
What are the prerequisites for using AMaCC?
You need an Arm/Linux build environment. It requires the arm-linux-gnueabihf GNU toolchain and QEMU for Arm user emulation (sudo apt-get install qemu-user).
How do I test AMaCC?
Run 'make check' in the source directory. It will perform C to IR translation, JIT compilation, and execution tests.