From f4db58d9edd430374453cb2729d22e9d4abf9275 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 28 May 2025 16:05:02 +0000 Subject: [PATCH 1/2] Simplify CI scripts that find `.rlib`s Switch from a global variable to a function that invokes a callback with each rlib file. This should be cleaner. This also fixes a bug where `check_core_symbols` is always passing since no files are found, because `builtins-test-intrinsics` has a separate target directory. --- ci/run.sh | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/ci/run.sh b/ci/run.sh index 68d13c130..c54cf61bf 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -47,21 +47,27 @@ else fi fi - -declare -a rlib_paths - -# Set the `rlib_paths` global array to a list of all compiler-builtins rlibs -update_rlib_paths() { +# Run a command for each `compiler_builtins` rlib file +for_each_rlib() { + shopt -s nullglob if [ -d /builtins-target ]; then rlib_paths=( /builtins-target/"${target}"/debug/deps/libcompiler_builtins-*.rlib ) else - rlib_paths=( target/"${target}"/debug/deps/libcompiler_builtins-*.rlib ) + rlib_paths=( "${SUBDIR:-}"target/"${target}"/debug/deps/libcompiler_builtins-*.rlib ) + fi + + if [ "${#rlib_paths[@]}" -lt 1 ]; then + echo "rlibs expected but not found" + exit 1 fi + + for rlib in "${rlib_paths[@]}"; do + "$@" "$rlib" + done } # Remove any existing artifacts from previous tests that don't set #![compiler_builtins] -update_rlib_paths -rm -f "${rlib_paths[@]}" +for_each_rlib rm cargo build -p compiler_builtins --target "$target" cargo build -p compiler_builtins --target "$target" --release @@ -98,9 +104,9 @@ if [[ "$TOOLCHAIN" == *i686-pc-windows-gnu ]]; then fi # Look out for duplicated symbols when we include the compiler-rt (C) implementation -update_rlib_paths -for rlib in "${rlib_paths[@]}"; do +check_duplicate_symbols() { set +x + rlib="$1" echo "================================================================" echo "checking $rlib for duplicate symbols" echo "================================================================" @@ -122,9 +128,10 @@ for rlib in "${rlib_paths[@]}"; do else echo "success; no duplicate symbols found" fi -done +} -rm -f "${rlib_paths[@]}" +for_each_rlib check_duplicate_symbols +for_each_rlib rm build_intrinsics_test() { cargo build \ @@ -144,9 +151,9 @@ CARGO_PROFILE_DEV_LTO=true build_intrinsics_test CARGO_PROFILE_RELEASE_LTO=true build_intrinsics_test --release # Ensure no references to any symbols from core -update_rlib_paths -for rlib in "${rlib_paths[@]}"; do +check_core_symbols() { set +x + rlib="$1" echo "================================================================" echo "checking $rlib for references to core" echo "================================================================" @@ -170,7 +177,9 @@ for rlib in "${rlib_paths[@]}"; do else echo "success; no references to core found" fi -done +} + +SUBDIR="builtins-test-intrinsics/" for_each_rlib check_core_symbols # Test libm From 9fdb5f5e98aa2bef0690d016e8c58eef91804df4 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 28 May 2025 16:46:00 +0000 Subject: [PATCH 2/2] update --- ci/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/run.sh b/ci/run.sh index c54cf61bf..c6bf13166 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -50,7 +50,7 @@ fi # Run a command for each `compiler_builtins` rlib file for_each_rlib() { shopt -s nullglob - if [ -d /builtins-target ]; then + if [ -d /builtins-target ] && [ -z "$SUBDIR" ]; then rlib_paths=( /builtins-target/"${target}"/debug/deps/libcompiler_builtins-*.rlib ) else rlib_paths=( "${SUBDIR:-}"target/"${target}"/debug/deps/libcompiler_builtins-*.rlib )