| @@ -2,14 +2,27 @@ |
| 2 | 2 | # Helpers shared by bench.sh, bench-compile.sh, stress.sh and ci.sh. |
| 3 | 3 | # Sourced, not run; the caller has `cd`'d to the repository root. |
| 4 | 4 | |
| 5 | | −# Faster links with mold when it is installed (runners may lack it); |
| 6 | | −# override by setting RUSTFLAGS. LOUISE_NO_MOLD=1 skips this: a set |
| 7 | | −# RUSTFLAGS makes `cargo test --target` ignore the target's own |
| 8 | | −# rustflags (cargo quirk), which breaks the aarch64 cross link |
| 9 | | −# (scripts/aarch64.sh sets lld there). |
| 10 | | −if [ -z "${RUSTFLAGS:-}" ] && [ "${LOUISE_NO_MOLD:-0}" != 1 ] && command -v mold >/dev/null; then |
| 11 | | − export RUSTFLAGS="-C link-arg=-fuse-ld=mold" |
| 5 | +# Faster links with mold when it is installed (runners may lack it). |
| 6 | +# Target-scoped, never a global RUSTFLAGS: a global one makes cargo ignore |
| 7 | +# CARGO_TARGET_<triple>_RUSTFLAGS, which the aarch64 lane's lld/sysroot |
| 8 | +# flags need (found by WS-BC). LOUISE_NO_MOLD=1 opts out. |
| 9 | +# Scripts that set their own global RUSTFLAGS for a --target build |
| 10 | +# (runtime.sh's lto archive, tsan.sh, the loom lane) go through |
| 11 | +# without_mold: the scoped var would shadow their flags otherwise. |
| 12 | +LOUISE_MOLD_FLAGS="" |
| 13 | +if [ "${LOUISE_NO_MOLD:-0}" != 1 ] && command -v mold >/dev/null; then |
| 14 | + LOUISE_MOLD_FLAGS="-C link-arg=-fuse-ld=mold" |
| 15 | + LOUISE_MOLD_VAR="CARGO_TARGET_$(rustc -vV | sed -n 's/^host: //p' | tr 'a-z-.' 'A-Z__')_RUSTFLAGS" |
| 16 | + if [ -z "${!LOUISE_MOLD_VAR:-}" ]; then export "$LOUISE_MOLD_VAR=$LOUISE_MOLD_FLAGS"; fi |
| 17 | + export LOUISE_MOLD_VAR |
| 12 | 18 | fi |
| 19 | +export LOUISE_MOLD_FLAGS |
| 20 | + |
| 21 | +# without_mold CMD... — CMD builds with its own RUSTFLAGS for a --target: |
| 22 | +# run it with the scoped mold var cleared (its own flags then apply). |
| 23 | +without_mold() { |
| 24 | + if [ -n "${LOUISE_MOLD_VAR:-}" ]; then env -u "$LOUISE_MOLD_VAR" "$@"; else "$@"; fi |
| 25 | +} |
| 13 | 26 | |
| 14 | 27 | # heavy CMD... — on a shared host (LOUISE_CI_SHARED_HOST=1), run heavy lanes |
| 15 | 28 | # one at a time per machine, niced; ci.sh uses this, and standalone scripts |