Phase 6: Self-host seed¶
For agentic workers: REQUIRED SUB-SKILL: Use superpowers:executing-plans or build-li-master-plan.
Goal: Ship a bootstrap lic binary compiled from Li source (bootstrap/lic/main.li) by the C++ host. Full compiler rewrite in Li is out of scope for v1; this phase proves the build/run loop and CLI argv bridge.
Architecture: C++ lic remains the production compiler. Li bootstrap binary is a minimal CLI (--version, smoke) using li_rt_argc / li_rt_argv and libc strcmp. Parameterless proc main() lowers to li_user_main with a C main(argc, argv) wrapper that calls li_rt_set_args before user code.
Depends on: Phase 5
Blocks: Future full self-host (parser/types/codegen in Li)
Task 1: Runtime argv bridge¶
Files: - Modify: runtime/li_rt.c, runtime/li_rt.h
-
li_rt_set_args(int argc, char** argv) -
li_rt_argc() -> int,li_rt_argv(i: int) -> ptr
Task 2: Codegen + MIR fixes¶
Files: - Modify: compiler/codegen/emit.cpp - Modify: compiler/mir/lower.cpp
- C
mainwrapper only for parameterless usermain(preservestypedict_ok.lietc.) -
ptrextern params/returns usei8*allocas (ptr_locals) - Nested call expressions as extern call args
-
StoreInt/StoreI64from ident or temp: setrhs_is_literal = false(MIR default wastrue)
Task 3: Bootstrap source + script¶
Files: - Create: bootstrap/lic/main.li - Create: scripts/bootstrap_lic.sh - Modify: .gitignore (build/lic-from-li)
- CLI dispatches on
argv[1](--version,smoke, usage) -
bootstrap_lic.shbuilds and smoke-tests the binary
Task 4: Tests + registration¶
Files: - Modify: li-tests/manifest.toml
- Integration
verify_okon../bootstrap/lic/main.li
Exit gate¶
export LLVM_DIR="$(brew --prefix llvm@18)/lib/cmake/llvm"
./scripts/build.sh
./scripts/bootstrap_lic.sh
LIC=./build/compiler/lic/lic ./li-tests/run_all.sh
Expected:
lic 0.2.0-bootstrap (compiled with Li)on--versionbootstrap: smoke okli-tests: pass=46 fail=0
Out of scope (later)¶
- Rewrite lexer/parser/types/MIR/codegen in Li
- Stage-2 bootstrap: Li-compiled
liccompiling itself lic build/lic checkin bootstrap source