|
1 | | -#!/usr/bin/env sh |
| 1 | +#!/usr/bin/env bash |
2 | 2 |
|
3 | 3 | set -ex |
4 | 4 |
|
@@ -36,7 +36,68 @@ if retry rustup component add rustfmt ; then |
36 | 36 | fi |
37 | 37 |
|
38 | 38 | if retry rustup component add clippy ; then |
39 | | - cargo clippy --all --tests --features serde,rayon -- -D warnings |
| 39 | + # we want all targets that have dedicated SIMD implementations, |
| 40 | + # plus one that uses the generic implementation, |
| 41 | + # since we can't lint cfg-disabled code |
| 42 | + TARGETS=() |
| 43 | + |
| 44 | + # associative array of cfgs from rustc |
| 45 | + declare -A CFG |
| 46 | + for cfg in $(rustc --print cfg); do |
| 47 | + # bash is very upset about quotes and equal signs in keys |
| 48 | + cfg="${cfg//\"/}" |
| 49 | + cfg="${cfg//=/_}" |
| 50 | + printf "\n%s\n" "$cfg" >&2 |
| 51 | + CFG["$cfg"]=1 |
| 52 | + done |
| 53 | + |
| 54 | + HOST_IS_GENERIC=1 |
| 55 | + |
| 56 | + # SSE2 |
| 57 | + if (( CFG[target_feature_sse2] && (CFG[target_arch_x86] || CFG[target_arch_x86_64]) )); then |
| 58 | + printf "\nHost target supports SSE2\n" >&2 |
| 59 | + TARGETS+=(--target "$(rustc --print host-tuple)") |
| 60 | + HOST_IS_GENERIC=0 |
| 61 | + elif retry rustup target add x86_64-unknown-linux-gnu; then |
| 62 | + printf "\nTesting x86_64-unknown-linux-gnu\n" >&2 |
| 63 | + TARGETS+=(--target x86_64-unknown-linux-gnu) |
| 64 | + fi |
| 65 | + |
| 66 | + # NEON |
| 67 | + if (( CFG[target_arch_aarch64] && CFG[target_feature_neon] && CFG[target_endian_little] )); then |
| 68 | + printf "\nHost target supports NEON\n" >&2 |
| 69 | + TARGETS+=(--target "$(rustc --print host-tuple)") |
| 70 | + HOST_IS_GENERIC=0 |
| 71 | + elif retry rustup target add aarch64-unknown-linux-gnu; then |
| 72 | + printf "\nTesting aarch64-unknown-linux-gnu\n" >&2 |
| 73 | + TARGETS+=(--target aarch64-unknown-linux-gnu) |
| 74 | + fi |
| 75 | + |
| 76 | + # LSX |
| 77 | + if (( CFG[target_arch_loongarch64] && CFG[target_feature_lsx] )); then |
| 78 | + printf "\nHost target supports LSX\n" >&2 |
| 79 | + TARGETS+=(--target "$(rustc --print host-tuple)") |
| 80 | + HOST_IS_GENERIC=0 |
| 81 | + elif retry rustup target add loongarch64-unknown-linux-gnu; then |
| 82 | + printf "\nTesting loongarch64-unknown-linux-gnu\n" >&2 |
| 83 | + TARGETS+=(--target loongarch64-unknown-linux-gnu) |
| 84 | + fi |
| 85 | + |
| 86 | + # Generic |
| 87 | + if (( HOST_IS_GENERIC )); then |
| 88 | + printf "\nHost target support is generic\n" >&2 |
| 89 | + TARGETS+=(--target "$(rustc --print host-tuple)") |
| 90 | + elif retry rustup target add i586-unknown-linux-gnu; then |
| 91 | + printf "\nTesting i586-unknown-linux-gnu\n" >&2 |
| 92 | + TARGETS+=(--target i586-unknown-linux-gnu) |
| 93 | + fi |
| 94 | + |
| 95 | + cargo clippy --all --tests --features serde,rayon "${TARGETS[@]}" -- -D warnings |
| 96 | + |
| 97 | + # check nightly too |
| 98 | + if rustc --version | grep --quiet nightly ; then |
| 99 | + cargo +nightly clippy --all --tests --features serde,rayon,nightly "${TARGETS[@]}" -- -D warnings |
| 100 | + fi |
40 | 101 | fi |
41 | 102 |
|
42 | 103 | if command -v taplo ; then |
|
0 commit comments