Skip to content

Commit 18b0977

Browse files
authored
Merge pull request #1941 from madhav-madhusoodanan/intrinsic-test-ci-modification
CI: Separate `intrinsic-test` from the other CI tests
2 parents 5c1f598 + 9d7cb2a commit 18b0977

File tree

4 files changed

+193
-51
lines changed

4 files changed

+193
-51
lines changed

.github/workflows/main.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,42 @@ jobs:
249249
env:
250250
TARGET: ${{ matrix.target.tuple }}
251251

252+
intrinsic-test:
253+
needs: [style]
254+
name: Intrinsic Test
255+
runs-on: ubuntu-latest
256+
strategy:
257+
matrix:
258+
target:
259+
- aarch64-unknown-linux-gnu
260+
- aarch64_be-unknown-linux-gnu
261+
- armv7-unknown-linux-gnueabihf
262+
- arm-unknown-linux-gnueabihf
263+
profile: [dev, release]
264+
include:
265+
- target: aarch64_be-unknown-linux-gnu
266+
build_std: true
267+
268+
steps:
269+
- uses: actions/checkout@v4
270+
- name: Install Rust
271+
run: |
272+
rustup update nightly --no-self-update
273+
rustup default nightly
274+
- run: rustup target add ${{ matrix.target }}
275+
if: ${{ (matrix.build_std || false) == false }}
276+
- run: |
277+
rustup component add rust-src
278+
echo "CARGO_UNSTABLE_BUILD_STD=std" >> $GITHUB_ENV
279+
if: ${{ matrix.build_std }}
280+
281+
# Configure some env vars based on matrix configuration
282+
- run: echo "PROFILE=--profile=${{ matrix.profile }}" >> $GITHUB_ENV
283+
- run: ./ci/intrinsic-test-docker.sh ${{ matrix.target }}
284+
if: ${{ !startsWith(matrix.target, 'thumb') }}
285+
env:
286+
TARGET: ${{ matrix.target }}
287+
252288
# Check that the generated files agree with the checked-in versions.
253289
check-stdarch-gen:
254290
needs: [style]
@@ -276,6 +312,7 @@ jobs:
276312
- docs
277313
- verify
278314
- test
315+
- intrinsic-test
279316
- check-stdarch-gen
280317
runs-on: ubuntu-latest
281318
# We need to ensure this job does *not* get skipped if its dependencies fail,

ci/intrinsic-test-docker.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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_DISABLE_ASSERT_INSTR \
35+
--env NOSTD \
36+
--env NORUN \
37+
--env RUSTFLAGS \
38+
--env CARGO_UNSTABLE_BUILD_STD \
39+
--volume "${HOME}/.cargo":/cargo \
40+
--volume "$(rustc --print sysroot)":/rust:ro \
41+
--volume "$(pwd)":/checkout:ro \
42+
--volume "$(pwd)"/target:/checkout/target \
43+
--volume "$(pwd)"/c_programs:/checkout/c_programs \
44+
--volume "$(pwd)"/rust_programs:/checkout/rust_programs \
45+
--init \
46+
--workdir /checkout \
47+
--privileged \
48+
stdarch \
49+
sh -c "HOME=/tmp PATH=\$PATH:/rust/bin exec ci/intrinsic-test.sh ${1}"
50+
}
51+
52+
if [ -z "$1" ]; then
53+
>&2 echo "No target specified!"
54+
exit 1
55+
else
56+
run "${1}"
57+
fi

ci/intrinsic-test.sh

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/usr/bin/env sh
2+
3+
set -ex
4+
5+
: "${TARGET?The TARGET environment variable must be set.}"
6+
7+
export RUSTFLAGS="${RUSTFLAGS} -D warnings -Z merge-functions=disabled -Z verify-llvm-ir"
8+
export HOST_RUSTFLAGS="${RUSTFLAGS}"
9+
export PROFILE="${PROFILE:="--profile=release"}"
10+
11+
case ${TARGET} in
12+
# On 32-bit use a static relocation model which avoids some extra
13+
# instructions when dealing with static data, notably allowing some
14+
# instruction assertion checks to pass below the 20 instruction limit. If
15+
# this is the default, dynamic, then too many instructions are generated
16+
# when we assert the instruction for a function and it causes tests to fail.
17+
i686-* | i586-*)
18+
export RUSTFLAGS="${RUSTFLAGS} -C relocation-model=static"
19+
;;
20+
# Some x86_64 targets enable by default more features beyond SSE2,
21+
# which cause some instruction assertion checks to fail.
22+
x86_64-*)
23+
export RUSTFLAGS="${RUSTFLAGS} -C target-feature=-sse3"
24+
;;
25+
#Unoptimized build uses fast-isel which breaks with msa
26+
mips-* | mipsel-*)
27+
export RUSTFLAGS="${RUSTFLAGS} -C llvm-args=-fast-isel=false"
28+
;;
29+
armv7-*eabihf | thumbv7-*eabihf)
30+
export RUSTFLAGS="${RUSTFLAGS} -Ctarget-feature=+neon"
31+
;;
32+
# Some of our test dependencies use the deprecated `gcc` crates which
33+
# doesn't detect RISC-V compilers automatically, so do it manually here.
34+
riscv*)
35+
export RUSTFLAGS="${RUSTFLAGS} -Ctarget-feature=+zk,+zks,+zbb,+zbc"
36+
;;
37+
esac
38+
39+
echo "RUSTFLAGS=${RUSTFLAGS}"
40+
echo "OBJDUMP=${OBJDUMP}"
41+
echo "PROFILE=${PROFILE}"
42+
43+
INTRINSIC_TEST="--manifest-path=crates/intrinsic-test/Cargo.toml"
44+
45+
# Test targets compiled with extra features.
46+
case ${TARGET} in
47+
# Setup aarch64 & armv7 specific variables, the runner, along with some
48+
# tests to skip
49+
aarch64-unknown-linux-gnu*)
50+
TEST_CPPFLAGS="-fuse-ld=lld -I/usr/aarch64-linux-gnu/include/ -I/usr/aarch64-linux-gnu/include/c++/9/aarch64-linux-gnu/"
51+
TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_aarch64.txt
52+
TEST_CXX_COMPILER="clang++"
53+
TEST_RUNNER="${CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER}"
54+
;;
55+
56+
aarch64_be-unknown-linux-gnu*)
57+
TEST_CPPFLAGS="-fuse-ld=lld"
58+
TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_aarch64.txt
59+
TEST_CXX_COMPILER="clang++"
60+
TEST_RUNNER="${CARGO_TARGET_AARCH64_BE_UNKNOWN_LINUX_GNU_RUNNER}"
61+
;;
62+
63+
armv7-unknown-linux-gnueabihf*)
64+
TEST_CPPFLAGS="-fuse-ld=lld -I/usr/arm-linux-gnueabihf/include/ -I/usr/arm-linux-gnueabihf/include/c++/9/arm-linux-gnueabihf/"
65+
TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_arm.txt
66+
TEST_CXX_COMPILER="clang++"
67+
TEST_RUNNER="${CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_RUNNER}"
68+
;;
69+
*)
70+
;;
71+
72+
esac
73+
74+
# Arm specific
75+
case "${TARGET}" in
76+
aarch64-unknown-linux-gnu*|armv7-unknown-linux-gnueabihf*)
77+
CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" RUST_LOG=warn \
78+
cargo run "${INTRINSIC_TEST}" "${PROFILE}" \
79+
--bin intrinsic-test -- intrinsics_data/arm_intrinsics.json \
80+
--runner "${TEST_RUNNER}" \
81+
--cppcompiler "${TEST_CXX_COMPILER}" \
82+
--skip "${TEST_SKIP_INTRINSICS}" \
83+
--target "${TARGET}"
84+
;;
85+
86+
aarch64_be-unknown-linux-gnu*)
87+
CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" RUST_LOG=warn \
88+
cargo run "${INTRINSIC_TEST}" "${PROFILE}" \
89+
--bin intrinsic-test -- intrinsics_data/arm_intrinsics.json \
90+
--runner "${TEST_RUNNER}" \
91+
--cppcompiler "${TEST_CXX_COMPILER}" \
92+
--skip "${TEST_SKIP_INTRINSICS}" \
93+
--target "${TARGET}" \
94+
--linker "${CARGO_TARGET_AARCH64_BE_UNKNOWN_LINUX_GNU_LINKER}" \
95+
--cxx-toolchain-dir "${AARCH64_BE_TOOLCHAIN}"
96+
;;
97+
*)
98+
;;
99+
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)