|  | 
|  | 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 | +INTRINSIC_TEST="--manifest-path=crates/intrinsic-test/Cargo.toml" | 
|  | 54 | + | 
|  | 55 | +# Test targets compiled with extra features. | 
|  | 56 | +case ${TARGET} in | 
|  | 57 | +    x86_64-unknown-linux-gnu) | 
|  | 58 | +        TEST_CPPFLAGS="-fuse-ld=lld -I/usr/include/x86_64-linux-gnu/" | 
|  | 59 | +        TEST_CXX_COMPILER="clang++" | 
|  | 60 | +        TEST_RUNNER="${CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER}" | 
|  | 61 | +        TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_x86.txt | 
|  | 62 | +        TEST_SAMPLE_INTRINSICS_PERCENTAGE=5 | 
|  | 63 | +        export STDARCH_DISABLE_ASSERT_INSTR=1 | 
|  | 64 | +        PATH="$PATH":"$(pwd)"/c_programs | 
|  | 65 | +        export PATH | 
|  | 66 | +        ;; | 
|  | 67 | +    x86_64* | i686*) | 
|  | 68 | +        export STDARCH_DISABLE_ASSERT_INSTR=1 | 
|  | 69 | + | 
|  | 70 | +        ;; | 
|  | 71 | + | 
|  | 72 | +    # Setup aarch64 & armv7 specific variables, the runner, along with some | 
|  | 73 | +    # tests to skip | 
|  | 74 | +    aarch64-unknown-linux-gnu*) | 
|  | 75 | +        TEST_CPPFLAGS="-fuse-ld=lld -I/usr/aarch64-linux-gnu/include/ -I/usr/aarch64-linux-gnu/include/c++/9/aarch64-linux-gnu/" | 
|  | 76 | +        TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_aarch64.txt | 
|  | 77 | +        TEST_CXX_COMPILER="clang++" | 
|  | 78 | +        TEST_RUNNER="${CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER}" | 
|  | 79 | +        ;; | 
|  | 80 | + | 
|  | 81 | +    aarch64_be-unknown-linux-gnu*) | 
|  | 82 | +        TEST_CPPFLAGS="-fuse-ld=lld" | 
|  | 83 | +        TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_aarch64.txt | 
|  | 84 | +        TEST_CXX_COMPILER="clang++" | 
|  | 85 | +        TEST_RUNNER="${CARGO_TARGET_AARCH64_BE_UNKNOWN_LINUX_GNU_RUNNER}" | 
|  | 86 | +        ;; | 
|  | 87 | + | 
|  | 88 | +    armv7-unknown-linux-gnueabihf*) | 
|  | 89 | +        TEST_CPPFLAGS="-fuse-ld=lld -I/usr/arm-linux-gnueabihf/include/ -I/usr/arm-linux-gnueabihf/include/c++/9/arm-linux-gnueabihf/" | 
|  | 90 | +        TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_arm.txt | 
|  | 91 | +        TEST_CXX_COMPILER="clang++" | 
|  | 92 | +        TEST_RUNNER="${CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_RUNNER}" | 
|  | 93 | +        ;; | 
|  | 94 | +    *) | 
|  | 95 | +        ;; | 
|  | 96 | + | 
|  | 97 | +esac | 
|  | 98 | + | 
|  | 99 | +# Arm specific | 
|  | 100 | +case "${TARGET}" in | 
|  | 101 | +    aarch64-unknown-linux-gnu*|armv7-unknown-linux-gnueabihf*) | 
|  | 102 | +        CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" RUST_LOG=warn \ | 
|  | 103 | +            cargo run "${INTRINSIC_TEST}" "${PROFILE}" \ | 
|  | 104 | +            --bin intrinsic-test -- intrinsics_data/arm_intrinsics.json \ | 
|  | 105 | +            --runner "${TEST_RUNNER}" \ | 
|  | 106 | +            --cppcompiler "${TEST_CXX_COMPILER}" \ | 
|  | 107 | +            --skip "${TEST_SKIP_INTRINSICS}" \ | 
|  | 108 | +            --target "${TARGET}" | 
|  | 109 | +        ;; | 
|  | 110 | + | 
|  | 111 | +    aarch64_be-unknown-linux-gnu*) | 
|  | 112 | +        CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" RUST_LOG=warn \ | 
|  | 113 | +            cargo run "${INTRINSIC_TEST}" "${PROFILE}"  \ | 
|  | 114 | +            --bin intrinsic-test -- intrinsics_data/arm_intrinsics.json \ | 
|  | 115 | +            --runner "${TEST_RUNNER}" \ | 
|  | 116 | +            --cppcompiler "${TEST_CXX_COMPILER}" \ | 
|  | 117 | +            --skip "${TEST_SKIP_INTRINSICS}" \ | 
|  | 118 | +            --target "${TARGET}" \ | 
|  | 119 | +            --linker "${CARGO_TARGET_AARCH64_BE_UNKNOWN_LINUX_GNU_LINKER}" \ | 
|  | 120 | +            --cxx-toolchain-dir "${AARCH64_BE_TOOLCHAIN}" | 
|  | 121 | +        ;; | 
|  | 122 | + | 
|  | 123 | +    x86_64-unknown-linux-gnu*) | 
|  | 124 | +        # `CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER` is not necessary for `intrinsic-test` | 
|  | 125 | +        # because the binary needs to run directly on the host. | 
|  | 126 | +        # Hence the use of `env -u`. | 
|  | 127 | +        env -u CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER \ | 
|  | 128 | +            CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" \ | 
|  | 129 | +            RUST_LOG=warn RUST_BACKTRACE=1 \ | 
|  | 130 | +            cargo run "${INTRINSIC_TEST}" "${PROFILE}"  \ | 
|  | 131 | +            --bin intrinsic-test -- intrinsics_data/x86-intel.xml \ | 
|  | 132 | +            --runner "${TEST_RUNNER}" \ | 
|  | 133 | +            --skip "${TEST_SKIP_INTRINSICS}" \ | 
|  | 134 | +            --cppcompiler "${TEST_CXX_COMPILER}" \ | 
|  | 135 | +            --target "${TARGET}" \ | 
|  | 136 | +            --sample-percentage "${TEST_SAMPLE_INTRINSICS_PERCENTAGE}" | 
|  | 137 | +        ;; | 
|  | 138 | +     *) | 
|  | 139 | +        ;; | 
|  | 140 | +esac | 
0 commit comments