From 804ccff23f89a684ed021131040b652a68ab33d1 Mon Sep 17 00:00:00 2001 From: nyash-codex Date: Tue, 2 Dec 2025 13:09:10 +0900 Subject: [PATCH] =?UTF-8?q?feat(phase73):=20Selfhost=20Stage-B=20I/O=20?= =?UTF-8?q?=E7=B0=A1=E7=B4=A0=E5=8C=96=20-=20HAKO=5FSRC=20=E7=92=B0?= =?UTF-8?q?=E5=A2=83=E5=A4=89=E6=95=B0=E7=B5=B1=E4=B8=80=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unified selfhost Stage-B I/O path from argv to environment variables: - Remove --source "$SRC_CONTENT" from compiler.hako invocation (argv limit) - Export HAKO_SRC="$SRC_CONTENT" instead (env-based I/O) - Update compiler_stageb.hako to check HAKO_SRC fallback Changes: 1. lang/src/compiler/entry/compiler_stageb.hako: - Added HAKO_SRC env check in StageBArgsBox.resolve_src() - Fallback order: --source arg → HAKO_SOURCE_FILE_CONTENT → HAKO_SRC → default 2. tools/selfhost/selfhost_build.sh: - Removed --source "$SRC_CONTENT" from compiler.hako invocation - Export HAKO_SRC="$SRC_CONTENT" before Stage-B execution - Unified with wrapper pathway (HAKO_USE_BUILDBOX=1) Benefits: - Eliminates "Argument list too long" (os error 7) for large .hako files - Single unified I/O pattern (env variables) for all Stage-B paths - Consistent with hako_check.sh and wrapper pattern - Ready for future HAKO_SRC_FILE optimization Verification: ✅ NYASH_FEATURES=stage3 NYASH_USE_NY_COMPILER=1 \ ./tools/selfhost/selfhost_build.sh --in apps/tests/stage1_run_min.hako --run Output: abc (correct) 🤖 Generated with Claude Code Co-Authored-By: Claude --- lang/src/compiler/entry/compiler_stageb.hako | 7 +++++-- tools/selfhost/selfhost_build.sh | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lang/src/compiler/entry/compiler_stageb.hako b/lang/src/compiler/entry/compiler_stageb.hako index f54796dd..5106018b 100644 --- a/lang/src/compiler/entry/compiler_stageb.hako +++ b/lang/src/compiler/entry/compiler_stageb.hako @@ -65,8 +65,11 @@ static box StageBArgsBox { local inline = env.get("HAKO_SOURCE_FILE_CONTENT") if inline != null { src = "" + inline } } - // Skip env.local.get check - Stage-3 keyword conflict - // Original: if src == null { src = env.local.get("HAKO_SOURCE") } + // Phase 73: Fallback to HAKO_SRC env variable (unified I/O path) + // This eliminates the need for large argv strings (solves "Argument list too long") + if src == null { + src = env.get("HAKO_SRC") + } if src == null { src = "return 0" } { diff --git a/tools/selfhost/selfhost_build.sh b/tools/selfhost/selfhost_build.sh index a4782b7a..0ab3e359 100644 --- a/tools/selfhost/selfhost_build.sh +++ b/tools/selfhost/selfhost_build.sh @@ -93,10 +93,11 @@ else apply_selfhost_env stageb_cmd_desc="compiler.hako --stage-b --stage3" ( + export HAKO_SRC="$SRC_CONTENT" cd "$ROOT" && \ "$BIN" --backend vm \ "$ROOT/lang/src/compiler/entry/compiler.hako" -- \ - --stage-b --stage3 --source "$SRC_CONTENT" + --stage-b --stage3 ) > "$RAW" 2>&1 || stageb_rc=$? fi