2025-11-02 18:07:33 +09:00
|
|
|
|
Hybrid Selfhost Build (80/20)
|
|
|
|
|
|
|
|
|
|
|
|
Purpose
|
|
|
|
|
|
- Provide a minimal, fast path to compile Hako source via Hakorune Stage‑B to Program(JSON v0), and optionally run it via Core‑Direct (in‑proc).
|
|
|
|
|
|
- Future: add MIR emit and ny-llvmc EXE build in small increments.
|
|
|
|
|
|
|
|
|
|
|
|
Script
|
|
|
|
|
|
- tools/selfhost/selfhost_build.sh
|
|
|
|
|
|
- --in <file.hako>: input Hako source
|
|
|
|
|
|
- --json <out.json>: write Program(JSON v0); default: /tmp/hako_stageb_$$.json
|
2025-11-02 18:48:34 +09:00
|
|
|
|
- --mir <out.json>: emit MIR(JSON) from source (runner path)
|
|
|
|
|
|
- --exe <out>: build native executable via ny-llvmc (llvmlite harness)
|
2025-11-02 18:07:33 +09:00
|
|
|
|
- --run: run via Gate‑C/Core Direct (in‑proc). Exit code mirrors program return.
|
|
|
|
|
|
- Env:
|
|
|
|
|
|
- NYASH_BIN: path to hakorune/nyash binary (auto-detected)
|
|
|
|
|
|
- NYASH_ROOT: repo root (auto-detected)
|
2025-11-02 18:48:34 +09:00
|
|
|
|
- HAKO_USE_BUILDBOX=1: use BuildBox for emit-only (no run/exe)
|
2025-11-02 18:07:33 +09:00
|
|
|
|
|
|
|
|
|
|
Examples
|
|
|
|
|
|
```bash
|
2025-11-02 18:48:34 +09:00
|
|
|
|
# Emit JSON only (Stage‑B)
|
2025-11-02 18:07:33 +09:00
|
|
|
|
tools/selfhost/selfhost_build.sh --in apps/demo/main.hako --json /tmp/demo.json
|
|
|
|
|
|
|
|
|
|
|
|
# Run and use exit code
|
|
|
|
|
|
tools/selfhost/selfhost_build.sh --in apps/demo/return7.hako --run; echo $?
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
Notes
|
2025-11-02 18:48:34 +09:00
|
|
|
|
- Stage‑B emit uses either the Stage‑B entry or BuildBox(HAKO_USE_BUILDBOX=1 for emit-only)
|
2025-11-02 18:07:33 +09:00
|
|
|
|
- Runner executes Core‑Direct in-proc under HAKO_CORE_DIRECT_INPROC=1.
|
|
|
|
|
|
- For heavier cases (bundles/alias/require), keep Stage‑B canaries opt‑in in quick profile.
|