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

@@ -16,12 +16,6 @@ rand = "0.8"
reqwest = { version = "0.11", features = ["blocking", "json"] }
tiny_http = "0.12"
# Cranelift for native compilation
cranelift-codegen = "0.95"
cranelift-frontend = "0.95"
cranelift-module = "0.95"
cranelift-jit = "0.95"
target-lexicon = "0.12"
[dev-dependencies]
tempfile = "3"