📚 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:
97
tools/build_compiler_exe.sh
Normal file
97
tools/build_compiler_exe.sh
Normal file
@ -0,0 +1,97 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [[ "${NYASH_CLI_VERBOSE:-0}" == "1" ]]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
usage() {
|
||||
cat << USAGE
|
||||
Usage: tools/build_compiler_exe.sh [-o <name>] [--no-pack]
|
||||
|
||||
Builds the selfhost Nyash parser as a native EXE using the LLVM harness,
|
||||
and stages a runnable bundle with required plugin (FileBox) and nyash.toml.
|
||||
|
||||
Options:
|
||||
-o <name> Output executable name (default: nyash_compiler)
|
||||
--no-pack Do not create dist/ bundle; only build the executable in repo root
|
||||
|
||||
Examples:
|
||||
tools/build_compiler_exe.sh
|
||||
tools/build_compiler_exe.sh -o nyc
|
||||
USAGE
|
||||
}
|
||||
|
||||
OUT="nyash_compiler"
|
||||
PACK=1
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
-h|--help) usage; exit 0 ;;
|
||||
-o) OUT="$2"; shift 2 ;;
|
||||
--no-pack) PACK=0; shift ;;
|
||||
*) echo "unknown arg: $1" >&2; usage; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if ! command -v llvm-config-18 >/dev/null 2>&1; then
|
||||
echo "error: llvm-config-18 not found (install LLVM 18 dev)." >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# 1) Build nyash with LLVM harness
|
||||
echo "[1/4] Building nyash (LLVM harness) ..."
|
||||
_LLVMPREFIX=$(llvm-config-18 --prefix)
|
||||
LLVM_SYS_181_PREFIX="${_LLVMPREFIX}" LLVM_SYS_180_PREFIX="${_LLVMPREFIX}" \
|
||||
cargo build --release -j 24 --features llvm >/dev/null
|
||||
|
||||
# 2) Emit + link compiler.nyash → EXE
|
||||
echo "[2/4] Emitting + linking selfhost compiler ..."
|
||||
tools/build_llvm.sh apps/selfhost-compiler/compiler.nyash -o "$OUT"
|
||||
|
||||
if [[ "$PACK" == "0" ]]; then
|
||||
echo "✅ Built: ./$OUT"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 3) Build FileBox plugin (required when reading files)
|
||||
echo "[3/4] Building FileBox plugin ..."
|
||||
unset NYASH_DISABLE_PLUGINS || true
|
||||
cargo build -p nyash-filebox-plugin --release >/dev/null
|
||||
|
||||
# 4) Stage dist/ bundle
|
||||
echo "[4/4] Staging dist bundle ..."
|
||||
DIST="dist/nyash_compiler"
|
||||
rm -rf "$DIST"
|
||||
mkdir -p "$DIST/plugins/nyash-filebox-plugin/target/release" "$DIST/tmp"
|
||||
cp -f "$OUT" "$DIST/"
|
||||
|
||||
# Copy plugin binary (platform-specific extension). Copy entire release dir for safety.
|
||||
cp -a plugins/nyash-filebox-plugin/target/release/. "$DIST/plugins/nyash-filebox-plugin/target/release/" || true
|
||||
|
||||
# Minimal nyash.toml for runtime (FileBox only)
|
||||
cat > "$DIST/nyash.toml" << 'TOML'
|
||||
[libraries]
|
||||
[libraries."libnyash_filebox_plugin"]
|
||||
boxes = ["FileBox"]
|
||||
path = "./plugins/nyash-filebox-plugin/target/release/libnyash_filebox_plugin"
|
||||
|
||||
[libraries."libnyash_filebox_plugin".FileBox]
|
||||
type_id = 6
|
||||
|
||||
[libraries."libnyash_filebox_plugin".FileBox.methods]
|
||||
birth = { method_id = 0 }
|
||||
open = { method_id = 1, args = ["path", "mode"] }
|
||||
read = { method_id = 2 }
|
||||
write = { method_id = 3, args = ["data"] }
|
||||
close = { method_id = 4 }
|
||||
fini = { method_id = 4294967295 }
|
||||
TOML
|
||||
|
||||
echo "✅ Done: $DIST"
|
||||
echo " Usage:"
|
||||
echo " echo 'return 1+2*3' > $DIST/tmp/sample.nyash"
|
||||
echo " (cd $DIST && ./$(basename "$OUT") tmp/sample.nyash > sample.json)"
|
||||
echo " head -n1 sample.json"
|
||||
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user