Files
hakorune/tools/selfhost
nyash-codex 981ddd890c Phase 22.1 WIP: SSOT resolver + TLV infrastructure + Hako MIR builder setup
Setup infrastructure for Phase 22.1 (TLV C shim & Resolver SSOT):

Core changes:
- Add nyash_tlv, nyash_c_core, nyash_kernel_min_c crates (opt-in)
- Implement SSOT resolver bridge (src/using/ssot_bridge.rs)
- Add HAKO_USING_SSOT=1 / HAKO_USING_SSOT_HAKO=1 env support
- Add HAKO_TLV_SHIM=1 infrastructure (requires --features tlv-shim)

MIR builder improvements:
- Fix using/alias consistency in Hako MIR builder
- Add hako.mir.builder.internal.{prog_scan,pattern_util} to nyash.toml
- Normalize LLVM extern calls: nyash.console.* → nyash_console_*

Smoke tests:
- Add phase2211 tests (using_ssot_hako_parity_canary_vm.sh)
- Add phase2220, phase2230, phase2231 test structure
- Add phase2100 S3 backend selector tests
- Improve test_runner.sh with quiet/timeout controls

Documentation:
- Add docs/ENV_VARS.md (Phase 22.1 env vars reference)
- Add docs/development/runtime/C_CORE_ABI.md
- Update de-rust-roadmap.md with Phase 22.x details

Tools:
- Add tools/hakorune_emit_mir.sh (Hako-first MIR emission wrapper)
- Add tools/tlv_roundtrip_smoke.sh placeholder
- Improve ny_mir_builder.sh with better backend selection

Known issues (to be fixed):
- Parser infinite loop in static method parameter parsing
- Stage-B output contamination with "RC: 0" (needs NYASH_JSON_ONLY=1)
- phase2211/using_ssot_hako_parity_canary_vm.sh fork bomb (needs recursion guard)

Next steps: Fix parser infinite loop + Stage-B quiet mode for green tests
2025-11-09 15:11:18 +09:00
..

Hybrid Selfhost Build (80/20)

Purpose

  • Provide a minimal, fast path to compile Hako source via Hakorune StageB to Program(JSON v0), and optionally run it via CoreDirect (inproc).
  • 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
    • --mir <out.json>: emit MIR(JSON) from source (runner path)
    • --exe : build native executable via ny-llvmc (llvmlite harness)
    • --run: run via GateC/Core Direct (inproc). Exit code mirrors program return.
    • Env:
      • NYASH_BIN: path to hakorune/nyash binary (auto-detected)
      • NYASH_ROOT: repo root (auto-detected)
      • HAKO_USE_BUILDBOX=1: use BuildBox for emit-only (no run/exe)

Examples

# Emit JSON only (StageB)
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

  • StageB emit uses either the StageB entry or BuildBoxHAKO_USE_BUILDBOX=1 for emit-only
  • Runner executes CoreDirect in-proc under HAKO_CORE_DIRECT_INPROC=1.
  • For heavier cases (bundles/alias/require), keep StageB canaries optin in quick profile.