On this page

0150: Debug and profile builds

Status: Proposed — design default, pending the maintainer's confirmation

Context

Debugging needs stable source attribution and useful profiling symbols without changing ordinary builds. This numbering starts at 0150, leaving 0122–0149 for the owner's in-progress M14 ADRs.

Decision

Add build and run flags --debug (-g -Og) and --profile (-g -O2), both with frame pointers and a debug-prefix map from the temporary build directory to the package root. Reject using both flags. Keep default compiler flags and machine code unchanged; generated C in all builds gains #line directives for the main() wrapper and trailing glue (no .text change without -g); include flags in build-cache identity and normalize the mapped temp directory there.

Map compiler-added statements inside each hn_* function to lines within its source function span; map the main() wrapper to fn main. Map trailing generated glue to a <stem>.hn.c pseudo-file. Preserve per-module mappings. Keep hn_<name> symbols and document source/mangling attribution in debugging.md.

Consequences

Debug binaries support addr2line; profile binaries retain frame pointers for perf. Tool-dependent tests skip with a clear message when tools or perf access are unavailable. No language diagnostics or traps change.

Alternatives considered

Changing default compiler flags or C output would disturb existing reproducibility and goldens. Renaming symbols or adding a demangler is unnecessary for source attribution.