Skip to content

Native Executables

Derek Snider edited this page Jul 23, 2026 · 2 revisions

Native Executables

madc can generate standalone native Linux ELF executables from your programs.

Basic usage

madc -o program program.mad
./program

The output is a real native binary — no runtime dependency on madc.

How it works

When you pass -o, madc compiles your program to native machine code (just like JIT mode) but writes the result directly as an ELF executable instead of running it in-process — no external assembler or linker involved. The same MIR backend generates the code for both modes; native artifacts are position-independent and support -g DWARF debug info for gdb.

Multi-file projects

madc -o myapp myapp.mad

All #included files are compiled together into a single binary.

EXE parity

The native executable lane is kept in sync with JIT mode. Both modes pass the same integration test suite (287/287 as of the latest build). When a test passes in JIT, it should also pass as a native executable.

libmadc dependency

Native executables link against libmadc.so for runtime support (string operations, namespace functions, etc.). To run the executable:

sudo make -C src install-libmadc    # install libmadc.so to /usr/local/lib
LD_LIBRARY_PATH=/usr/local/lib ./program

What's next?

Clone this wiki locally