|
| 1 | +#!/usr/bin/env sh |
| 2 | + |
| 3 | +set -ex |
| 4 | + |
| 5 | +: "${TARGET?The TARGET environment variable must be set.}" |
| 6 | + |
| 7 | +# Tests are all super fast anyway, and they fault often enough on travis that |
| 8 | +# having only one thread increases debuggability to be worth it. |
| 9 | +#export RUST_BACKTRACE=full |
| 10 | +#export RUST_TEST_NOCAPTURE=1 |
| 11 | +#export RUST_TEST_THREADS=1 |
| 12 | + |
| 13 | +export RUSTFLAGS="${RUSTFLAGS} -D warnings -Z merge-functions=disabled -Z verify-llvm-ir" |
| 14 | +export HOST_RUSTFLAGS="${RUSTFLAGS}" |
| 15 | +export PROFILE="${PROFILE:="--profile=release"}" |
| 16 | + |
| 17 | +case ${TARGET} in |
| 18 | + # On 32-bit use a static relocation model which avoids some extra |
| 19 | + # instructions when dealing with static data, notably allowing some |
| 20 | + # instruction assertion checks to pass below the 20 instruction limit. If |
| 21 | + # this is the default, dynamic, then too many instructions are generated |
| 22 | + # when we assert the instruction for a function and it causes tests to fail. |
| 23 | + i686-* | i586-*) |
| 24 | + export RUSTFLAGS="${RUSTFLAGS} -C relocation-model=static" |
| 25 | + ;; |
| 26 | + # Some x86_64 targets enable by default more features beyond SSE2, |
| 27 | + # which cause some instruction assertion checks to fail. |
| 28 | + x86_64-*) |
| 29 | + export RUSTFLAGS="${RUSTFLAGS} -C target-feature=-sse3" |
| 30 | + ;; |
| 31 | + #Unoptimized build uses fast-isel which breaks with msa |
| 32 | + mips-* | mipsel-*) |
| 33 | + export RUSTFLAGS="${RUSTFLAGS} -C llvm-args=-fast-isel=false" |
| 34 | + ;; |
| 35 | + armv7-*eabihf | thumbv7-*eabihf) |
| 36 | + export RUSTFLAGS="${RUSTFLAGS} -Ctarget-feature=+neon" |
| 37 | + ;; |
| 38 | + # Some of our test dependencies use the deprecated `gcc` crates which |
| 39 | + # doesn't detect RISC-V compilers automatically, so do it manually here. |
| 40 | + riscv*) |
| 41 | + export RUSTFLAGS="${RUSTFLAGS} -Ctarget-feature=+zk,+zks,+zbb,+zbc" |
| 42 | + ;; |
| 43 | +esac |
| 44 | + |
| 45 | +echo "RUSTFLAGS=${RUSTFLAGS}" |
| 46 | +echo "OBJDUMP=${OBJDUMP}" |
| 47 | +echo "STDARCH_DISABLE_ASSERT_INSTR=${STDARCH_DISABLE_ASSERT_INSTR}" |
| 48 | +echo "STDARCH_TEST_EVERYTHING=${STDARCH_TEST_EVERYTHING}" |
| 49 | +echo "STDARCH_TEST_SKIP_FEATURE=${STDARCH_TEST_SKIP_FEATURE}" |
| 50 | +echo "STDARCH_TEST_SKIP_FUNCTION=${STDARCH_TEST_SKIP_FUNCTION}" |
| 51 | +echo "PROFILE=${PROFILE}" |
| 52 | + |
| 53 | +CORE_ARCH="--manifest-path=crates/core_arch/Cargo.toml" |
| 54 | +STDARCH_EXAMPLES="--manifest-path=examples/Cargo.toml" |
| 55 | +INTRINSIC_TEST="--manifest-path=crates/intrinsic-test/Cargo.toml" |
| 56 | + |
| 57 | +# Test targets compiled with extra features. |
| 58 | +case ${TARGET} in |
| 59 | + x86_64-unknown-linux-gnu) |
| 60 | + TEST_CPPFLAGS="-fuse-ld=lld -I/usr/include/x86_64-linux-gnu/" |
| 61 | + TEST_CXX_COMPILER="clang++" |
| 62 | + TEST_RUNNER="${CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER}" |
| 63 | + TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_x86.txt |
| 64 | + TEST_SAMPLE_INTRINSICS_PERCENTAGE=5 |
| 65 | + export STDARCH_DISABLE_ASSERT_INSTR=1 |
| 66 | + PATH="$PATH":"$(pwd)"/c_programs |
| 67 | + export PATH |
| 68 | + ;; |
| 69 | + x86_64* | i686*) |
| 70 | + export STDARCH_DISABLE_ASSERT_INSTR=1 |
| 71 | + |
| 72 | + ;; |
| 73 | + |
| 74 | + # Setup aarch64 & armv7 specific variables, the runner, along with some |
| 75 | + # tests to skip |
| 76 | + aarch64-unknown-linux-gnu*) |
| 77 | + TEST_CPPFLAGS="-fuse-ld=lld -I/usr/aarch64-linux-gnu/include/ -I/usr/aarch64-linux-gnu/include/c++/9/aarch64-linux-gnu/" |
| 78 | + TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_aarch64.txt |
| 79 | + TEST_CXX_COMPILER="clang++" |
| 80 | + TEST_RUNNER="${CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER}" |
| 81 | + ;; |
| 82 | + |
| 83 | + aarch64_be-unknown-linux-gnu*) |
| 84 | + TEST_CPPFLAGS="-fuse-ld=lld" |
| 85 | + TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_aarch64.txt |
| 86 | + TEST_CXX_COMPILER="clang++" |
| 87 | + TEST_RUNNER="${CARGO_TARGET_AARCH64_BE_UNKNOWN_LINUX_GNU_RUNNER}" |
| 88 | + ;; |
| 89 | + |
| 90 | + armv7-unknown-linux-gnueabihf*) |
| 91 | + TEST_CPPFLAGS="-fuse-ld=lld -I/usr/arm-linux-gnueabihf/include/ -I/usr/arm-linux-gnueabihf/include/c++/9/arm-linux-gnueabihf/" |
| 92 | + TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_arm.txt |
| 93 | + TEST_CXX_COMPILER="clang++" |
| 94 | + TEST_RUNNER="${CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_RUNNER}" |
| 95 | + ;; |
| 96 | + *) |
| 97 | + ;; |
| 98 | + |
| 99 | +esac |
| 100 | + |
| 101 | +# Arm specific |
| 102 | +case "${TARGET}" in |
| 103 | + aarch64-unknown-linux-gnu*|armv7-unknown-linux-gnueabihf*) |
| 104 | + CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" RUST_LOG=warn \ |
| 105 | + cargo run "${INTRINSIC_TEST}" "${PROFILE}" \ |
| 106 | + --bin intrinsic-test -- intrinsics_data/arm_intrinsics.json \ |
| 107 | + --runner "${TEST_RUNNER}" \ |
| 108 | + --cppcompiler "${TEST_CXX_COMPILER}" \ |
| 109 | + --skip "${TEST_SKIP_INTRINSICS}" \ |
| 110 | + --target "${TARGET}" |
| 111 | + ;; |
| 112 | + |
| 113 | + aarch64_be-unknown-linux-gnu*) |
| 114 | + CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" RUST_LOG=warn \ |
| 115 | + cargo run "${INTRINSIC_TEST}" "${PROFILE}" \ |
| 116 | + --bin intrinsic-test -- intrinsics_data/arm_intrinsics.json \ |
| 117 | + --runner "${TEST_RUNNER}" \ |
| 118 | + --cppcompiler "${TEST_CXX_COMPILER}" \ |
| 119 | + --skip "${TEST_SKIP_INTRINSICS}" \ |
| 120 | + --target "${TARGET}" \ |
| 121 | + --linker "${CARGO_TARGET_AARCH64_BE_UNKNOWN_LINUX_GNU_LINKER}" \ |
| 122 | + --cxx-toolchain-dir "${AARCH64_BE_TOOLCHAIN}" |
| 123 | + ;; |
| 124 | + |
| 125 | + x86_64-unknown-linux-gnu*) |
| 126 | + # `CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER` is not necessary for `intrinsic-test` |
| 127 | + # because the binary needs to run directly on the host. |
| 128 | + # Hence the use of `env -u`. |
| 129 | + env -u CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER \ |
| 130 | + CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" \ |
| 131 | + RUST_LOG=warn RUST_BACKTRACE=1 \ |
| 132 | + cargo run "${INTRINSIC_TEST}" "${PROFILE}" \ |
| 133 | + --bin intrinsic-test -- intrinsics_data/x86-intel.xml \ |
| 134 | + --runner "${TEST_RUNNER}" \ |
| 135 | + --skip "${TEST_SKIP_INTRINSICS}" \ |
| 136 | + --cppcompiler "${TEST_CXX_COMPILER}" \ |
| 137 | + --target "${TARGET}" \ |
| 138 | + --sample-percentage "${TEST_SAMPLE_INTRINSICS_PERCENTAGE}" |
| 139 | + ;; |
| 140 | + *) |
| 141 | + ;; |
| 142 | +esac |
0 commit comments