Commit d1aabc72

d1aabc72595bMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 6 files · ~5 modified · -1 deleted

Description

Fold the driver into spinelc: one self-contained binary (no shell)

The spinel POSIX shell script is gone; spinelc is now the whole compiler AND driver in a single native binary. It parses, infers types, emits C, invokes cc to link against libspinel_rt.a, and (with -E) runs the result. No shell wrapper and no chained helper binaries, so the compiler works on Windows natively.

main.c grows the full driver: all flags the shell handled (-o/-c/-S/-E, -e, -O/-g/--debug, --line-map/--no-line-map, --cc, --int-overflow, --rbs, --emit-rbs/--emit-types/--emit-symbol-map), self-locates lib/ from the executable path (dev build/ vs installed layout), scrapes the FFI SPINEL_LINK/SPINEL_CFLAGS markers straight from the generated C, builds the cc command (GC flags, MinGW stack, -rdynamic, overflow define), and shells out via system() for portability. The existing env-driven machinery (SPINEL_LINE_MAP / SPINEL_DEBUG / SPINEL_EMIT_* / SPINEL_RBS_SEED) is reused in-process via setenv. Default mode now produces a binary (the old spinelc default of emitting C moves under -c / -S).

Also fix a latent #line bug surfaced by this change: emit_line_directive wrote #line wherever the statement started, so a statement emitted mid-line (an inlined block/proc body) produced a stray '#'. It now breaks the line first. The bug was invisible before because the gate drove spinelc directly without line-map; the driver defaults it on.

Build/Makefile:

  • make builds the binary and a repo-root spinel symlink to it (dev convenience; gitignored). install ships the binary as spinel.
  • test / bench / optcarrot rules pass -c --no-line-map (they want plain, reproducible C; keeps the perf-sensitive optcarrot path byte-stable).
  • clean removes the symlink; README updated.

make gate: ALL GREEN (test 846, bench, optcarrot, self-host fixpoint).

Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]

Details

Commit
d1aabc72595b
Parent
25251640df94

.gitignoremodifiedView file

@@ -13,6 +13,8 @@
1313 /build/
1414 /legacy/build/
1515 /vendor/
16+# Dev convenience symlink to build/spinelc (created by `make`)
17+/spinel
1618
1719 # Temp files
1820 /tmp/