commit e8e6581c9b695d8e265a180dc64d27e73938815f
parent f67721344dae984c70e84c70eac94e2f3f48fc3b
Author: Ryan Sepassi <rsepassi@gmail.com>
Date: Sun, 17 May 2026 22:17:47 -0700
wasm: run executable path for macho tests
Diffstat:
| M | test/wasm/run.sh | | | 67 | +++++++++++++++++++++++++++++++++++++++++-------------------------- |
1 file changed, 41 insertions(+), 26 deletions(-)
diff --git a/test/wasm/run.sh b/test/wasm/run.sh
@@ -24,25 +24,42 @@ note_pass() { printf ' PASS %s\n' "$1"; pass=$((pass + 1)); }
note_fail() { printf ' FAIL %s\n' "$1"; fail=$((fail + 1)); }
note_skip() { printf ' SKIP %s (%s)\n' "$1" "$2"; skip=$((skip + 1)); }
+case "$TEST_ARCH" in
+ aa64|aarch64|arm64) TEST_ARCH=aa64; EXEC_ARCH="aarch64" ;;
+ x64|x86_64|amd64) TEST_ARCH=x64; EXEC_ARCH="x64" ;;
+ rv64|riscv64) TEST_ARCH=rv64; EXEC_ARCH="rv64" ;;
+ *) TEST_ARCH=aa64; EXEC_ARCH="aarch64" ;;
+esac
+
host_arch=$(uname -m)
host_matches=0
case "$TEST_ARCH:$host_arch" in
- aa64:arm64|aa64:aarch64|aarch64:arm64|aarch64:aarch64|arm64:arm64) host_matches=1 ;;
- x64:x86_64|x86_64:x86_64) host_matches=1 ;;
+ aa64:arm64|aa64:aarch64) host_matches=1 ;;
+ x64:x86_64) host_matches=1 ;;
esac
case "$TEST_OBJ" in
- macho) target_triple="aarch64-macos" ;;
+ macho)
+ EXEC_OS="macos"
+ case "$TEST_ARCH" in
+ aa64) target_triple="aarch64-macos"; clang_triple="arm64-apple-macos" ;;
+ x64) target_triple="x86_64-macos"; clang_triple="x86_64-apple-macos" ;;
+ *) target_triple="aarch64-macos"; clang_triple="arm64-apple-macos" ;;
+ esac
+ ;;
elf)
+ EXEC_OS="linux"
case "$TEST_ARCH" in
- aa64|aarch64|arm64) target_triple="aarch64-linux" ;;
- x64|x86_64|amd64) target_triple="x86_64-linux" ;;
- rv64|riscv64) target_triple="riscv64-linux" ;;
- *) target_triple="aarch64-linux" ;;
+ aa64) target_triple="aarch64-linux"; clang_triple="aarch64-linux-gnu" ;;
+ x64) target_triple="x86_64-linux"; clang_triple="x86_64-linux-gnu" ;;
+ rv64) target_triple="riscv64-linux"; clang_triple="riscv64-linux-gnu" ;;
+ *) target_triple="aarch64-linux"; clang_triple="aarch64-linux-gnu" ;;
esac
;;
- *) target_triple="aarch64-macos" ;;
+ *) target_triple="aarch64-macos"; clang_triple="arm64-apple-macos"; EXEC_OS="macos" ;;
esac
+EXEC_TAG="$EXEC_ARCH-$EXEC_OS"
+export CFREE_TEST_ARCH="$TEST_ARCH" CFREE_TEST_OBJ="$TEST_OBJ"
have_wasm_tool=0
if [ -x "$WASM_TOOL" ]; then
@@ -67,24 +84,23 @@ QEMU_BIN="$(command -v qemu-aarch64-static 2>/dev/null || command -v qemu-aarch6
command -v podman >/dev/null 2>&1 && have_podman=1
arch_raw="$(uname -m 2>/dev/null || true)"
{ [ "$arch_raw" = "aarch64" ] || [ "$arch_raw" = "arm64" ]; } && is_aarch64=1
-case "$TEST_ARCH" in
- aa64|aarch64|arm64) EXEC_ARCH="aarch64" ;;
- x64|x86_64|amd64) EXEC_ARCH="x64" ;;
- rv64|riscv64) EXEC_ARCH="rv64" ;;
- *) EXEC_ARCH="$TEST_ARCH" ;;
-esac
EXEC_TARGET_MOUNT_ROOT="$BUILD_DIR"
# shellcheck source=../lib/exec_target.sh
source "$ROOT/test/lib/exec_target.sh"
START_OBJ="$BUILD_DIR/start.o"
have_start_obj=0
-if [ "$TEST_OBJ" = "elf" ]; then
- clang_target="$target_triple"
- if clang --target="$clang_target" -ffreestanding -fno-stack-protector \
- -fno-builtin -nostdlib -c "$LINK_TEST_DIR/harness/start.c" \
- -o "$START_OBJ" >"$BUILD_DIR/start.out" 2>"$BUILD_DIR/start.err"; then
- have_start_obj=1
+if clang --target="$clang_triple" -ffreestanding -fno-stack-protector \
+ -fno-builtin -nostdlib -c "$LINK_TEST_DIR/harness/start.c" \
+ -o "$START_OBJ" >"$BUILD_DIR/start.out" 2>"$BUILD_DIR/start.err"; then
+ have_start_obj=1
+fi
+
+MACHO_DSO_ARGS=()
+if [ "$TEST_OBJ" = "macho" ] && command -v xcrun >/dev/null 2>&1; then
+ sdk="$(xcrun --show-sdk-path 2>/dev/null || true)"
+ if [ -n "$sdk" ] && [ -f "$sdk/usr/lib/libSystem.tbd" ]; then
+ MACHO_DSO_ARGS=(--dso "$sdk/usr/lib/libSystem.tbd")
fi
fi
@@ -157,13 +173,12 @@ for wat in "$CASES_DIR"/*.wat; do
note_skip "$name/J" "host arch does not match target or no jit-runner"
fi
- if [ "$TEST_OBJ" = "elf" ] && [ "$have_link_runner" -eq 1 ] &&
- [ "$have_start_obj" -eq 1 ]; then
+ if [ "$have_link_runner" -eq 1 ] && [ "$have_start_obj" -eq 1 ]; then
exe="$work/$name.exe"
- if "$LINK_EXE_RUNNER" -o "$exe" "$wat_obj" "$START_OBJ" \
+ if "$LINK_EXE_RUNNER" -o "$exe" "${MACHO_DSO_ARGS[@]}" "$wat_obj" "$START_OBJ" \
>"$work/link.out" 2>"$work/link.err"; then
- if exec_target_supported "$EXEC_ARCH"; then
- exec_target_run "$EXEC_ARCH" "$exe" "$work/exec.out" "$work/exec.err"
+ if exec_target_supported "$EXEC_TAG"; then
+ exec_target_run "$EXEC_TAG" "$exe" "$work/exec.out" "$work/exec.err"
rc=$RUN_RC
if [ "$rc" -eq "$expected" ]; then
note_pass "$name/E"
@@ -177,7 +192,7 @@ for wat in "$CASES_DIR"/*.wat; do
note_fail "$name/E link failed"
fi
else
- note_skip "$name/E" "requires ELF link runner and start.o"
+ note_skip "$name/E" "requires link runner and start.o"
fi
done