Skip to content

Commit 0a521ae

Browse files
committed
Harden macOS target checks
1 parent fbaf978 commit 0a521ae

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

scripts/check_macos.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ fi
88

99
host="$(rustc -vV | sed -n 's/^host: //p')"
1010
machine="$(uname -m)"
11+
toolchain="$(rustup show active-toolchain | sed 's/ .*//')"
1112

12-
echo "macOS checks: host=$host machine=$machine"
13+
echo "macOS checks: host=$host machine=$machine toolchain=$toolchain"
1314

1415
case "$host" in
1516
aarch64-apple-darwin|x86_64-apple-darwin)
@@ -46,9 +47,16 @@ echo "macOS checks: host clippy all features"
4647
cargo clippy --all-targets --all-features -- -D warnings
4748

4849
for target in aarch64-apple-darwin x86_64-apple-darwin; do
49-
if ! rustup target list --installed | grep -qx "$target"; then
50-
echo "macOS checks: installing missing Rust target $target"
51-
rustup target add "$target"
50+
if ! rustup target list --installed --toolchain "$toolchain" | grep -qx "$target"; then
51+
echo "macOS checks: installing missing Rust target $target for $toolchain"
52+
rustup target add --toolchain "$toolchain" "$target"
53+
fi
54+
55+
if ! rustc --target "$target" --print target-libdir >/dev/null 2>&1; then
56+
echo "macOS checks: Rust target $target is not usable for $toolchain" >&2
57+
echo "macOS checks: installed targets for $toolchain:" >&2
58+
rustup target list --installed --toolchain "$toolchain" >&2
59+
exit 1
5260
fi
5361

5462
echo "macOS checks: target compile all features for $target"

0 commit comments

Comments
 (0)