kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

commit df346d81fc94705392812053c1a029bbf7e0ed62
parent f2a928e2f8901aec26bed7d2a6465e505109c280
Author: Ryan Sepassi <rsepassi@gmail.com>
Date:   Sun, 10 May 2026 10:46:51 -0700

test: fix path-E exec on Darwin and trim default opt-levels

The MULTIARCH Phase 1 refactor (8f565be) introduced a "native" fast
path that returned true on Darwin/arm64 for aarch64 targets, so path E
ran linux/arm64 ELFs directly on the host instead of through podman.
Every cg path-E case failed with rc=126 ("Exec format error") and
podman was never invoked.

- exec_target.sh: split the predicate. _exec_target_native gates the
  on-host run (now requires uname -s = Linux); _exec_target_podman_native
  gates the --platform flag (arch-only, since the podman VM on
  Darwin/arm64 is already linux/arm64). Skipping --platform when the VM
  matches avoids the ~30s registry manifest lookup per `podman run`.
- test/cg/run.sh: drop opt-level 2 from the default set. Level 2's
  dry-run SSA construction is gated on user opt-in via
  CFREE_OPT_LEVELS="0 1 2".

Diffstat:
Mtest/cg/run.sh | 13++++++-------
Mtest/lib/exec_target.sh | 27++++++++++++++++++++-------
2 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/test/cg/run.sh b/test/cg/run.sh @@ -52,17 +52,16 @@ ALLOW_SKIP="${CFREE_TEST_ALLOW_SKIP:-0}" # $1 / CFREE_TEST_FILTER — substring match against case name # $2 / CFREE_TEST_PATHS — subset of "DREJ" (default "DREJ") # CFREE_OPT_LEVELS — space-separated opt levels to exercise. Default -# "0 1 2" so every case is built three ways: -# directly against the backend (level 0), and -# through the opt_cgtarget wrapper at levels 1 and -# 2. Level 2 currently runs the Phase 3 dry-run -# passes (build_cfg + build_ssa) and discards -# before replay, so behavior must match level 1. +# "0 1": directly against the backend (level 0) +# and through the opt_cgtarget wrapper (level 1). +# Level 2 (Phase 3 dry-run build_cfg + build_ssa, +# discarded before replay) is opt-in via +# CFREE_OPT_LEVELS="0 1 2". # Path W (DWARF) only runs at level 0 — opt-level # DWARF equivalence is a later phase concern. FILTER="${1:-${CFREE_TEST_FILTER:-}}" PATHS="${2:-${CFREE_TEST_PATHS:-DREJW}}" -OPT_LEVELS="${CFREE_OPT_LEVELS:-0 1 2}" +OPT_LEVELS="${CFREE_OPT_LEVELS:-0 1}" case "$PATHS" in *D*) RUN_D=1;; *) RUN_D=0;; esac case "$PATHS" in *R*) RUN_R=1;; *) RUN_R=0;; esac case "$PATHS" in *E*) RUN_E=1;; *) RUN_E=0;; esac diff --git a/test/lib/exec_target.sh b/test/lib/exec_target.sh @@ -74,11 +74,21 @@ _exec_target_image() { } _exec_target_native() { + # Targets are linux/<arch> ELFs; matching arch on a non-Linux host + # (e.g. Darwin/arm64) cannot load them, so require Linux too. + [ "$(uname -s 2>/dev/null)" = "Linux" ] || return 1 + _exec_target_podman_native "$1" +} + +# True when podman can run this target arch without emulation. The podman +# machine on Darwin/arm64 already runs linux/arm64, so passing `--platform +# linux/arm64` there is redundant — and worse, triggers a registry manifest +# lookup (~30 s) on every `podman run` even when the local image matches. +_exec_target_podman_native() { case "$1" in aarch64) [ "${is_aarch64:-0}" -eq 1 ] ;; - x64) [ "${is_aarch64:-0}" -eq 0 ] && \ - { [ "$(uname -m 2>/dev/null)" = "x86_64" ] || \ - [ "$(uname -m 2>/dev/null)" = "amd64" ]; } ;; + x64) [ "$(uname -m 2>/dev/null)" = "x86_64" ] || \ + [ "$(uname -m 2>/dev/null)" = "amd64" ] ;; *) return 1 ;; esac } @@ -117,9 +127,12 @@ exec_target_run() { platform="$(_exec_target_platform "$arch")" image="$(_exec_target_image "$arch")" # `--platform` triggers a registry manifest lookup (~30 s) even - # when the local image already matches. Only pass it on hosts - # that can't run the arch natively. - if ! _exec_target_native "$arch"; then + # when the local image already matches. Only pass it when podman + # would otherwise have to emulate — i.e. the podman machine's + # native arch differs from the target. (On Darwin/arm64 the + # podman VM is already linux/arm64, so aarch64 targets skip the + # flag even though the host can't load the ELF directly.) + if ! _exec_target_podman_native "$arch"; then platform_flag=(--platform "$platform") fi podman run --rm "${platform_flag[@]}" --net=none \ @@ -182,7 +195,7 @@ _exec_target_flush_arch() { local platform image platform_flag=() platform="$(_exec_target_platform "$arch")" image="$(_exec_target_image "$arch")" - if ! _exec_target_native "$arch"; then + if ! _exec_target_podman_native "$arch"; then platform_flag=(--platform "$platform") fi # Manifest is fed via stdin; one tab-separated line per case.