Kern
On this page

Native Cortex-M3 size gate

Measured 2026-11-23 from bc29445 on macOS with both stage0 and self-hosted compilers, using Arm GNU size 2.44.0.20250616. Both produced the same sizes in bytes. Reproduce with python3 bench/size_mcu.py after building the compilers; --json FILE saves machine-readable results. Pass compiler paths to select one or more explicitly. sh scripts/mcu-size.sh measures and enforces the gate. The native ELF contains a vector table, startup, and semihosting support; it is for QEMU mps2-an385, not qualified board firmware.

ProgramELF bytes.text.rodata.data.bssFlashStatic RAM
arithmetic12156243813350037730
blinky928447060005300
empty88681400001400
fib9612708174008820
hello889215219001710
overflow915640849004570

Flash is .text + .rodata + .data; static RAM is .data + .bss. ELF headers, non-loadable metadata, stack and heap are excluded from both totals. ELF bytes are reported for inspection only, not used as a budget. These totals are not full board memory requirements; stack usage is not measured.

Budgets and regression rule

Budgets are bytes, with roughly 15% flash headroom rounded upward and 32 bytes of static RAM headroom. bench/size_mcu_budgets.json is the gate's authoritative baseline and budget. Each compiler and each program must fit both budgets; exceeding either fails. Growth strictly greater than 5% over the recorded flash or static RAM baseline warns, even when within budget. Any positive static RAM use warns against the current zero baseline. New fixtures require explicit baseline and budget entries; missing or extra entries fail the gate. Baselines and budgets should change only with a reviewed explanation of the size change.

ProgramFlash budgetStatic RAM budget
empty16532
hello (semihosting)20032
fib102032
blinky61032
arithmetic435032
overflow53032

C -Os comparison

M4-SIZES.md reports Cortex-M3 flash of 4 bytes for empty, 39 for hello, 14 for blinky and 140 for sieve. The corresponding Kern measurements are 140, 171 and 530 bytes for empty, hello and blinky (35×, 4.38× and 37.86×), respectively. These are illustrative, not equivalent workload ratios: C has no vectors or startup; its hello writes unpaced to a placeholder UART, while Kern uses semihosting with a different string; C blinky toggles a GPIO forever, while Kern prints a bounded counter. C reserves 1024 stack bytes, whereas the static RAM metric here excludes stack. There is no matching C reference for Kern's iterative fib, arithmetic, or overflow, and no matching Kern sieve. The 1.5× C target in the plan cannot be fairly gated by these mismatched fixtures. The budgets above guard the current native examples, including their startup and runtime, until matched workloads exist.

Source: SIZE-MCU.md in the repository.