From 10470d794350dd42a5dc28c8d654cd622ca72a99 Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Wed, 19 Feb 2025 19:41:46 -0300 Subject: [PATCH 1/3] Makefile: add explicit target to test the x86_64 backend When developing on an arm64 machine, it's useful to be able to test the x86_64 target. --- Makefile | 3 +++ tools/test.sh | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/Makefile b/Makefile index f5e8a76..1a6f00a 100644 --- a/Makefile +++ b/Makefile @@ -71,6 +71,9 @@ clean-gen: clean check: qbe tools/test.sh all +check-x86_64: qbe + TARGET=x86_64 tools/test.sh all + check-arm64: qbe TARGET=arm64 tools/test.sh all diff --git a/tools/test.sh b/tools/test.sh index 23c6663..0eb6593 100755 --- a/tools/test.sh +++ b/tools/test.sh @@ -62,6 +62,30 @@ init() { fi bin="$bin -t rv64" ;; + x86_64|amd64) + for p in x86_64-linux-musl x86_64-linux-gnu + do + cc="$p-gcc -no-pie -static" + qemu="qemu-x86_64" + if + $cc -v >/dev/null 2>&1 && + $qemu -version >/dev/null 2>&1 + then + if sysroot=$($cc -print-sysroot) && test -n "$sysroot" + then + qemu="$qemu -L $sysroot" + fi + break + fi + cc= + done + if test -z "$cc" + then + echo "Cannot find x86_64 compiler or qemu." + exit 1 + fi + bin="$bin -t amd64_sysv" + ;; "") case `uname` in *Darwin*) -- 2.47.2