Selfhost build: add EXE path via ny-llvmc (tools) + smoke

- tools/selfhost/selfhost_build.sh: support --exe <out>, using LLVM harness (ny-llvmc)
- Add selfhost EXE canary (opt-in): selfhost_build_exe_return.sh
- Keep Stage‑B JSON emit for verification; EXE path currently parses original Hako source (80/20)
This commit is contained in:
nyash-codex
2025-11-02 18:16:11 +09:00
parent 075257a948
commit 2dcf5006c6
2 changed files with 64 additions and 1 deletions

View File

@ -0,0 +1,42 @@
#!/bin/bash
# selfhost_build_exe_return.sh — Build EXE via tools/selfhost_build.sh (optin)
set -euo pipefail
if [ "${SMOKES_ENABLE_SELFHOST:-0}" != "1" ]; then
echo "[SKIP] selfhost_build_exe_return (SMOKES_ENABLE_SELFHOST=1 to enable)"
exit 0
fi
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
ROOT="$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null || cd "$SCRIPT_DIR/../../../../../../.." && pwd)"
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"
require_env || exit 2
# Check ny-llvmc
NYLL="${NYASH_NY_LLVM_COMPILER:-$ROOT/target/release/ny-llvmc}"
if [ ! -f "$NYLL" ]; then
echo "[SKIP] selfhost_build_exe_return (ny-llvmc not found)"
exit 0
fi
tmp_hako="/tmp/selfhost_exe_return7_$$.hako"
tmp_exe="/tmp/selfhost_exe_return7_$$.out"
cat > "$tmp_hako" <<'HAKO'
static box Main { method main(args) { return 7 } }
HAKO
"$ROOT/tools/selfhost/selfhost_build.sh" --in "$tmp_hako" --exe "$tmp_exe" >/dev/null 2>&1 || { echo "[FAIL] selfhost_build_exe_return (build failed)" >&2; exit 1; }
set +e
"$tmp_exe" >/dev/null 2>&1
rc=$?
set -e
rm -f "$tmp_hako" "$tmp_exe" 2>/dev/null || true
if [ "$rc" = "7" ]; then
echo "[PASS] selfhost_build_exe_return"
else
echo "[FAIL] selfhost_build_exe_return (rc=$rc)" >&2
exit 1
fi