tobogganSe connecter

louise

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

71 lignes · 3202 octetsBrut · Historique
1#!/usr/bin/env bash
2# The runtime and the native programs on aarch64, under qemu (ADR 0011).
3#
4# Everything is compiled here, for aarch64 (rustc's target, clang
5# --target, lld), against an arm64 Fedora sysroot made once with podman in
6# target/arm64-sysroot. The aarch64 binaries then run through qemu: the
7# test binaries as cargo's runner, and the programs they build through the
8# kernel's binfmt handler.
9#
10# scripts/aarch64.sh run: the runtime's unit tests, then
11# every tests/run program natively (on
12# 4 then 1 threads), then again with
13# every parked actor hibernated
14# scripts/aarch64.sh --available exit 0 if this machine can run it
15#
16# Needs: podman, qemu-user-static with its binfmt handler (Fedora:
17# `sudo dnf install qemu-user-static && sudo systemctl restart
18# systemd-binfmt`), clang, lld and llvm-ar. Emulated, the native step takes
19# a few minutes.
20set -euo pipefail
21cd "$(dirname "$0")/.."
22
23TARGET=aarch64-unknown-linux-gnu
24IMAGE=registry.fedoraproject.org/fedora:44
25
26available() {
27 command -v podman >/dev/null && command -v qemu-aarch64-static >/dev/null &&
28 command -v clang >/dev/null && command -v ld.lld >/dev/null &&
29 command -v llvm-ar >/dev/null && [ -e /proc/sys/fs/binfmt_misc/qemu-aarch64 ]
30}
31
32if [ "${1:-}" = --available ]; then
33 available
34 exit
35fi
36if ! available; then
37 echo "aarch64.sh: needs podman, qemu-user-static (binfmt), clang, lld and llvm-ar" >&2
38 exit 1
39fi
40
41sysroot="$PWD/target/arm64-sysroot"
42if [ ! -e "$sysroot/usr/lib/ld-linux-aarch64.so.1" ] || [ ! -d "$sysroot/usr/lib/gcc" ]; then
43 echo "== making the arm64 sysroot (once)"
44 name="louise-arm64-sysroot-$$"
45 podman run --arch arm64 --name "$name" "$IMAGE" \
46 sh -c 'dnf -y -q install gcc glibc-devel >/dev/null'
47 rm -rf "$sysroot"
48 mkdir -p "$sysroot"
49 podman cp "$name:/usr" "$sysroot/usr"
50 podman rm -f "$name" >/dev/null
51 ln -sfn usr/lib64 "$sysroot/lib64"
52 ln -sfn usr/lib "$sysroot/lib"
53fi
54
55cross="--target=aarch64-linux-gnu --sysroot=$sysroot"
56export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=clang
57export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS="-C link-arg=--target=aarch64-linux-gnu -C link-arg=--sysroot=$sysroot -C link-arg=-fuse-ld=lld"
58export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="qemu-aarch64-static -L $sysroot"
59export CC_aarch64_unknown_linux_gnu=clang CFLAGS_aarch64_unknown_linux_gnu="$cross"
60export AR_aarch64_unknown_linux_gnu=llvm-ar
61# The programs the native tests build: clang for aarch64, linked by lld,
62# run by binfmt's qemu, which finds the dynamic loader in the sysroot.
63export LOUISE_CC=clang LOUISE_CFLAGS="$cross" LOUISE_LD=lld QEMU_LD_PREFIX="$sysroot"
64
65echo "== runtime unit tests (aarch64)"
66cargo test --quiet -p louise_rt --lib --target "$TARGET"
67cargo build --quiet -p louise_rt --target "$TARGET"
68echo "== tests/run natively (aarch64, 4 then 1 threads)"
69cargo test --quiet -p louise_codegen_c --test native --target "$TARGET"
70echo "== tests/run natively, every parked actor hibernated (aarch64)"
71LOUISE_PARKED_EPOCH_MS=0 cargo test --quiet -p louise_codegen_c --test native --target "$TARGET"