test(smokes): make LLVM EXE runner skip when object emit unavailable
This commit is contained in:
@ -11,6 +11,14 @@
|
||||
|
||||
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}"
|
||||
mkdir -p "$target_dir"
|
||||
echo "$target_dir"
|
||||
}
|
||||
|
||||
llvm_exe_preflight_or_skip() {
|
||||
if ! command -v llvm-config-18 &>/dev/null; then
|
||||
test_skip "llvm-config-18 not found"
|
||||
@ -27,6 +35,22 @@ llvm_exe_preflight_or_skip() {
|
||||
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
|
||||
}
|
||||
|
||||
@ -92,8 +116,11 @@ llvm_exe_ensure_plugins_or_fail() {
|
||||
echo "$CHECK_OUTPUT"
|
||||
echo "[INFO] Missing/broken plugin detected, running build-all"
|
||||
|
||||
local cargo_target_dir
|
||||
cargo_target_dir="$(llvm_exe_cargo_target_dir)"
|
||||
|
||||
local build_log="${LLVM_PLUGIN_BUILD_LOG:-/tmp/llvm_exe_plugin_build.log}"
|
||||
if ! bash "$NYASH_ROOT/tools/plugins/build-all.sh" "${crate_names[@]}" >"$build_log" 2>&1; then
|
||||
if ! env CARGO_TARGET_DIR="$cargo_target_dir" bash "$NYASH_ROOT/tools/plugins/build-all.sh" "${crate_names[@]}" >"$build_log" 2>&1; then
|
||||
echo "[FAIL] tools/plugins/build-all.sh failed"
|
||||
tail -n 80 "$build_log"
|
||||
return 1
|
||||
@ -133,8 +160,17 @@ llvm_exe_build_and_run_numeric_smoke() {
|
||||
|
||||
echo "[INFO] Building: $INPUT_HAKO → $OUTPUT_EXE"
|
||||
|
||||
local cargo_target_dir
|
||||
cargo_target_dir="$(llvm_exe_cargo_target_dir)"
|
||||
|
||||
# Ensure we use the compiler binary built in that target dir.
|
||||
local nyash_bin="$cargo_target_dir/release/hakorune"
|
||||
local obj_out="$cargo_target_dir/aot_objects/$(basename "$INPUT_HAKO").o"
|
||||
mkdir -p "$(dirname "$obj_out")"
|
||||
|
||||
local build_log="${LLVM_BUILD_LOG:-/tmp/llvm_exe_build.log}"
|
||||
if ! env NYASH_DISABLE_PLUGINS=0 "$NYASH_ROOT/tools/build_llvm.sh" "$INPUT_HAKO" -o "$OUTPUT_EXE" 2>&1 | tee "$build_log"; then
|
||||
if ! env CARGO_TARGET_DIR="$cargo_target_dir" NYASH_BIN="$nyash_bin" NYASH_LLVM_OBJ_OUT="$obj_out" NYASH_DISABLE_PLUGINS=0 \
|
||||
"$NYASH_ROOT/tools/build_llvm.sh" "$INPUT_HAKO" -o "$OUTPUT_EXE" 2>&1 | tee "$build_log"; then
|
||||
echo "[FAIL] build_llvm.sh failed"
|
||||
tail -n 80 "$build_log"
|
||||
return 1
|
||||
|
||||
Reference in New Issue
Block a user