Files
hakorune/docs/development/roadmap/phases/phase-10.5/10.5b-native-build-consolidation.md

38 lines
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 10.5b ネイティブビルド基盤の固めAOT/EXE
Python統合を本格化する前に、配布可能なネイティブ実行ファイルEXEの足回りを先に完成させる。JITは実行エンジンから外し、EXE生成専用のコンパイラとして運用する。
## 🎯 目的
- VM=実行、JIT=EXEAOTの二系統を明確化フォールバックなし/Fail-Fast
- CLIF→.o→`libnyrt`リンク→EXEのパイプラインを実効化
- プラグイン解決をクロスプラットフォームに(.so/.dll/.dylib、自動lib剥がし、検索パス
- Windowsを含む実用的な配布体験を整備
## 🧩 範囲
- JIT分離・Strict運用Fail-Fast/No-fallback
- AOTパイプライン: `--compile-native``tools/build_aot.{sh,ps1}`
- プラグインローダの拡張: 拡張子変換/`lib`剥がし、`plugin_paths`+`NYASH_PLUGIN_PATHS`
- Windowsリンク: clang優先`nyrt.lib`/`libnyrt.a`両対応、bash+cc fallback
- 観測/EXE出力の統一: `Result: <val>`、終了コード=<val>
## ✅ 成果DoD
- `cargo build --release --features cranelift-jit` の後、
- Linux: `./tools/build_aot.sh examples/aot_min_string_len.hako -o app && ./app`
- Windows: `powershell -ExecutionPolicy Bypass -File tools\build_aot.ps1 -Input examples\aot_min_string_len.hako -Out app.exe && .\app.exe`
- プラグインは `.so` 記述でも各OSで自動解決.dll/.dylib へ変換、lib剥がし
- `tools/smoke_aot_vs_vm.sh` で VM/EXE の `Result:` 行比較が可能(差異は警告表示)
## 🔧 実装メモ
- `src/runtime/plugin_loader_v2.rs``resolve_library_path()` を追加:
- OS別拡張子、Windowsの`lib`剥がし、`plugin_paths`探索
- `src/config/nyash_toml_v2.rs``NYASH_PLUGIN_PATHS` を追加(`;`/`:`区切り)
- `AotConfigBox``set_plugin_paths()` 追加env同期
- `crates/nyrt` の EXE出力統一`Result:`/exit code
- Windows: `tools/build_aot.ps1`clang→bash fallback、Linux: `tools/build_aot.sh`
## 📌 次10.5c 以降)
- PyRuntimeBox/PyObjectBoxRO優先
- Python ABIルータを `libnyrt` に同梱type_id→invokeディスパッチ
- 配布用パッケージ整備nyash.toml/プラグイン配置ガイドの最終化)