
louise
Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.
Dernier runRéussi#1197 · main · 10 min 35 s
1Étoiles
0Forks
0Issues
| 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. |
| 20 | set -euo pipefail |
| 21 | cd "$(dirname "$0")/.." |
| 22 | |
| 23 | TARGET=aarch64-unknown-linux-gnu |
| 24 | IMAGE=registry.fedoraproject.org/fedora:44 |
| 25 | |
| 26 | available() { |
| 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 | |
| 32 | if [ "${1:-}" = --available ]; then |
| 33 | available |
| 34 | exit |
| 35 | fi |
| 36 | if ! available; then |
| 37 | echo "aarch64.sh: needs podman, qemu-user-static (binfmt), clang, lld and llvm-ar" >&2 |
| 38 | exit 1 |
| 39 | fi |
| 40 | |
| 41 | sysroot="$PWD/target/arm64-sysroot" |
| 42 | if [ ! -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" |
| 53 | fi |
| 54 | |
| 55 | cross="--target=aarch64-linux-gnu --sysroot=$sysroot" |
| 56 | export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=clang |
| 57 | export 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" |
| 58 | export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="qemu-aarch64-static -L $sysroot" |
| 59 | export CC_aarch64_unknown_linux_gnu=clang CFLAGS_aarch64_unknown_linux_gnu="$cross" |
| 60 | export 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. |
| 63 | export LOUISE_CC=clang LOUISE_CFLAGS="$cross" LOUISE_LD=lld QEMU_LD_PREFIX="$sysroot" |
| 64 | |
| 65 | echo "== runtime unit tests (aarch64)" |
| 66 | cargo test --quiet -p louise_rt --lib --target "$TARGET" |
| 67 | cargo build --quiet -p louise_rt --target "$TARGET" |
| 68 | echo "== tests/run natively (aarch64, 4 then 1 threads)" |
| 69 | cargo test --quiet -p louise_codegen_c --test native --target "$TARGET" |
| 70 | echo "== tests/run natively, every parked actor hibernated (aarch64)" |
| 71 | LOUISE_PARKED_EPOCH_MS=0 cargo test --quiet -p louise_codegen_c --test native --target "$TARGET" |