feat: replace Cranelift JIT with C backend

Remove Cranelift JIT compiler and expose the existing C backend as the
compilation target. Generated C code can be compiled with GCC/Clang.

Changes:
- Remove cranelift-* dependencies from Cargo.toml
- Delete src/compiler.rs (565 lines of Cranelift code)
- Add compile_to_c() function with -o and --run flags
- Fix C backend name mangling (main -> main_lux) to avoid conflicts
- Update CLI help text and documentation

Usage:
  lux compile <file.lux>           # Output C to stdout
  lux compile <file.lux> -o out.c  # Write to file
  lux compile <file.lux> --run     # Compile and execute

C backend supports: functions, basic types, operators, if/then/else,
records, enums, Console.print. Future work: closures, lists, patterns.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-14 03:37:35 -05:00
parent 8c7354131e
commit 67437b8273
8 changed files with 132 additions and 999 deletions

View File

@@ -614,16 +614,15 @@ fn main() =
**Goal**: Compile to a real target
- [x] JIT compiler (Cranelift) - works for numeric code (~160x speedup)
- [x] C backend scaffolding
- [ ] Full JIT (strings, lists, ADTs, effects)
- [x] C backend (basic functions, Console.print)
- [ ] C backend extensions (closures, lists, pattern variables)
- [ ] JavaScript backend
- [ ] WASM backend
- [ ] Optimization passes
**Deliverable**: Compiled programs that run natively or in browser
**Current**: `lux compile <file>` JIT compiles numeric code. C backend in progress.
**Current**: `lux compile <file>` compiles to C code. Compile and run with `--run` flag.
### Phase 3: Schema Evolution ⚠️ PARTIAL
@@ -719,7 +718,7 @@ fn abs(x: Int): Int
### Pragmatics (In Progress)
- Primary target: Tree-walking interpreter (default), JIT for performance
- Primary target: Tree-walking interpreter (default), C backend for compilation
- FFI: Shell commands via Process effect
- [ ] JavaScript backend for browser use