tobogganSe connecter

louise

The Louise language: compiler, runtime, std, tooling

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

40 lignes · 1594 octetsBrut · Historique
1#!/usr/bin/env bash
2# Build louise_rt as a staticlib and run the M0 ABI spike against it.
3# Usage: scripts/spike.sh [--release] [--asan]
4set -euo pipefail
5
6root="$(cd "$(dirname "$0")/.." && pwd)"
7profile=debug cargo_flags=() cflags=(-O2) target="$root/target"
8for arg in "$@"; do
9 case "$arg" in
10 --release) profile=release cargo_flags+=(--release) ;;
11 --asan)
12 cflags=(-O1 -g -fsanitize=address,undefined -fno-omit-frame-pointer)
13 # ASan sees only the system allocator's blocks: build the runtime
14 # without mimalloc, apart from the usual one.
15 target="$root/target/sanitize"
16 cargo_flags+=(--no-default-features --features stats --target-dir "$target") ;;
17 *) echo "unknown flag: $arg" >&2; exit 64 ;;
18 esac
19done
20
21# CARGO_TARGET_DIR relocates the build (ci.sh isolates the release
22# spike's and sweeps it: peak disk on a bounded runner store). --asan
23# already has its own.
24if [ -n "${CARGO_TARGET_DIR:-}" ] && [ "$target" = "$root/target" ]; then
25 case "$CARGO_TARGET_DIR" in
26 /*) target="$CARGO_TARGET_DIR" ;;
27 *) target="$root/$CARGO_TARGET_DIR" ;;
28 esac
29 cargo_flags+=(--target-dir "$target")
30fi
31
32cargo build --quiet -p louise_rt "${cargo_flags[@]}" --manifest-path "$root/Cargo.toml"
33mkdir -p "$root/build"
34cc="${CC:-cc}"
35[[ " ${cflags[*]} " == *sanitize* && -z "${CC:-}" ]] && cc=clang # gcc often lacks libasan
36"$cc" -std=c11 -Wall -Wextra -Werror "${cflags[@]}" \
37 -I "$root/runtime/louise_rt/include" \
38 "$root/runtime/spike/spike.c" "$target/$profile/liblouise_rt.a" \
39 -lpthread -ldl -lm -o "$root/build/spike"
40"$root/build/spike"