Skip to content

Commit 0545cbe

Browse files
feat: separate intrinsic-test from the other CI pipelines
1 parent 8b51bf5 commit 0545cbe

File tree

4 files changed

+241
-51
lines changed

4 files changed

+241
-51
lines changed

.github/workflows/main.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,74 @@ jobs:
248248
if: matrix.target.os == 'ubuntu-latest' && !startsWith(matrix.target.tuple, 'thumb')
249249
env:
250250
TARGET: ${{ matrix.target.tuple }}
251+
252+
intrinsic-test:
253+
needs: [style]
254+
name: Intrinsic Test
255+
runs-on: ${{ matrix.target.os }}
256+
strategy:
257+
matrix:
258+
profile:
259+
- dev
260+
- release
261+
target:
262+
# Dockers that are run through docker on linux
263+
- tuple: arm-unknown-linux-gnueabihf
264+
os: ubuntu-latest
265+
- tuple: armv7-unknown-linux-gnueabihf
266+
os: ubuntu-latest
267+
- tuple: aarch64-unknown-linux-gnu
268+
os: ubuntu-latest
269+
- tuple: aarch64_be-unknown-linux-gnu
270+
os: ubuntu-latest
271+
272+
# Add additional variables to the matrix variations generated above using `include`:
273+
include:
274+
# `TEST_EVERYTHING` setups - there should be at least 1 for each architecture
275+
- target:
276+
tuple: aarch64-unknown-linux-gnu
277+
os: ubuntu-latest
278+
test_everything: true
279+
- target:
280+
tuple: aarch64_be-unknown-linux-gnu
281+
os: ubuntu-latest
282+
test_everything: true
283+
build_std: true
284+
- target:
285+
tuple: armv7-unknown-linux-gnueabihf
286+
os: ubuntu-latest
287+
test_everything: true
288+
289+
steps:
290+
- uses: actions/checkout@v4
291+
- name: Install Rust
292+
run: |
293+
rustup update nightly --no-self-update
294+
rustup default nightly
295+
shell: bash
296+
- run: rustup target add ${{ matrix.target.tuple }}
297+
shell: bash
298+
if: matrix.build_std == ''
299+
- run: |
300+
rustup component add rust-src
301+
echo "CARGO_UNSTABLE_BUILD_STD=std" >> $GITHUB_ENV
302+
shell: bash
303+
if: matrix.build_std != ''
304+
305+
# Configure some env vars based on matrix configuration
306+
- run: echo "PROFILE=--profile=${{matrix.profile}}" >> $GITHUB_ENV
307+
shell: bash
308+
- run: echo "STDARCH_TEST_EVERYTHING=1" >> $GITHUB_ENV
309+
shell: bash
310+
if: matrix.test_everything != ''
311+
- run: echo "STDARCH_DISABLE_ASSERT_INSTR=1" >> $GITHUB_ENV
312+
shell: bash
313+
if: matrix.disable_assert_instr != ''
314+
- run: ./ci/intrinsic-test-docker.sh ${{ matrix.target.tuple }}
315+
shell: bash
316+
if: matrix.target.os == 'ubuntu-latest' && !startsWith(matrix.target.tuple, 'thumb')
317+
env:
318+
TARGET: ${{ matrix.target.tuple }}
251319

252320
# Check that the generated files agree with the checked-in versions.
253321
check-stdarch-gen:
@@ -276,6 +344,7 @@ jobs:
276344
- docs
277345
- verify
278346
- test
347+
- intrinsic-test
279348
- check-stdarch-gen
280349
runs-on: ubuntu-latest
281350
# We need to ensure this job does *not* get skipped if its dependencies fail,

ci/intrinsic-test-docker.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env sh
2+
3+
# Small script to run tests for a target (or all targets) inside all the
4+
# respective docker images.
5+
6+
set -ex
7+
8+
if [ $# -lt 1 ]; then
9+
>&2 echo "Usage: $0 <TARGET>"
10+
exit 1
11+
fi
12+
13+
run() {
14+
# Set the linker that is used for the host (e.g. when compiling a build.rs)
15+
# This overrides any configuration in e.g. `.cargo/config.toml`, which will
16+
# probably not work within the docker container.
17+
HOST_LINKER="CARGO_TARGET_$(rustc --print host-tuple | tr '[:lower:]-' '[:upper:]_')_LINKER"
18+
19+
# Prevent `Read-only file system (os error 30)`.
20+
cargo generate-lockfile
21+
22+
echo "Building docker container for TARGET=${1}"
23+
docker build -t stdarch -f "ci/docker/${1}/Dockerfile" ci/
24+
mkdir -p target c_programs rust_programs
25+
echo "Running docker"
26+
# shellcheck disable=SC2016
27+
docker run \
28+
--rm \
29+
--user "$(id -u)":"$(id -g)" \
30+
--env CARGO_HOME=/cargo \
31+
--env CARGO_TARGET_DIR=/checkout/target \
32+
--env TARGET="${1}" \
33+
--env "${HOST_LINKER}"="cc" \
34+
--env STDARCH_TEST_EVERYTHING \
35+
--env STDARCH_DISABLE_ASSERT_INSTR \
36+
--env NOSTD \
37+
--env NORUN \
38+
--env RUSTFLAGS \
39+
--env CARGO_UNSTABLE_BUILD_STD \
40+
--volume "${HOME}/.cargo":/cargo \
41+
--volume "$(rustc --print sysroot)":/rust:ro \
42+
--volume "$(pwd)":/checkout:ro \
43+
--volume "$(pwd)"/target:/checkout/target \
44+
--volume "$(pwd)"/c_programs:/checkout/c_programs \
45+
--volume "$(pwd)"/rust_programs:/checkout/rust_programs \
46+
--init \
47+
--workdir /checkout \
48+
--privileged \
49+
stdarch \
50+
sh -c "HOME=/tmp PATH=\$PATH:/rust/bin exec ci/intrinsic-test.sh ${1}"
51+
}
52+
53+
if [ -z "$1" ]; then
54+
>&2 echo "No target specified!"
55+
exit 1
56+
else
57+
run "${1}"
58+
fi

ci/intrinsic-test.sh

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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+
58+
x86_64* | i686*)
59+
export STDARCH_DISABLE_ASSERT_INSTR=1
60+
;;
61+
62+
# Setup aarch64 & armv7 specific variables, the runner, along with some
63+
# tests to skip
64+
aarch64-unknown-linux-gnu*)
65+
TEST_CPPFLAGS="-fuse-ld=lld -I/usr/aarch64-linux-gnu/include/ -I/usr/aarch64-linux-gnu/include/c++/9/aarch64-linux-gnu/"
66+
TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_aarch64.txt
67+
TEST_CXX_COMPILER="clang++"
68+
TEST_RUNNER="${CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER}"
69+
;;
70+
71+
aarch64_be-unknown-linux-gnu*)
72+
TEST_CPPFLAGS="-fuse-ld=lld"
73+
TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_aarch64.txt
74+
TEST_CXX_COMPILER="clang++"
75+
TEST_RUNNER="${CARGO_TARGET_AARCH64_BE_UNKNOWN_LINUX_GNU_RUNNER}"
76+
;;
77+
78+
armv7-unknown-linux-gnueabihf*)
79+
TEST_CPPFLAGS="-fuse-ld=lld -I/usr/arm-linux-gnueabihf/include/ -I/usr/arm-linux-gnueabihf/include/c++/9/arm-linux-gnueabihf/"
80+
TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_arm.txt
81+
TEST_CXX_COMPILER="clang++"
82+
TEST_RUNNER="${CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_RUNNER}"
83+
;;
84+
*)
85+
;;
86+
87+
esac
88+
89+
# Arm specific
90+
case "${TARGET}" in
91+
aarch64-unknown-linux-gnu*|armv7-unknown-linux-gnueabihf*)
92+
CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" RUST_LOG=warn \
93+
cargo run "${INTRINSIC_TEST}" "${PROFILE}" \
94+
--bin intrinsic-test -- intrinsics_data/arm_intrinsics.json \
95+
--runner "${TEST_RUNNER}" \
96+
--cppcompiler "${TEST_CXX_COMPILER}" \
97+
--skip "${TEST_SKIP_INTRINSICS}" \
98+
--target "${TARGET}"
99+
;;
100+
101+
aarch64_be-unknown-linux-gnu*)
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+
--linker "${CARGO_TARGET_AARCH64_BE_UNKNOWN_LINUX_GNU_LINKER}" \
110+
--cxx-toolchain-dir "${AARCH64_BE_TOOLCHAIN}"
111+
;;
112+
*)
113+
;;
114+
esac

ci/run.sh

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ cargo_test() {
7979

8080
CORE_ARCH="--manifest-path=crates/core_arch/Cargo.toml"
8181
STDARCH_EXAMPLES="--manifest-path=examples/Cargo.toml"
82-
INTRINSIC_TEST="--manifest-path=crates/intrinsic-test/Cargo.toml"
8382

8483
cargo_test "${CORE_ARCH} ${PROFILE}"
8584

@@ -130,61 +129,11 @@ case ${TARGET} in
130129
export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+altivec"
131130
cargo_test "${PROFILE}"
132131
;;
133-
134-
# Setup aarch64 & armv7 specific variables, the runner, along with some
135-
# tests to skip
136-
aarch64-unknown-linux-gnu*)
137-
TEST_CPPFLAGS="-fuse-ld=lld -I/usr/aarch64-linux-gnu/include/ -I/usr/aarch64-linux-gnu/include/c++/9/aarch64-linux-gnu/"
138-
TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_aarch64.txt
139-
TEST_CXX_COMPILER="clang++"
140-
TEST_RUNNER="${CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER}"
141-
;;
142-
143-
aarch64_be-unknown-linux-gnu*)
144-
TEST_CPPFLAGS="-fuse-ld=lld"
145-
TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_aarch64.txt
146-
TEST_CXX_COMPILER="clang++"
147-
TEST_RUNNER="${CARGO_TARGET_AARCH64_BE_UNKNOWN_LINUX_GNU_RUNNER}"
148-
;;
149-
150-
armv7-unknown-linux-gnueabihf*)
151-
TEST_CPPFLAGS="-fuse-ld=lld -I/usr/arm-linux-gnueabihf/include/ -I/usr/arm-linux-gnueabihf/include/c++/9/arm-linux-gnueabihf/"
152-
TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_arm.txt
153-
TEST_CXX_COMPILER="clang++"
154-
TEST_RUNNER="${CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_RUNNER}"
155-
;;
156132
*)
157133
;;
158134

159135
esac
160136

161-
# Arm specific
162-
case "${TARGET}" in
163-
aarch64-unknown-linux-gnu*|armv7-unknown-linux-gnueabihf*)
164-
CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" RUST_LOG=warn \
165-
cargo run "${INTRINSIC_TEST}" "${PROFILE}" \
166-
--bin intrinsic-test -- intrinsics_data/arm_intrinsics.json \
167-
--runner "${TEST_RUNNER}" \
168-
--cppcompiler "${TEST_CXX_COMPILER}" \
169-
--skip "${TEST_SKIP_INTRINSICS}" \
170-
--target "${TARGET}"
171-
;;
172-
173-
aarch64_be-unknown-linux-gnu*)
174-
CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" RUST_LOG=warn \
175-
cargo run "${INTRINSIC_TEST}" "${PROFILE}" \
176-
--bin intrinsic-test -- intrinsics_data/arm_intrinsics.json \
177-
--runner "${TEST_RUNNER}" \
178-
--cppcompiler "${TEST_CXX_COMPILER}" \
179-
--skip "${TEST_SKIP_INTRINSICS}" \
180-
--target "${TARGET}" \
181-
--linker "${CARGO_TARGET_AARCH64_BE_UNKNOWN_LINUX_GNU_LINKER}" \
182-
--cxx-toolchain-dir "${AARCH64_BE_TOOLCHAIN}"
183-
;;
184-
*)
185-
;;
186-
esac
187-
188137
if [ "$NORUN" != "1" ] && [ "$NOSTD" != 1 ]; then
189138
# Test examples
190139
(

0 commit comments

Comments
 (0)