rg-cc
"I can C for miles and miles"
When we started writing games for the Falcon, we did everything entirely in assembly language. This inevitably led to many long hours in Mon-ST sweating over crashes and memory scribblers. After a long hard year of writing Double Bobble 2000, we decided there had to be a better way; and there was. We switched to C for writing high-level logic and program flow, and assembly for graphics routines and performance-critical code.
We started this work with Hisoft's Lattice C, but quickly switched to Pure C due to its much higher speed (both in compile times and runtime performance).
In later years, as we moved to cross-platform development, we found VBCC was really tailored for our needs.
But revisiting our workflows after many years of absence, it became obvious that things would have to change.
VBCC was not being updated very regularly and had some nasty compiler bugs that were annoying to work around. Pure C still produces excellent 68k code, but is awkward to use in a cross-platform toolchain, and lacks many modern C features and optimisations. Modern compilers like GCC are large and bloated, and although they have amazing high-level optimisations, they don't always do a great job at the final step of writing 68k code.
Wouldn't it be nice to have something better? A modern compiler, with modern features and modern optimisations, that also deeply understands and optimises for the 68k architecture.
That is the design ethos behind rg-cc: a brand new C99 compiler, built from the ground up around the 68k architecture.
We kept it simple — a single executable that compiles, assembles, links, and even includes its own build system, with no dependencies or external tooling needed.
Contents
- Quick start
- Headers & libraries
- Target CPU, FPU & ABI
- Compiling
- Project builds
- Preprocessor
- Optimisation
- Output formats
- Warnings
- GCC & VBCC flags
- IR & token dumps
- Compiler Architecture Reference
- Command-line reference
- Greetings
Command-Line Interface
Install
rg-cc is distributed as a single standalone executable (static musl on Linux with zero host library dependencies; standard OS system libraries only on macOS and Windows). Prebuilt packages for macOS, Linux, and Windows are available from rg.atari.org.
Simply drop the executable somewhere on your PATH.
Quick start
# Compile single C file to relocatable object (default: fastcall ABI, 68000 CPU)
rg-cc -c game.c -o game.o
# Compile with optimisation level 2 and size-favouring mode
rg-cc -c -O2 --opt-size game.c -o game.o
# Multi-file parallel compilation (Rayon multi-threaded across CPU cores)
rg-cc -c -I include/ -D NDEBUG player.c enemy.c audio.c video.c
# Direct single-step link into an Atari executable (one of the objects defines `main`)
rg-cc game.o player.o enemy.o audio.o video.o -o game.tos
# Build a multi-target project from ./build.rbs or a classic Pure C .PRJ file
rg-cc build
rg-cc MYGAME.PRJ
# Preprocess only (GCC -E) or emit Makefile header dependency files
rg-cc -E main.c -o main.i
rg-cc -c main.c --emit-depfile
# Inspect SSA three-address intermediate representation (IR)
rg-cc --ir --opt 2 math.c
Compile and run
The direct-to-executable path links the bundled startup and the compiler-support runtime for you, so a freestanding program goes from source to a runnable Atari executable in one step:
printf 'int main(void) { return 0; }\n' > hello.c
rg-cc hello.c -o hello.tos
hello.tos boots on a real ST (or under an emulator) and terminates with Pterm(0) using the value
main returned. Standard C, math, GEM, Line-A, Pure C <ext.h>, and POSIX calls are all
bundled and linked automatically; see
the library contract.
Headers & libraries
rg-cc compiles in freestanding mode by default and hosted mode when you pass --hosted.
This decides which headers are built in and what you need to link yourself:
- Freestanding (default,
__STDC_HOSTED__=0). Includes the core freestanding C headers, Atari TOS/GEM/Line-A headers, and Pure C / VBCC compatibility headers. - Hosted (
--hosted,__STDC_HOSTED__=1). Defines__STDC_HOSTED__=1and adds standard C library declarations (stdio,stdlib,string, etc.) plus POSIX file/process headers.
| Mode | Built-in Header Families |
|---|---|
| Freestanding (default) | Core C (<stdint.h>, <stddef.h>, <stdbool.h>, <stdarg.h>, <limits.h>, <float.h>, <inttypes.h>, <complex.h>, <time.h>, <wchar.h>, <iso646.h>, <stdalign.h>, <stdnoreturn.h>), Atari OS/GUI (<tos.h>, <osbind.h>, <gemdos.h>, <bios.h>, <xbios.h>, <linea.h>, <gem.h>, <aes.h>, <vdi.h>, <ext.h>), Pure C / VBCC compat (<compiler.h>, <math_881.h>, <math_040.h>, <math_060.h>), plus <fenv.h>, <locale.h>, <math.h>, <signal.h>, <tgmath.h>, <wctype.h>, <strings.h>, <sys/types.h>, <sys/stat.h> |
Hosted (--hosted) | Everything above plus <assert.h>, <ctype.h>, <errno.h>, <fcntl.h>, <setjmp.h>, <stdio.h>, <stdlib.h>, <string.h>, <unistd.h> |
All core Atari and C libraries are built in. When linking without -nostdlib or -nodefaultlibs, rg-cc compiles and links its own in-memory runtime archives matching your active --abi, --mshort, CPU, and FPU settings:
| Archive | Contents |
|---|---|
crt0.o | TOS startup (_start, __BasPag), Mshrink, stack setup, Pterm exit |
libc.a | C99 stdio, stdlib (malloc/free), string, ctype, time, errno, assert, setjmp/longjmp |
libm.a | Pure C99 floating-point maths (sin, cos, sqrt, pow, exp, log, atan2, rounding) |
libgem.a | AES (trap #2, 0xC8) and VDI (trap #2, 0x73) bindings (mt_*, v_*, aes_global, gl_apid) |
liblinea.a | Line-A (0xA000–0xA00A) pixel, line, and rectangle helpers (__aline, linea_init) |
libext.a | Pure C / Turbo C <ext.h> helpers (findfirst/findnext, fnsplit/fnmerge, getdate, delay) |
libposix.a | POSIX file and directory wrappers (open, read, write, close, lseek, stat, mkdir, sbrk) |
libintrt.a, libsoftfloat.a | 64-bit integer and IEEE soft-float compiler helpers |
Bring your own library. Headers found on -I <dir> take precedence over built-ins, and any -l archive or .a/.o file you pass is linked before the built-in libraries so external libraries (such as libcmini, MiNTLib, or gemlib) take priority. Pass -nodefaultlibs or -nostdlib to disable the built-in libraries, or --emit-runtime [<DIR>] to inspect or link against the archives on disk. For example, linking against an external cdecl library:
rg-cc --hosted --abi cdecl -I /path/to/libcmini/include main.c -L /path/to/libcmini/lib -lc -o main.tos
Target CPU, FPU & ABI
rg-cc generates code for the Motorola 680x0 family and supports both Atari ST system conventions and custom register layouts.
Target CPUs (--mcpu <CPU>)
| Target | Capabilities / Codegen Model |
|---|---|
68000 (default) | 16/32-bit CISC baseline; 16-bit ALU multiplications (muls.w/mulu.w), 8-bit brief indexed addressing (d8(An,Dn)). |
68020 | Full 32-bit ALU (muls.l, divs.l), hardware scaled indexing (d(An,Dn*scale)), bitfield instructions (bfextu, bfins). |
68030 | On-chip data/instruction caches, MMU support, 68020 instruction superset. |
68040 | Integrated FPU pipeline, copyback cache, dual execution units. |
68060 | Dual-issue superscalar p-pipe/s-pipe branch folding instruction scheduler. |
Floating-Point Models (--hard-float / --soft-float)
By default, floating-point operations are rejected at compile time so software-float helpers are never linked accidentally. Pass --soft-float or --hard-float when your code uses float or double:
--soft-float: Emits software floating-point runtime helper calls matching the GCC/libgcc calling standard. Zero FPU instructions are emitted.--hard-float(Available on 68881/68882/68040/68060): Emits native hardware FPU coprocessor instructions (fadd,fmul,fmove, etc.) with dedicatedFP0–FP7register allocation.
Calling Conventions (--abi <ABI>)
fastcall(Default): VBCC-compatible register fastcall ABI. Integer arguments are passed inD0andD1; pointer arguments are passed inA0andA1. Overflow parameters (including the 3rd+ integer or pointer argument) are passed on the stack. Returns useD0(with anA0mirror only for stdargs/variadic calls). Data registersD2–D7and address registersA2–A6are callee-saved (matching VBCC's defaultdscratch=1). Cuts stack traffic and frame setup overhead while staying binary-compatible with standard Atari assembly stubs and libraries.cdecl/stdargs: Standard stack-based calling convention. All parameters pushed right-to-left onto the stack ((SP)). Fully compatible with standard hosted C libraries and varargs calls.purec: Pure C / Turbo C register-passing convention (D0–D2,A0–A1in order of scalar/pointer parameter types), for linking against classic Pure C objects and.LIBarchives.
Compiling
rg-cc works both as a single-file compiler and as a fast parallel driver:
# Single-file compile
rg-cc -c main.c -o main.o
# Multi-file batch compilation
rg-cc -c src/main.c src/render.c src/audio.c src/physics.c
When multiple source files are passed with -c, rg-cc uses Rayon threads to parse, optimise, and assemble all translation units concurrently across all available CPU cores.
Response Files (@<file>)
To pass hundreds of source files, include paths, or macro definitions without running into OS command-line length limits (or inside complex build tools like Make, Ninja, and FASTBuild), rg-cc supports response files:
# Read arguments from a response file
rg-cc @build_args.rsp
# Mix direct flags with response files
rg-cc -c -O2 @sources.rsp -o combined.o
- Formatting: Arguments in a response file may be separated by whitespace, tabs, or newlines.
- Quoting & Escaping: Supports shell-style single quotes (
'...'), double quotes ("..."), and backslash escapes (\). - Nesting: Response files can reference other response files (e.g.
@includes.rspinside@build.rsp) with recursive expansion supported up to 10 levels deep.
Link-Time Optimisation (--lto)
Pass --lto to enable cross-translation-unit whole-program optimisation:
rg-cc -c --lto file1.c file2.c file3.c -o combined.o
Under --lto, all translation units are merged into one AST/IR module before optimisation for cross-file inlining, unused static dead-code pruning, interprocedural register allocation (IPRA), and global constant propagation across module boundaries.
Preprocessor
rg-cc contains a standards-compliant, zero-copy C99 preprocessor supporting macro expansion, token pasting (##), stringification (#), variadic macros (__VA_ARGS__), and header search paths.
Include paths & macros
| Flag | Meaning | Example |
|---|---|---|
-I <DIR> | Add directory to include search path | -I include/ |
-D <NAME[=VAL]> | Define preprocessor macro | -D NDEBUG or -D SCREEN_WIDTH=320 |
-U, --undefine <NAME> | Undefine preprocessor macro | -U DEBUG |
--include <FILE> | Force-include header before compiling | --include config.h |
--iquote <DIR> | Quote-include path (#include "...") | --iquote src/ |
--isystem <DIR> | System-include path (#include <...>) | --isystem /usr/include |
--idirafter <DIR> | Search directory after all standard -I | --idirafter compat/ |
Preprocess Only (-E)
rg-cc -E input.c -o preprocessed.i
Writes the preprocessed C source containing #line / # N "filename" linemarkers to stdout or the specified output file.
Makefile Dependency Generation (--emit-depfile)
Ideal for build orchestration systems (Make, Ninja, FASTBuild):
rg-cc -c main.c --emit-depfile
# Generates main.o and main.d containing: main.o: main.c header1.h header2.h
--depfile <FILE>: Explicit output path for the.dfile.--dep-target <TARGET>: Override rule target name (-MT/-MQ).--dep-phony: Emit phony targets for each header (-MP) to avoid errors on renamed/deleted headers.
Optimisation
rg-cc features a multi-stage SSA optimising pipeline:
rg-cc -c --opt 0 foo.c # Debug / Fast (peephole only)
rg-cc -c --opt 1 foo.c # Basic SSA optimisations (GVN, SCCP, DCE, inlining)
rg-cc -c --opt 2 foo.c # Full release optimisation (LICM, LSR, scheduling, unrolling)
rg-cc -c --opt 3 foo.c # Aggressive optimisation (maximum inlining & loop unrolling)
Optimisation Tiers
| Level | Passes Executed | Target Use Case |
|---|---|---|
-O0 / --opt 0 | Constant folding, local dead code elimination, machine peephole. | Fast compilation, clean debugging with exact source line mappings. |
-O1 / --opt 1 | Global Value Numbering (GVN), Sparse Conditional Constant Propagation (SCCP), small leaf inlining, algebraic simplification. | Balanced compile time and execution performance. |
-O2 / --opt 2 | Default Release. Loop-Invariant Code Motion (LICM), Loop Strength Reduction (LSR), instruction scheduling, memory-direct RMW. | Recommended default for shipping games and applications. |
-O3 / --opt 3 | Aggressive caller inlining (up to 128 IR insns), constant-trip loop unrolling, speculative branch elimination. | Critical inner loops and compute-heavy mathematical code. |
Size-Favouring Mode (--opt-size)
When compiling code for memory-constrained 512 KB–1 MB Atari STs, pass --opt-size:
rg-cc -c -O2 --opt-size cold_ui.c -o cold_ui.o
--opt-size maintains all correctness and redundancy elimination passes (GVN, SCCP, DCE) while turning off byte-expanding cycle-favouring transformations (such as aggressive inlining and large multiply-to-shift-add expansions).
Profile-Guided Function Size Mode (--opt-size-list <FILE>)
Compile hot functions for maximum cycle speed while keeping cold functions size-optimised in the same file:
rg-cc -c -O2 --opt-size-list cold_functions.txt game.c
Fine-Grained Pass Flags (--flags <SPEC>)
Override specific internal optimiser passes on the command line:
rg-cc -c -O2 --flags ptr_loop_dbra=on,unroll=off game.c
Output formats
Output depends on whether you compile intermediate objects (-c) or link a final executable:
Executables (.PRG / .TOS)
When invoked without -c, rg-cc links the compiled code (or supplied object files) directly into an Atari GEMDOS executable:
# Single-step compilation and linking to an Atari PRG executable
rg-cc player.c enemy.c audio.c -o game.prg
# Linking previously compiled object files into a TOS binary
rg-cc player.o enemy.o audio.o -o game.tos
Because rg-cc embeds its own linker directly:
- Output binaries contain the standard GEMDOS
$601Amagic header, PRG execution flags, and contiguousTEXT,DATA, andBSSsegment sections. - Appends the standard GEMDOS byte-differential relocation table, making executables fully relocatable at runtime by the Atari TOS operating system.
- Produces clean embedded DRI or GST symbol tables for runtime debuggers (MonST, Godbox, Hatari).
- Ready to copy directly to a floppy/hard disk image and execute on Atari ST, STe, TT030, or Falcon030 hardware.
Object files (-c)
When compiling with -c, rg-cc outputs relocatable object files (.o):
rg-cc -c game.c -o game.o
Why does rg-cc use ELF32 for intermediate objects instead of legacy Atari DRI/GST formats?
- No Symbol Truncation: Legacy Atari DRI object files truncate symbol names to 8 characters (and GST caps at 22 bytes). Modern C code with static namespaces, long identifiers, and mangled names suffers fatal collisions under DRI. ELF supports unlimited identifier lengths.
- Rich Relocations & Sections: ELF32 supports full 68k relocation types (
R_68K_32,R_68K_PC32,R_68K_16,R_68K_PC16), arbitrary section names, and weak linkage. - DWARF 4 Debug Symbols: Emits standard
.debug_lineand.debug_infosections for rich source-level debugging in Hatari and Godbox. - Toolchain Interoperability: Compatible with
vasm(-Felf),vlink(-b elf32m68k),rg-asm, andrg-link.
Direct ELF vs. assembly text
rg-cc includes a direct machine-instruction encoder alongside its text-assembly path:
--direct-elf(Default): Direct binary encoding to ELF32 relocatable objects. Encodes 68k opcodes directly to bytes in memory, skipping thousands of string formatting and parsing steps. 500× faster instruction emission and ~2× end-to-end compiler speedup.--text-asm: Diagnostic fallback mode that generates traditional Motorola-syntax assembly text (.s) and invokesrg-asm-core.
Warnings
rg-cc provides rich compiler diagnostics with source snippets, column carets, and severity levels.
rg-cc -c --wall --wextra game.c # Enable common and extra warning sets
rg-cc -c --werror game.c # Treat all warnings as fatal errors
rg-cc -c --pedantic game.c # Strict C99 conformance validation
rg-cc -c -g game.c # Emit DWARF 4 debug symbols (.debug_line, .debug_info)
Warning Control Flags
| Flag / Option | Effect | Example |
|---|---|---|
-w, --quiet | Silence all compiler warning messages | rg-cc -c -w game.c |
-Wall, --wall | Enable standard diagnostic warnings | rg-cc -c -Wall game.c |
-Wextra, --wextra | Enable extra detailed compiler diagnostics | rg-cc -c -Wextra game.c |
-Werror, --werror | Promote all enabled warnings to fatal compilation errors | rg-cc -c -Werror game.c |
-Wpedantic, --pedantic | Enforce strict ISO C99 standards conformance checks | rg-cc -c -pedantic game.c |
-Werror=<CAT>, --werror-cat <CAT> | Promote a specific warning category <CAT> to a fatal error | rg-cc -c -Werror=shadow game.c |
-Wno-<CAT>, --wno-cat <CAT> | Disable and silence a specific warning category <CAT> | rg-cc -c -Wno-unused game.c |
-W<CAT>, --w-cat <CAT> | Explicitly enable a specific warning category <CAT> | rg-cc -c -Wshadow game.c |
-g, --debug | Emit DWARF 4 debug info sections (.debug_line, .debug_info) | rg-cc -c -g game.c |
--hosted | Compile in hosted mode (__STDC_HOSTED__=1) with built-in hosted headers and bundled C/GEM/POSIX libraries — see the library contract | rg-cc -c --hosted game.c |
--std <STD> | Set the C standard dialect (c89, c99, gnu99, c11); see C dialects | rg-cc -c --std c99 game.c |
C dialects
--std <STD> selects the C standard the front end applies. It is read: it sets
__STDC_VERSION__, and it decides whether an implicit function declaration is a constraint
violation.
--std | __STDC_VERSION__ | Implicit function declaration |
|---|---|---|
| (omitted) | 199901L | accepted (the legacy permissive default) |
c89 | undefined — the macro is C99's (§6.10.8) | accepted (the C89 rule, §6.5.2.2) |
c99 | 199901L | refused (§6.5.2.2p1 removed the implicit declaration) |
gnu99 | 199901L | accepted (the C99 macro set with the GNU/legacy permissiveness) |
c11 | 201112L | refused |
An undeclared identifier used as a value (int y = undefined_thing;) is refused under every
dialect: neither C89's implicit declaration (which covers a call) nor its implicit int (which
covers a declaration) makes a bare object use legal. An unknown --std value is refused at
argument parsing, and the accepted set is exactly what --help lists.
Warning Categories
Specific warning classes can be enabled (-W<cat>), disabled (-Wno-<cat>), or promoted to fatal errors (-Werror=<cat>):
Category (<CAT>) | Trigger Condition / Description | Enabled In |
|---|---|---|
shadow | A local variable declaration shadows a variable, parameter, or global from an outer scope. | -Wextra |
unused | An unused variable, function parameter, or static function definition is detected. | -Wall |
unused-variable | A local variable is declared or assigned but never read. | -Wall |
unused-parameter | A function parameter is declared in a defined function body but never referenced. | -Wextra |
unused-function | A static function is declared/defined in the translation unit but never called. | -Wall |
implicit | Implicit type conversions that may lose precision or sign, or implicit function declarations. | -Wall |
pointer-sign | Pointer assignment or argument passing between signed and unsigned pointer targets. | -Wall |
pedantic | Use of non-standard C GNU extensions, anonymous struct/unions outside C11, or VLA edge cases. | -Wpedantic |
cpp | Preprocessor #warning directives, macro redefinition mismatches, or #if evaluation anomalies. | Default |
lto | Cross-translation unit symbol mismatches, type conflicts, or duplicate static declarations under --lto. | Default |
attributes | Unknown __attribute__((...)) ignored during parsing. | Default |
incompatible-pointer-types | Pointer type mismatches in assignments, initialisers, and calls. | Default |
address-of-packed-member | Taking the address of a packed struct member (unaligned pointer risk). | Default |
Diagnostic Pragmas
rg-cc supports standard GCC diagnostic pragmas to selectively suppress or elevate warnings inside source code:
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
#pragma GCC diagnostic ignored "-Wunused-parameter"
void handler(int unused_param) {
int x = 10; // shadowing outer declaration without warning
}
#pragma GCC diagnostic pop
GCC & VBCC flags
rg-cc normalises common GCC and VBCC command-line flags out of the box so existing Makefiles, FASTBuild configs, and Atari scripts work unchanged:
| Short / Common Flag | Normalised rg-cc Target | Description |
|---|---|---|
-O0, -O1, -O2, -O3 | --opt <0..3> | Standard optimisation levels |
-Os, -Osize, -O2-size | --opt-size | Size-favouring optimisation |
-m68000 .. -m68060 | --mcpu 68000 .. 68060 | CPU target architecture (-m68010 maps to --mcpu 68000) |
-mfastcall, -mregargs | --abi fastcall | Fastcall register calling convention |
-mstdargs, -mcdecl | --abi cdecl | Stack-based calling convention |
-mhard-float, -m68881, -mfpu | --hard-float | Hardware floating-point coprocessor |
-msoft-float, -mno-fpu | --soft-float | Software floating-point helpers |
-flto, -fwhole-program | --lto | Cross-TU whole-program optimisation |
-w | --quiet | Suppress all warnings and banners |
-Wall, -Wextra, -Werror | --wall, --wextra, --werror | Standard diagnostic flags |
-Wpedantic, -pedantic | --pedantic | Strict standard compliance |
-g, -g1..-g3, -ggdb | -g | DWARF 4 debug symbols |
-mhosted, -fhosted | --hosted | Hosted environment (__STDC_HOSTED__=1) with bundled standard libraries |
-ffreestanding, -fno-hosted | (default) | Freestanding environment (__STDC_HOSTED__=0) |
IR & token dumps
For engine developers and performance hackers, rg-cc provides deep visibility into its intermediate stages:
Dump Preprocessor Tokens (--dump-tokens)
rg-cc --dump-tokens main.c
Prints the lexical token stream with line/column coordinates.
Dump Preprocessed C (--dump-pp)
rg-cc --dump-pp main.c
Outputs preprocessed C source after expanding macros and #include directives.
Dump SSA Three-Address IR (--ir)
rg-cc --ir --opt 2 main.c
Prints the SSA intermediate representation showing basic blocks, phi nodes, value types, and dominator trees.
Dump Per-Pass Compiler Artefacts (--dump-dir <DIR>)
rg-cc -c main.c --opt 2 --dump-dir /tmp/compiler-dumps/
Writes complete per-pass intermediate files:
A01-ast.txt: Abstract Syntax Tree representation.A02-ir-initial.ir: Unoptimised SSA IR lowered from AST.A03-ir-gvn.ir: IR after Global Value Numbering & SCCP.A04-ir-licm.ir: IR after Loop-Invariant Code Motion.A05-O2-ir-optimized.ir: Final optimised IR fed to instruction selection.
Project builds
rg-cc includes an integrated project build engine (the Reservoir Build System, RBS), so multi-file C and 680x0 assembly libraries and executables can be built by a single rg-cc invocation without external Makefiles, shell scripts, or separate assembler/archiver/linker processes. See the RBS reference for syntax and properties.
Declarative build.rbs projects
Running rg-cc build in a directory containing build.rbs (or passing rg-cc <path/to/build.rbs>) resolves the project graph, executes pre-build file operations (file_configure, files_copy, file_write), compiles C and 680x0 assembly translation units in parallel across CPU cores, archives static libraries, links GEMDOS .TOS/.PRG or ELF executables, and stages runtime assets (files_stage).
# Build default targets in ./build.rbs (default: --platform atari --config release)
rg-cc build
# Build a specific target or configuration
rg-cc build --config debug
rg-cc build my_demo -Diterations=2000
# Inspect resolved targets or emit compile_commands.json for clangd/IDE tooling
rg-cc build --list-targets
rg-cc build --compdb
# Clean target outputs or purge .rbs-cache
rg-cc build --clean
rg-cc build --clean-cache
Intermediate objects and target manifests are stored in .rbs-cache/ (or $RG_CC_CACHE_DIR) so unchanged translation units and up-to-date targets skip recompilation and relinking. Guarded headers (#ifndef GUARD_H / #define GUARD_H / #endif and #pragma once) are tokenised once and shared across translation units within the build process.
A build.rbs file uses a declarative, block-scoped DSL supporting:
- Bare or quoted block identifiers: Project, config, platform, and target blocks accept either bare identifiers (
library cmini { ... }) or quoted string literals. - First-class toolchain properties: Configure target CPU, FPU, ABI, C dialect, assembler dialect, optimisation, LTO, output format, stack size, and symbol stripping as structured properties alongside raw compiler/assembler/linker flags. See the RBS reference for the full property table.
- Transitive library exports & pre-build file ops: Libraries can propagate
export_includesandexport_definesacross dependency chains, and pre-build file operations run in topological order before compiling or generatingcompile_commands.json(--compdb). - Globs with brace expansion & conditional blocks: Supports brace-expanded
glob(...)patterns,whencondition blocks, and explicit list replacement (=), append (+=), or removal (!item) semantics.
Native Pure C .PRJ support
rg-cc also accepts classic Atari Pure C, Turbo C, and AHCC .PRJ project files directly:
rg-cc DEMO.PRJ
rg-cc build DESKTOP.PRJ --config debug
The .PRJ loader translates .C[...], .S[...], and .L[...] option directives, parenthesised #include header dependency lists, per-file flag overrides, and nested .prj sub-targets into the in-process build graph, mapping legacy Pure C startup objects (PCSTART.O) and standard library references to rg-cc's built-in runtime when not present on disk.
Porting external projects (libcmini, mintlib, Makefiles)
rg-cc bundles its own libc.a, libm.a, libgem.a, liblinea.a, libext.a, and libposix.a, so most --hosted Makefiles compile and link out of the box. When an external project explicitly supplies its own libc archive and matching headers, pass them via -I, -L, and -l (user archives take precedence over built-ins):
# Compile and link against an external cdecl libcmini archive
rg-cc -O2 --abi cdecl -I/path/to/libcmini/include -L/path/to/libcmini/lib main.c -lcmini -o app.tos
- Calling convention:
rg-ccdefaults to--abi fastcall(register arguments). When linking against static archives built withm68k-atari-mint-gccorlibcmini(stdargs/cdecl), pass--abi cdecl(-mcdecl). - Drop-in
CC=rg-cc: Standard GCC compilation, assembly (-S), dependency generation (-MD/-MMD/-MM), and-Wp,preprocessor pass-through flags work out of the box; see GCC / VBCC Driver Compatibility Flags below for the full list. Use--strip-debugor-Wl,-Sto strip debug symbols when linking.
Reference
| Flag | Meaning / Description |
|---|---|
@<FILE> | Read command-line arguments and file lists from a response file |
-c | Compile source files (.c or .s/.S) to object files (.o) without linking |
-S, --emit-asm | Compile C source files to 680x0 assembly text (.s) without assembling or linking |
--strip-debug | Strip debug symbols from linked executable output (also -Wl,-S) |
-o <FILE> | Specify output filename |
-I <DIR> | Add directory to #include search list |
-D <NAME[=VAL]> | Define preprocessor macro |
-U, --undefine <NAME> | Undefine preprocessor macro |
--include <FILE> | Force-include header file before processing source |
--iquote <DIR> | Add directory to #include "..." quote search list |
--isystem <DIR> | Add directory to #include <...> system search list |
--idirafter <DIR> | Add directory to search list after all -I directories |
-E | Preprocess only; output preprocessed C with linemarkers |
-g, --debug | Emit DWARF 4 debug information sections |
--mcpu <CPU> | Target CPU model (68000, 68020, 68030, 68040, 68060) |
--hard-float | Generate native 68881/68882/68040 hardware FPU instructions |
--soft-float | Generate software floating-point runtime helper calls (required for float/double without FPU) |
--abi <ABI> | Calling convention (fastcall [default], cdecl / stdargs, or purec) |
--vbcc-fastcall-alias | Enable VBCC fastcall register calling convention compatibility |
--small-data / --no-small-data | Enable or disable small data base addressing (-msmall-data / Lattice -b0) |
--opt <0..3> | Optimisation level: 0 (debug/peephole), 1 (SSA basic), 2 (release), 3 (aggressive) |
--opt-size | Size-favouring optimisation mode (disables byte-expanding transforms) |
--opt-size-list <FILE> | Per-function profile-guided size optimisation list |
--flags <SPEC> | Fine-grained optimiser pass enable/disable overrides |
--lto | Whole-program Link-Time Optimisation across multiple input files |
--std <STANDARD> | Set the C standard dialect (c89, c99, gnu99, c11); see C dialects |
--dialect <DIALECT> | Compiler compatibility dialect (gcc, purec, vbcc, ahcc, lattice, sozobon, alcyon, none) |
--compat <COMPILER> | Disambiguate colliding rival short flags (vbcc, purec, ahcc, lattice) |
-funsigned-char | Treat plain char as unsigned char and define __CHAR_UNSIGNED__=1 |
-fshort-enums | Size each enum to the smallest integer type holding all its enumerators |
-fpack-struct[=N] | Pack all struct/union members to N-byte alignment (default 1 if bare) |
-mshort, --mshort | Use 16-bit int (__INT_MAX__=32767, __SIZEOF_INT__=2, __MSHORT__=1) |
-dM, --dump-defines | Dump all active preprocessor macro definitions to stdout and exit |
-fsyntax-only, --syntax-only | Validate syntax and semantic types without codegen or linking |
--stack-size <BYTES> | Set executable stack allocation size in bytes |
--direct-elf | Direct binary ELF32 emission (default, fast text-free path) |
--text-asm | Generate intermediate assembly text (.s) and invoke assembler |
--emit-headers [<DIR>] | Extract built-in C and Atari OS headers to specified directory |
--emit-runtime [<DIR>] | Extract built-in runtime archives and startup objects to specified directory |
--emit-depfile | Emit Makefile-style header dependency files (.d) |
--dep-only | Emit Makefile-style depfile and exit without compiling (GCC -MM) |
--dep-no-system | Exclude --isystem headers from generated depfiles (GCC -MM / -MMD) |
--depfile <FILE> | Explicit target output path for dependency file |
--dep-target <TARGET> | Override rule target name in generated dependency file |
--dep-phony | Generate phony targets for each dependency (-MP) |
-L <DIR>, -l <LIB> | Library search paths and libraries to link with |
-e, --entry <SYM> | Override linker entry point symbol |
-s, --strip-all | Strip all symbols from linked output |
-M, --print-map | Emit link map (-M / --print-map / --emit-map) |
--sym <FORMAT> | Symbol table format (dri, gst, extern, none) |
--tos-flags <FLAGS> | GEMDOS process header flags |
-T, --script <SCRIPT> | Custom linker script |
--relax-pcrel / --no-relax-pcrel | Enable or disable PC-relative size-changing relaxation (Lattice -r0) |
--nostdlib, --nostartfiles, --nodefaultlibs | Omit standard libraries, crt0.o, or built-in runtime libraries |
--Bstatic, --no-rgcc-tag, --Wl <ARG> | Static linking mode, omit RGCC provenance stamp, or pass raw linker flag |
--ir | Output SSA Three-Address Intermediate Representation to stdout |
--dump-pp | Output preprocessed C source text to stdout |
--dump-tokens | Output lexer token stream to stdout |
--dump-dir <DIR> | Save per-phase AST and IR dumps into specified directory |
--emit-signatures | Print function type signatures as TSV table and exit |
build [FILE] | Build an RBS (.rbs) or Pure C (.prj) project file |
--platform <PLAT> | Target platform override for RBS build (atari, linux, macos, windows, sdl, host) |
--config <CFG> | Build configuration override for RBS build (debug, release, shipping, lowmem) |
--compdb [FILE] | Emit Clang compile_commands.json compilation database |
--cc, --ar, --ld <TOOL> | External C compiler, archiver, and linker overrides for non-68k RBS platforms |
--clean | Remove target outputs and build artefacts |
--clean-cache | Clear the .rbs-cache directory |
--list-targets | List all resolved targets in build graph and exit |
--wall | Enable standard compiler warning diagnostics |
--wextra | Enable extra compiler warning diagnostics |
--werror | Treat all warnings as fatal errors |
--werror-cat <CAT> | Promote a specific warning category to fatal error (-Werror=<CAT>) |
--wno-cat <CAT> | Disable a specific warning category (-Wno-<CAT>) |
--w-cat <CAT> | Enable a specific warning category (-W<CAT>) |
--pedantic | Enforce strict ISO C99 standards conformance |
--hosted | Compile in hosted environment mode (__STDC_HOSTED__=1) with built-in headers and bundled standard libraries |
-v, --verbose | Verbose compiler execution and phase timing output |
-q, --quiet | Suppress compiler banners and status progress output |
--color <WHEN> | Colourised diagnostic output (auto, always, never; honours NO_COLOR) |
--banner <STYLE> | Startup masthead (none, line, logo) |
--ascii | Use ASCII fallback characters instead of Unicode box-drawing glyphs |
--version | Print compiler version |
--help | Display command-line options and usage summary (unstable introspection flags are grouped separately) |
GCC / VBCC Driver Compatibility Flags
rg-cc accepts standard GCC and VBCC short flags for drop-in Makefile, CMake, and Meson integration:
| Flag(s) | Behaviour |
|---|---|
-O, -O0..-O3, -Os, -Og, -Ofast, -Oz | Optimisation levels (-Og maps to --opt=0, -Ofast to --opt=3, -Oz to --opt-size) |
- | Read C source from stdin (requires -E or -x c; default -c output is stdin.o) |
-x <lang> | Override input language (c, assembler, assembler-with-cpp, or none to restore extension detection) |
-M, -MM, -MD, -MMD, -MF, -MT, -MQ | Makefile dependency generation (-MM/-MMD exclude -isystem headers; -MT<t>/-MQ<t> work attached or spaced) |
-I, -iquote, -isystem, -idirafter, -include, -nostdinc | Header search paths, forced includes, and standard include suppression |
-D, -U, -E, -dM | Preprocessor macros and standalone preprocessing modes |
-m68000..-m68060, -msoft-float, -m68881, -m68882, -ansi | Target CPU, soft/hard-float, and -std=c89 alias |
-fno-common, -fcommon | Common-symbol placement for uninitialised globals |
-L, -l, -Wl,..., -Wp,..., -Wa,-m680*, -nostdlib, -nostartfiles, -nodefaultlibs, -s, -S, -g | Linker search paths, libraries, pass-through flags, freestanding control, strip, .s assembly emission (-S), and debug info |
-dumpversion, -dumpmachine, -v | Print compiler version, m68k-atari-tos target triple, or verbose driver banner (when no inputs are given) |
-pipe, -fomit-frame-pointer, -fstrict-aliasing, -ffreestanding, -fsigned-char, -fno-builtin, -fPIC, -fpic, -fno-exceptions, -fno-rtti, -march=*, -mtune=* | Accepted as compatibility no-ops (plain char is signed; int is 32-bit ILP32) |
Environment Variables
| Variable | Effect |
|---|---|
NO_COLOR | Disable ANSI colour output on stderr when set (standard no-color.org convention) |
RG_CC_CACHE_DIR | Override the default .rbs-cache directory used by RBS builds |
RG_CC_OPT_FLAGS | Comma-separated optimiser pass overrides (equivalent to --flags=..., applied when --flags is omitted) |
RG_CC_TEXT_ASM | Force text assembly emission when set to 1, true, or on (equivalent to --text-asm) |
RG_CC_VERIFY_EACH | Run IR verification after every optimisation pass when set to 1, true, or on |
RG_CC_PASS_REMARKS | Emit optimisation pass remarks when set to 1, true, or on |
Exit Status Codes
| Code | Meaning |
|---|---|
0 | Compilation / linking completed successfully |
1 | Compilation, syntax, type, or semantic analysis error |
2 | Command-line argument usage or configuration error |
Greetings
Aggression · Avena · Cerebral Vortex · Cream · Defence Force · Dekadence · DHS
Dune · Effect · Ephidrena · Evolution · Extream · HMD · Holocaust · KÜA
Lamers · LineOut · LoUD · Marquee Design · MEC · MPS · MSB · New Beat · Newline
NoExtra · Omega · OVR · Oxygene · Paradox · PHF · Sector One · smfx · SYNC
TPT · Vectronix · XiA