📚 Phase 15 - セルフホスティング戦略の明確化とEXE-first実装

## 主な変更点

### 🎯 戦略の転換と明確化
- PyVMを開発ツールとして位置づけ(本番経路ではない)
- EXE-first戦略を明確に優先(build_compiler_exe.sh実装済み)
- Phase順序の整理: 15.2(LLVM)→15.3(コンパイラ)→15.4(VM)

### 🚀 セルフホスティング基盤の実装
- apps/selfhost-compiler/にNyashコンパイラMVP実装
  - compiler.nyash: メインエントリー(位置引数対応)
  - boxes/: parser_box, emitter_box, debug_box分離
- tools/build_compiler_exe.sh: ネイティブEXEビルド+dist配布
- Python MVPパーサーStage-2完成(local/if/loop/call/method/new)

### 📝 ドキュメント整備
- Phase 15 README/ROADMAP更新(Self-Hosting優先明記)
- docs/guides/exe-first-wsl.md: WSLクイックスタート追加
- docs/private/papers/: 論文G~L、爆速事件簿41事例収録

### 🔧 技術的改善
- JSON v0 Bridge: If/Loop PHI生成実装(ChatGPT協力)
- PyVM/llvmliteパリティ検証スイート追加
- using/namespace機能(gated実装、Phase 15では非解決)

## 次のステップ
1. パーサー無限ループ修正(未実装関数の実装)
2. EXEビルドとセルフホスティング実証
3. c0→c1→c1'ブートストラップループ確立

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Selfhosting Dev
2025-09-15 18:44:49 +09:00
parent 8f11c79f19
commit d90216e9c4
68 changed files with 4521 additions and 1641 deletions

View File

@ -0,0 +1,56 @@
# EXEFirst Quickstart (WSL/Ubuntu)
This guide prioritizes building and running the Nyash parser as a native executable on WSL (Ubuntu). It uses the LLVM harness (llvmlite) and the NyRT static runtime.
Prerequisites
- Rust toolchain (stable): `curl https://sh.rustup.rs -sSf | sh`
- Build tools: `sudo apt update && sudo apt install -y build-essential git python3 python3-pip`
- llvmlite: `pip3 install --user llvmlite`
- LLVM 18 (for `llvm-config-18` used by the Rust build + tools):
- Ubuntu (with apt.llvm.org):
- `sudo apt install -y wget gnupg lsb-release`
- `wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 18`
- This installs `llvm-18` and `llvm-18-dev` (provides `llvm-config-18`).
Verify
- `rustc --version`
- `python3 -c "import llvmlite, sys; print('llvmlite', llvmlite.__version__)"`
- `llvm-config-18 --version`
Build Parser EXE (bundle)
- `tools/build_compiler_exe.sh`
- Result: `dist/nyash_compiler/` containing `nyash_compiler`, `nyash.toml`, and the FileBox plugin.
Smoke (Parser EXE → JSON)
- `echo 'return 1+2*3' > dist/nyash_compiler/tmp/sample.ny`
- `(cd dist/nyash_compiler && ./nyash_compiler tmp/sample.ny > sample.json)`
- `head -n1 dist/nyash_compiler/sample.json` should start with `{` and contain `"kind":"Program"`.
EndtoEnd (JSON → execute via bridge)
- `./tools/exe_first_smoke.sh`
- Builds the EXE bundle, runs parser → JSON, and executes via the bridge to verify exit code `7`.
MIR Builder (optional, EXE)
- Build: `cargo build --release --features llvm`
- EXE from JSON: `./target/release/ny_mir_builder --in dist/nyash_compiler/sample.json --emit exe -o app_out`
- Run: `./app_out` (exit `7` expected for `return 1+2*3`).
Runner with EXEFirst Parser
- `NYASH_USE_NY_COMPILER=1 NYASH_USE_NY_COMPILER_EXE=1 ./target/release/nyash --backend vm tmp/sample.nyash`
- Smoke: `./tools/exe_first_runner_smoke.sh`
Troubleshooting
- `llvm-config-18: not found`
- Ensure apt.llvm.org installation worked (see above), or install the distros `llvm-18-dev` package.
- `ModuleNotFoundError: llvmlite`
- `pip3 install --user llvmlite` and rerun the build/smoke.
- Link errors (`cc` not found or missing libs)
- `sudo apt install -y build-essential`
- If you have a custom toolchain, export `CC` to point at your compiler.
- Plugin resolution
- The EXE bundle includes a minimal `nyash.toml` and plugin paths under `dist/nyash_compiler/plugins/`.
Notes
- The EXEfirst path is the delivery priority. PyVM remains a development aid for semantics parity.
- Windows support is evolving; WSL is the recommended environment for now.