fix(llvm): make LLVM EXE smokes use workspace target and reliable build_llvm

This commit is contained in:
nyash-codex
2025-12-18 09:22:11 +09:00
parent 4a109eb6b9
commit 46a623fd75
2 changed files with 19 additions and 30 deletions

View File

@ -12,9 +12,8 @@
set -uo pipefail
llvm_exe_cargo_target_dir() {
# Release builds can fail with EXDEV when rustc uses /tmp for temp files and target/ is elsewhere.
# Force a dedicated target dir under /tmp so rustc temp files and outputs stay on the same filesystem.
local target_dir="${LLVM_EXE_CARGO_TARGET_DIR:-/tmp/nyash_cargo_target}"
# Use the workspace target dir by default so `NYASH_BIN` and plugin artifacts match local dev expectations.
local target_dir="${LLVM_EXE_CARGO_TARGET_DIR:-$NYASH_ROOT/target}"
mkdir -p "$target_dir"
echo "$target_dir"
}
@ -25,32 +24,11 @@ llvm_exe_preflight_or_skip() {
return 1
fi
if ! "$NYASH_BIN" --help 2>&1 | grep -q "llvm"; then
test_skip "hakorune --backend llvm not available"
return 1
fi
if ! python3 -c "import llvmlite" 2>/dev/null; then
test_skip "Python llvmlite not found"
return 1
fi
# Verify the binary can actually emit an object (not "mock LLVM").
# This avoids hard failures when hakorune was built without `--features llvm`.
local cargo_target_dir
cargo_target_dir="$(llvm_exe_cargo_target_dir)"
local preflight_obj="$cargo_target_dir/_llvm_exe_preflight.o"
rm -f "$preflight_obj"
if ! env NYASH_DISABLE_PLUGINS=1 NYASH_LLVM_USE_HARNESS=1 NYASH_LLVM_OBJ_OUT="$preflight_obj" \
"$NYASH_BIN" --backend llvm "$NYASH_ROOT/apps/tests/phase87_llvm_exe_min.hako" >/dev/null 2>&1; then
test_skip "LLVM object emit preflight failed (hakorune may lack --features llvm)"
return 1
fi
if [ ! -f "$preflight_obj" ]; then
test_skip "LLVM object emit unavailable (hakorune may be built without --features llvm)"
return 1
fi
return 0
}