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:
@@ -181,7 +181,7 @@ fn processAny(x: Int @latest): Int = x // any version
|
||||
|
||||
### Planned (Not Yet Fully Implemented)
|
||||
|
||||
- **Full Compilation**: JIT works for numeric code, strings/lists/ADTs missing
|
||||
- **Full C Backend**: Basic functions work, closures/lists/pattern variables pending
|
||||
- **Auto-migration Generation**: Migration bodies stored, execution pending
|
||||
|
||||
---
|
||||
@@ -234,7 +234,7 @@ Quick iteration with type inference and a REPL.
|
||||
|
||||
| Limitation | Description |
|
||||
|------------|-------------|
|
||||
| **Limited JIT** | Cranelift JIT works for numeric code only |
|
||||
| **Limited C Backend** | Basic functions work, closures/lists pending |
|
||||
| **No Package Manager** | Can't share/publish packages yet |
|
||||
| **New Paradigm** | Effects require learning new concepts |
|
||||
| **Small Ecosystem** | No community packages yet |
|
||||
@@ -297,7 +297,7 @@ Quick iteration with type inference and a REPL.
|
||||
### Not a Good Fit (Yet)
|
||||
|
||||
- Large production applications (early stage)
|
||||
- Performance-critical code (JIT limited to numeric)
|
||||
- Performance-critical code (C backend still basic)
|
||||
- Web frontend development (no JS compilation)
|
||||
- Systems programming (no low-level control)
|
||||
|
||||
@@ -348,13 +348,12 @@ Source Code
|
||||
├─────────────────────────┐
|
||||
▼ ▼
|
||||
┌─────────────┐ ┌──────────────┐
|
||||
│ Interpreter │ │ JIT Compiler │
|
||||
│ (default) │ │ (Cranelift) │
|
||||
│ Interpreter │ │ C Backend │
|
||||
│ (default) │ │ (compile) │
|
||||
└─────────────┘ └──────────────┘
|
||||
│ │
|
||||
▼ ▼
|
||||
Values + Effects Native Code
|
||||
(~160x speedup)
|
||||
Values + Effects C Code → GCC/Clang
|
||||
```
|
||||
|
||||
---
|
||||
@@ -370,12 +369,12 @@ Values + Effects Native Code
|
||||
- ✅ HTTP Server Effect (listen, accept, respond, stop)
|
||||
- ✅ Test Effect (native testing framework)
|
||||
- ✅ Console.readLine and Console.readInt
|
||||
- ✅ JIT Compiler for numeric code (~160x speedup)
|
||||
- ✅ C Backend (basic functions, Console.print)
|
||||
- ✅ Watch mode / hot reload
|
||||
- ✅ Formatter
|
||||
|
||||
**In Progress:**
|
||||
1. **Behavioral Type Verification** - Total, idempotent, deterministic checking
|
||||
1. **C Backend Extensions** - Closures, lists, pattern variable binding
|
||||
2. **Schema Evolution** - Type system integration, auto-migration
|
||||
3. **Error Message Quality** - Context lines shown, suggestions partial
|
||||
|
||||
@@ -383,4 +382,4 @@ Values + Effects Native Code
|
||||
4. **SQL Effect** - Database access
|
||||
5. **Package Manager** - Share code (manifest parsing exists)
|
||||
6. **JavaScript Backend** - Run in browsers
|
||||
7. **Full JIT** - Strings, lists, ADTs, effects
|
||||
7. **Behavioral Type Verification** - Total, idempotent, deterministic checking
|
||||
|
||||
Reference in New Issue
Block a user