Working on a compiler can be complex. This playbook provides repeatable command paths for diagnosing parser, semantic, ABI, and code generation issues when contributing to Aburiscript.
- Wrong preprocessor output:
- Run the compiler with
-Eto inspect the transformed text.
- Run the compiler with
- Parser diagnostic mismatch or recovery bug:
- Inspect
parser/parser.cpporparser/parser_cxx.cpp. - Reproduce the failure with the smallest possible source file.
- Inspect
- Name lookup or overload mismatch:
- Inspect
collect/decl_context.cpp,collect/lookup_engine.cpp, orcollect/collect_decl.cpp. - Reduce the input until the wrong lookup is obvious in a single file.
- Inspect
- Link/mangling collision:
- Inspect
abi/mangle.cppandabi/abi_policy.cpp. - Compare the emitted symbols or IR for a minimal reproducer.
- Inspect
- Compiles but runtime result is wrong:
- The issue is likely in
ast2llvm/ast2llvm.cpp,ast2llvm/flow.cpp, orast2llvm/arith.cpp. - Write a minimal reproducer C file and emit the LLVM IR (see below) to check how
ast2llvmlowered your AST.
- The issue is likely in
Assuming you built the compiler into a build/ directory:
To see exactly what the parser sees (after macros and #includes are expanded):
./build/aburi input.c -EThis is the most critical command for debugging backend/codegen bugs. It outputs the human-readable LLVM Intermediate Representation.
./build/aburi input.c --emit-llvm -o out.ll./build/aburi input.c -S -o out.sStops before invoking the system linker.
./build/aburi input.c -c -o out.oUseful for verifying that AST nodes are being constructed and tracked correctly in side-tables.
./build/aburi input.c -c --ast-memory-reportThe public repository ships with a small runtime smoke suite under
public_tests/.
# Configure with public tests enabled
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DLLVM_DIR=/path/to/llvm-18/lib/cmake/llvm -DABURI_BUILD_PUBLIC_TESTS=ON
# Run the public runtime smoke suite
ctest --test-dir build -R public_tests_runtime --output-on-failureIf the Aburiscript compiler itself segfaults, you can run it through lldb (or gdb):
lldb -batch -o "run -- input.c -c" -k "bt" -k "quit" ./build/aburi- Reproduce the bug with the smallest possible source file.
- Add or update a focused sample in
public_tests/when the bug belongs in the public smoke suite. - Fix the bug in the smallest subsystem that owns the behavior (e.g.,
parser/,collect/, orast2llvm/). - Run the relevant compiler command directly on the reproducer.
- Run
ctest -R public_tests_runtimeif the change affects the public smoke suite.