mirror of
git://c9x.me/qbe.git
synced 2026-04-05 18:09:47 +00:00
tools/test.sh: test the native architecture without QEMU
While at it, extract most duplicated code across targets into a function.
This commit is contained in:
parent
f7ab20680b
commit
903610de4f
@ -16,26 +16,50 @@ asmref=$tmp.ref.s
|
|||||||
exe=$tmp.exe
|
exe=$tmp.exe
|
||||||
out=$tmp.out
|
out=$tmp.out
|
||||||
|
|
||||||
|
qemu_not_needed() {
|
||||||
|
"$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
cc=
|
||||||
|
find_cc_and_qemu() {
|
||||||
|
if [ -n "$cc" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
target="$1"
|
||||||
|
candidate_cc="$2"
|
||||||
|
if $candidate_cc -v >/dev/null 2>&1; then
|
||||||
|
cc=$candidate_cc
|
||||||
|
echo "cc: $cc"
|
||||||
|
|
||||||
|
if [ "$target" = "$(uname -m)" ]; then
|
||||||
|
qemu=qemu_not_needed
|
||||||
|
echo "qemu: not needed, testing native architecture"
|
||||||
|
else
|
||||||
|
qemu="$3"
|
||||||
|
if $qemu -version >/dev/null 2>&1; then
|
||||||
|
sysroot=$($candidate_cc -print-sysroot)
|
||||||
|
if [ -n "$sysroot" ]; then
|
||||||
|
qemu="$qemu -L $sysroot"
|
||||||
|
fi
|
||||||
|
echo "qemu: $qemu"
|
||||||
|
else
|
||||||
|
qemu=
|
||||||
|
echo "qemu: not found"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
case "$TARGET" in
|
case "$TARGET" in
|
||||||
arm64)
|
arm64)
|
||||||
for p in aarch64-linux-musl aarch64-linux-gnu
|
for p in aarch64-linux-musl aarch64-linux-gnu
|
||||||
do
|
do
|
||||||
cc="$p-gcc -no-pie -static"
|
find_cc_and_qemu aarch64 "$p-gcc -no-pie -static" "qemu-aarch64"
|
||||||
qemu="qemu-aarch64"
|
|
||||||
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
|
done
|
||||||
if test -z "$cc"
|
if test -z "$cc" -o -z "$qemu"
|
||||||
then
|
then
|
||||||
echo "Cannot find arm64 compiler or qemu."
|
echo "Cannot find arm64 compiler or qemu."
|
||||||
exit 77
|
exit 77
|
||||||
@ -45,21 +69,9 @@ init() {
|
|||||||
rv64)
|
rv64)
|
||||||
for p in riscv64-linux-musl riscv64-linux-gnu
|
for p in riscv64-linux-musl riscv64-linux-gnu
|
||||||
do
|
do
|
||||||
cc="$p-gcc -no-pie -static"
|
find_cc_and_qemu riscv64 "$p-gcc -no-pie -static" "qemu-riscv64"
|
||||||
qemu="qemu-riscv64"
|
|
||||||
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
|
done
|
||||||
if test -z "$cc"
|
if test -z "$cc" -o -z "$qemu"
|
||||||
then
|
then
|
||||||
echo "Cannot find riscv64 compiler or qemu."
|
echo "Cannot find riscv64 compiler or qemu."
|
||||||
exit 77
|
exit 77
|
||||||
@ -69,21 +81,9 @@ init() {
|
|||||||
x86_64)
|
x86_64)
|
||||||
for p in x86_64-linux-musl x86_64-linux-gnu
|
for p in x86_64-linux-musl x86_64-linux-gnu
|
||||||
do
|
do
|
||||||
cc="$p-gcc -no-pie -static"
|
find_cc_and_qemu x86_64 "$p-gcc -no-pie -static" "qemu-x86_64"
|
||||||
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
|
done
|
||||||
if test -z "$cc"
|
if test -z "$cc" -o -z "$qemu"
|
||||||
then
|
then
|
||||||
echo "Cannot find x86_64 compiler or qemu."
|
echo "Cannot find x86_64 compiler or qemu."
|
||||||
exit 77
|
exit 77
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user