No. 82 / project of 147 on the ladder

Chip-side C compiler

introduces — guest-side compiler; generated RV32 Linux ELF; exec from tmpfs; TinyCC feasibility check

harden statelast run2026-05-05
signoff
  • DRCNOT RUN
  • LVSNOT RUN
  • antennaNOT RUN

P82 takes the BusyBox shell from P81 and uses it to compile something on the chip for the chip. A new /bin/chipcc program runs inside the RV32 Linux guest, reads /usr/share/p82/hello.c, emits a static RV32 Linux ELF at /tmp/p82_hello, and then BusyBox ash executes that new file.

The generated executable printed:

P82-COMPILED-ON-CHIP

Why Not TinyCC?

TinyCC was checked first. The available Nix package metadata exposes a riscv32-linux platform, but the local TCC source tree only has RISC-V backend files for riscv64 and its configure target detection recognizes riscv64, not riscv32. A direct cross build also failed while trying to execute a target-built helper on the x86 host.

So this page does not claim TinyCC support. chipcc is a tiny purpose-built compiler for a C-shaped subset: one print call and an optional return value.

Output Shape

chipcc emits a 456-byte ELF32 little-endian RISC-V executable in the passing run. The generated program is syscall-only: RV32I instructions load the arguments for SYS_write, execute ecall, then load SYS_exit and execute another ecall.

That is narrow, but it proves the useful stack:

guest compiler -> tmpfs output file -> Linux ELF loader -> generated RV32 code -> syscall output

Verification

tty-smoke waits for the shell prompt, then sends commands through the same host-input FIFO used by the interactive console:

P82-BUSYBOX-SMOKE
P82-UNAME-OK
P82-TOOLS-OK
P82-BACKSPACE-OK
chipcc: wrote 456-byte RV32 Linux ELF to /tmp/p82_hello
P82-COMPILED-ON-CHIP
P82-COMPILE-OK
P82-FILE-OK

The passing run stopped on P82-FILE-OK after 183,069,150 post-load cycles with all 284 host input bytes delivered.

Honest Status

checkstatus
Linux boots to BusyBox /initPASS
/bin/chipcc runs inside the guestPASS
chipcc emits a new RV32 Linux ELF into /tmpPASS
Generated executable runs and prints through hvc0PASS
TinyCC RV32 codegen with the local packageFAIL
LibreLane hardeningNOT RUN

What just happened?

The chip is no longer limited to executing binaries baked into the initramfs by the host. It can run a compiler-like guest program, create a new executable file, and immediately run that file under Linux.