mirror of
https://github.com/Nexoniarz/Finch.git
synced 2026-11-03 00:44:27 +00:00
ARM64 and macOS: AAPCS64 struct passing, aarch64/macos targets, Apple frameworks and ld messages, tests/cross.sh, CI on ARM64 Linux and macOS
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
013b95d584
commit
484c14fe77
12 changed files with 256 additions and 78 deletions
|
|
@ -25,7 +25,7 @@ for f in tests/run/*.fch; do
|
|||
# (checked in the test and in the modules it imports)
|
||||
files="$f"
|
||||
for m in $(sed -n 's/^import \([a-z_]*\)$/\1/p' "$f"); do files="$files tests/run/$m.fch"; done
|
||||
if grep -qE '^import "|^link |\b(u8|u16|u32|u64|i8|i16|i32|f32|f64)\b|defer |0x' $files; then
|
||||
if grep -qE '^import "|^link |defer |0x' $files || grep -qwE 'u8|u16|u32|u64|i8|i16|i32|f32|f64' $files; then
|
||||
skipped=$((skipped + 1))
|
||||
continue
|
||||
fi
|
||||
|
|
|
|||
58
tests/cross.sh
Executable file
58
tests/cross.sh
Executable file
|
|
@ -0,0 +1,58 @@
|
|||
#!/usr/bin/env bash
|
||||
# Builds every test for another system and runs it there through an emulator:
|
||||
# tests/cross.sh windows x86_64-w64-mingw32, run with Wine
|
||||
# tests/cross.sh arm64 aarch64 Linux, run with qemu-aarch64
|
||||
# e.g. nix-shell -p pkgsCross.mingwW64.buildPackages.gcc wine64 --run 'tests/cross.sh windows'
|
||||
# nix-shell -p pkgsCross.aarch64-multiplatform.buildPackages.gcc qemu \
|
||||
# --run 'FINCH_CC=aarch64-unknown-linux-gnu-gcc tests/cross.sh arm64'
|
||||
# (On a real Windows/ARM64/macOS machine, use tests/run.sh with that system's finch.)
|
||||
set -u
|
||||
cd "$(dirname "$0")"
|
||||
target=${1:?usage: tests/cross.sh windows|arm64}
|
||||
FINCH=${FINCH:-../build/finch}
|
||||
export WINEDEBUG=-all
|
||||
case $target in
|
||||
windows) runner=wine; ext=.exe ;;
|
||||
arm64) runner=qemu-aarch64; ext= ;;
|
||||
*) echo "unknown target $target"; exit 2 ;;
|
||||
esac
|
||||
pass=0; failed=0
|
||||
tmp=$(mktemp -d)
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
|
||||
run_exe() { # program, stdin -> output without Windows' \r
|
||||
$runner "$1" < "$2" 2>&1 | tr -d '\r'
|
||||
}
|
||||
|
||||
for f in run/*.fch; do
|
||||
grep -q "^fn main" "$f" || continue
|
||||
input="${f%.fch}.in"
|
||||
[ -f "$input" ] || input=/dev/null
|
||||
exe="$tmp/$(basename "${f%.fch}")$ext"
|
||||
if ! "$FINCH" build "$f" --target "$target" -o "$exe" > "$tmp/err" 2>&1; then
|
||||
failed=$((failed + 1)); echo "FAIL (build) $f"; head -5 "$tmp/err"; continue
|
||||
fi
|
||||
got=$(run_exe "$exe" "$input")
|
||||
if [ "$got" == "$(tr -d '\r' < "${f%.fch}.out")" ]; then
|
||||
pass=$((pass + 1))
|
||||
else
|
||||
failed=$((failed + 1)); echo "FAIL $f"; diff <(echo "$got") "${f%.fch}.out" | head -10
|
||||
fi
|
||||
done
|
||||
|
||||
for f in fail/*.fch; do
|
||||
expect=$(head -1 "$f" | sed -n 's|^// expect: ||p')
|
||||
exe="$tmp/$(basename "${f%.fch}")$ext"
|
||||
if "$FINCH" build "$f" --target "$target" -o "$exe" > "$tmp/out" 2>&1; then
|
||||
got=$(run_exe "$exe" /dev/null)
|
||||
else
|
||||
got=$(cat "$tmp/out")
|
||||
fi
|
||||
if [[ "$got" == *"$expect"* ]]; then
|
||||
pass=$((pass + 1))
|
||||
else
|
||||
failed=$((failed + 1)); echo "FAIL $f (wanted: $expect)"; echo "$got" | head -5
|
||||
fi
|
||||
done
|
||||
echo "$target ($runner): $pass passed, $failed failed"
|
||||
[ $failed -eq 0 ]
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
# Cross-compiles every test for Windows (x86_64-w64-mingw32) and runs it under Wine.
|
||||
# Needs x86_64-w64-mingw32-gcc and wine, e.g.:
|
||||
# nix-shell -p pkgsCross.mingwW64.buildPackages.gcc wine64 --run tests/windows.sh
|
||||
# (On a real Windows machine, use tests/run.sh with finch.exe instead.)
|
||||
set -u
|
||||
cd "$(dirname "$0")"
|
||||
FINCH=${FINCH:-../build/finch}
|
||||
export WINEDEBUG=-all
|
||||
pass=0; failed=0
|
||||
tmp=$(mktemp -d)
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
|
||||
run_exe() { # exe, stdin -> output without Windows' \r
|
||||
wine "$1" < "$2" 2>&1 | tr -d '\r'
|
||||
}
|
||||
|
||||
for f in run/*.fch; do
|
||||
grep -q "^fn main" "$f" || continue
|
||||
input="${f%.fch}.in"
|
||||
[ -f "$input" ] || input=/dev/null
|
||||
exe="$tmp/$(basename "${f%.fch}").exe"
|
||||
if ! "$FINCH" build "$f" --target windows -o "$exe" > "$tmp/err" 2>&1; then
|
||||
failed=$((failed + 1)); echo "FAIL (build) $f"; head -5 "$tmp/err"; continue
|
||||
fi
|
||||
got=$(run_exe "$exe" "$input")
|
||||
if [ "$got" == "$(cat "${f%.fch}.out")" ]; then
|
||||
pass=$((pass + 1))
|
||||
else
|
||||
failed=$((failed + 1)); echo "FAIL $f"; diff <(echo "$got") "${f%.fch}.out" | head -10
|
||||
fi
|
||||
done
|
||||
|
||||
for f in fail/*.fch; do
|
||||
expect=$(head -1 "$f" | sed -n 's|^// expect: ||p')
|
||||
exe="$tmp/$(basename "${f%.fch}").exe"
|
||||
if got=$("$FINCH" build "$f" --target windows -o "$exe" 2>&1); then
|
||||
got=$(run_exe "$exe" /dev/null); status=$?
|
||||
status=$( [ -n "$got" ] && echo 1 || echo 0 )
|
||||
else
|
||||
status=1
|
||||
fi
|
||||
if [[ "$got" == *"$expect"* ]]; then
|
||||
pass=$((pass + 1))
|
||||
else
|
||||
failed=$((failed + 1)); echo "FAIL $f (wanted: $expect)"; echo "$got" | head -5
|
||||
fi
|
||||
done
|
||||
echo "windows (wine): $pass passed, $failed failed"
|
||||
[ $failed -eq 0 ]
|
||||
Loading…
Reference in a new issue