Modifies CI to pass profile to test tool

This commit is contained in:
reucru01
2025-10-24 10:15:30 +01:00
parent eb49e65e2a
commit 741f23f80e
9 changed files with 62 additions and 31 deletions
+2 -2
View File
@@ -220,7 +220,7 @@ jobs:
if: matrix.build_std != ''
# Configure some env vars based on matrix configuration
- run: echo "PROFILE=--profile=${{matrix.profile}}" >> $GITHUB_ENV
- run: echo "PROFILE=${{matrix.profile}}" >> $GITHUB_ENV
shell: bash
- run: echo "NORUN=1" >> $GITHUB_ENV
shell: bash
@@ -280,7 +280,7 @@ jobs:
if: ${{ matrix.build_std }}
# Configure some env vars based on matrix configuration
- run: echo "PROFILE=--profile=${{ matrix.profile }}" >> $GITHUB_ENV
- run: echo "PROFILE=${{ matrix.profile }}" >> $GITHUB_ENV
- run: ./ci/intrinsic-test-docker.sh ${{ matrix.target }}
if: ${{ !startsWith(matrix.target, 'thumb') }}
env:
@@ -30,6 +30,7 @@ run() {
--env CARGO_HOME=/cargo \
--env CARGO_TARGET_DIR=/checkout/target \
--env TARGET="${1}" \
--env PROFILE \
--env "${HOST_LINKER}"="cc" \
--env STDARCH_DISABLE_ASSERT_INSTR \
--env NOSTD \
+12 -9
View File
@@ -6,7 +6,7 @@ set -ex
export RUSTFLAGS="${RUSTFLAGS} -D warnings -Z merge-functions=disabled -Z verify-llvm-ir"
export HOST_RUSTFLAGS="${RUSTFLAGS}"
export PROFILE="${PROFILE:="--profile=release"}"
export PROFILE="${PROFILE:="release"}"
case ${TARGET} in
# On 32-bit use a static relocation model which avoids some extra
@@ -85,27 +85,29 @@ esac
# Arm specific
case "${TARGET}" in
aarch64-unknown-linux-gnu*|armv7-unknown-linux-gnueabihf*)
CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" RUST_LOG=info \
cargo run "${INTRINSIC_TEST}" "${PROFILE}" \
CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" RUST_LOG=warn \
cargo run "${INTRINSIC_TEST}" --release \
--bin intrinsic-test -- intrinsics_data/arm_intrinsics.json \
--runner "${TEST_RUNNER}" \
--cppcompiler "${TEST_CXX_COMPILER}" \
--skip "${TEST_SKIP_INTRINSICS}" \
--target "${TARGET}" \
--profile "${PROFILE}" \
--sample-percentage "${TEST_SAMPLE_INTRINSICS_PERCENTAGE}"
;;
aarch64_be-unknown-linux-gnu*)
CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" RUST_LOG=info \
cargo run "${INTRINSIC_TEST}" "${PROFILE}" \
CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" RUST_LOG=warn \
cargo run "${INTRINSIC_TEST}" --release \
--bin intrinsic-test -- intrinsics_data/arm_intrinsics.json \
--runner "${TEST_RUNNER}" \
--cppcompiler "${TEST_CXX_COMPILER}" \
--skip "${TEST_SKIP_INTRINSICS}" \
--target "${TARGET}" \
--sample-percentage "${TEST_SAMPLE_INTRINSICS_PERCENTAGE}" \
--profile "${PROFILE}" \
--linker "${CARGO_TARGET_AARCH64_BE_UNKNOWN_LINUX_GNU_LINKER}" \
--cxx-toolchain-dir "${AARCH64_BE_TOOLCHAIN}"
--cxx-toolchain-dir "${AARCH64_BE_TOOLCHAIN}" \
--sample-percentage "${TEST_SAMPLE_INTRINSICS_PERCENTAGE}"
;;
x86_64-unknown-linux-gnu*)
@@ -114,13 +116,14 @@ case "${TARGET}" in
# Hence the use of `env -u`.
env -u CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER \
CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" \
RUST_LOG=info RUST_BACKTRACE=1 \
cargo run "${INTRINSIC_TEST}" "${PROFILE}" \
RUST_LOG=warn RUST_BACKTRACE=1 \
cargo run "${INTRINSIC_TEST}" --release \
--bin intrinsic-test -- intrinsics_data/x86-intel.xml \
--runner "${TEST_RUNNER}" \
--skip "${TEST_SKIP_INTRINSICS}" \
--cppcompiler "${TEST_CXX_COMPILER}" \
--target "${TARGET}" \
--profile "${PROFILE}" \
--sample-percentage "${TEST_SAMPLE_INTRINSICS_PERCENTAGE}"
;;
*)
+1
View File
@@ -37,6 +37,7 @@ run() {
--env NORUN \
--env RUSTFLAGS \
--env CARGO_UNSTABLE_BUILD_STD \
--env PROFILE \
--volume "${HOME}/.cargo":/cargo \
--volume "$(rustc --print sysroot)":/rust:ro \
--volume "$(pwd)":/checkout:ro \
+15 -15
View File
@@ -12,7 +12,7 @@ set -ex
export RUSTFLAGS="${RUSTFLAGS} -D warnings -Z merge-functions=disabled -Z verify-llvm-ir"
export HOST_RUSTFLAGS="${RUSTFLAGS}"
export PROFILE="${PROFILE:="--profile=release"}"
export PROFILE="${PROFILE:="release"}"
case ${TARGET} in
# On Windows the linker performs identical COMDAT folding (ICF) by default
@@ -63,7 +63,7 @@ cargo_test() {
if [ "$NORUN" = "1" ]; then
export subcmd="build"
fi
cmd="$cmd ${subcmd} --target=$TARGET $1"
cmd="$cmd ${subcmd} --target=$TARGET --profile=$PROFILE $1"
cmd="$cmd -- $2"
case ${TARGET} in
@@ -80,10 +80,10 @@ cargo_test() {
CORE_ARCH="--manifest-path=crates/core_arch/Cargo.toml"
STDARCH_EXAMPLES="--manifest-path=examples/Cargo.toml"
cargo_test "${CORE_ARCH} ${PROFILE}"
cargo_test "${CORE_ARCH}"
if [ "$NOSTD" != "1" ]; then
cargo_test "${STDARCH_EXAMPLES} ${PROFILE}"
cargo_test "${STDARCH_EXAMPLES}"
fi
@@ -93,41 +93,41 @@ case ${TARGET} in
export STDARCH_DISABLE_ASSERT_INSTR=1
export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+avx"
cargo_test "${PROFILE}"
cargo_test
export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+avx512f"
cargo_test "${PROFILE}"
cargo_test
;;
x86_64* | i686*)
export STDARCH_DISABLE_ASSERT_INSTR=1
export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+avx"
cargo_test "${PROFILE}"
cargo_test
;;
# FIXME: don't build anymore
#mips-*gnu* | mipsel-*gnu*)
# export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+msa,+fp64,+mips32r5"
# cargo_test "${PROFILE}"
# cargo_test
# ;;
mips64*)
export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+msa"
cargo_test "${PROFILE}"
cargo_test
;;
s390x*)
export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+vector-enhancements-1"
cargo_test "${PROFILE}"
cargo_test
;;
powerpc64*)
export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+altivec"
cargo_test "${PROFILE}"
cargo_test
export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+vsx"
cargo_test "${PROFILE}"
cargo_test
;;
powerpc*)
# qemu has a bug in PPC32 which leads to a crash when compiled with `vsx`
export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+altivec"
cargo_test "${PROFILE}"
cargo_test
;;
*)
;;
@@ -138,7 +138,7 @@ if [ "$NORUN" != "1" ] && [ "$NOSTD" != 1 ]; then
# Test examples
(
cd examples
cargo test --target "$TARGET" "${PROFILE}"
echo test | cargo run --target "$TARGET" "${PROFILE}" hex
cargo test --target "${TARGET}" --profile "${PROFILE}"
echo test | cargo run --target "${TARGET}" --profile "${PROFILE}" hex
)
fi
@@ -41,6 +41,10 @@ pub struct Cli {
#[arg(long, default_value_t = String::from("armv7-unknown-linux-gnueabihf"))]
pub target: String,
/// Pass a profile (release, dev)
#[arg(long, default_value_t = String::from("release"))]
pub profile: String,
/// Set the linker
#[arg(long)]
pub linker: Option<String>,
@@ -59,6 +63,7 @@ pub struct ProcessedCli {
pub cpp_compiler: Option<String>,
pub runner: String,
pub target: String,
pub profile: String,
pub linker: Option<String>,
pub cxx_toolchain_dir: Option<String>,
pub skip: Vec<String>,
@@ -70,6 +75,7 @@ pub fn new(cli_options: Cli) -> Self {
let filename = cli_options.input;
let runner = cli_options.runner.unwrap_or_default();
let target = cli_options.target;
let profile = cli_options.profile;
let linker = cli_options.linker;
let cxx_toolchain_dir = cli_options.cxx_toolchain_dir;
let sample_percentage = cli_options.sample_percentage;
@@ -103,6 +109,7 @@ pub fn new(cli_options: Cli) -> Self {
cpp_compiler,
runner,
target,
profile,
linker,
cxx_toolchain_dir,
skip,
@@ -11,7 +11,17 @@ fn runner_command(runner: &str) -> Command {
cmd
}
pub fn compare_outputs(intrinsic_name_list: &Vec<String>, runner: &str, target: &str) -> bool {
pub fn compare_outputs(
intrinsic_name_list: &Vec<String>,
runner: &str,
target: &str,
profile: &str,
) -> bool {
let profile_dir = match profile {
"dev" => "debug",
_ => "release",
};
let (c, rust) = rayon::join(
|| {
runner_command(runner)
@@ -21,7 +31,9 @@ pub fn compare_outputs(intrinsic_name_list: &Vec<String>, runner: &str, target:
},
|| {
runner_command(runner)
.arg(format!("./target/{target}/release/intrinsic-test-programs"))
.arg(format!(
"./target/{target}/{profile_dir}/intrinsic-test-programs"
))
.current_dir("rust_programs")
.output()
},
@@ -140,7 +140,12 @@ pub fn write_lib_rs<T: IntrinsicTypeDefinition>(
Ok(())
}
pub fn compile_rust_programs(toolchain: Option<&str>, target: &str, linker: Option<&str>) -> bool {
pub fn compile_rust_programs(
toolchain: Option<&str>,
target: &str,
profile: &str,
linker: Option<&str>,
) -> bool {
/* If there has been a linker explicitly set from the command line then
* we want to set it via setting it in the RUSTFLAGS*/
@@ -161,7 +166,7 @@ pub fn compile_rust_programs(toolchain: Option<&str>, target: &str, linker: Opti
if toolchain.is_some_and(|val| !val.is_empty()) {
cargo_command.arg(toolchain.unwrap());
}
cargo_command.args(["build", "--target", target, "--release"]);
cargo_command.args(["build", "--target", target, "--profile", profile]);
let mut rust_flags = "-Cdebuginfo=0".to_string();
if let Some(linker) = linker {
@@ -146,6 +146,7 @@ fn build_rust_file(&self) -> bool {
.unwrap();
let target = &self.cli_options().target;
let profile = &self.cli_options().profile;
let toolchain = self.cli_options().toolchain.as_deref();
let linker = self.cli_options().linker.as_deref();
@@ -178,7 +179,7 @@ fn build_rust_file(&self) -> bool {
.collect::<Result<(), std::io::Error>>()
.unwrap();
compile_rust_programs(toolchain, target, linker)
compile_rust_programs(toolchain, target, profile, linker)
}
fn compare_outputs(&self) -> bool {
@@ -193,6 +194,7 @@ fn compare_outputs(&self) -> bool {
&intrinsics_name_list,
&self.cli_options().runner,
&self.cli_options().target,
&self.cli_options().profile,
)
} else {
true