4747 fi
4848fi
4949
50-
51- declare -a rlib_paths
52-
53- # Set the `rlib_paths` global array to a list of all compiler-builtins rlibs
54- update_rlib_paths () {
50+ # Run a command for each `compiler_builtins` rlib file
51+ for_each_rlib () {
52+ shopt -s nullglob
5553 if [ -d /builtins-target ]; then
5654 rlib_paths=( /builtins-target/" ${target} " /debug/deps/libcompiler_builtins-* .rlib )
5755 else
58- rlib_paths=( target/" ${target} " /debug/deps/libcompiler_builtins-* .rlib )
56+ rlib_paths=( " ${SUBDIR:- } " target/" ${target} " /debug/deps/libcompiler_builtins-* .rlib )
57+ fi
58+
59+ if [ " ${# rlib_paths[@]} " -lt 1 ]; then
60+ echo " rlibs expected but not found"
61+ exit 1
5962 fi
63+
64+ for rlib in " ${rlib_paths[@]} " ; do
65+ " $@ " " $rlib "
66+ done
6067}
6168
6269# Remove any existing artifacts from previous tests that don't set #![compiler_builtins]
63- update_rlib_paths
64- rm -f " ${rlib_paths[@]} "
70+ for_each_rlib rm
6571
6672cargo build -p compiler_builtins --target " $target "
6773cargo build -p compiler_builtins --target " $target " --release
@@ -98,9 +104,9 @@ if [[ "$TOOLCHAIN" == *i686-pc-windows-gnu ]]; then
98104fi
99105
100106# Look out for duplicated symbols when we include the compiler-rt (C) implementation
101- update_rlib_paths
102- for rlib in " ${rlib_paths[@]} " ; do
107+ check_duplicate_symbols () {
103108 set +x
109+ rlib=" $1 "
104110 echo " ================================================================"
105111 echo " checking $rlib for duplicate symbols"
106112 echo " ================================================================"
@@ -122,9 +128,10 @@ for rlib in "${rlib_paths[@]}"; do
122128 else
123129 echo " success; no duplicate symbols found"
124130 fi
125- done
131+ }
126132
127- rm -f " ${rlib_paths[@]} "
133+ for_each_rlib check_duplicate_symbols
134+ for_each_rlib rm
128135
129136build_intrinsics_test () {
130137 cargo build \
@@ -144,9 +151,9 @@ CARGO_PROFILE_DEV_LTO=true build_intrinsics_test
144151CARGO_PROFILE_RELEASE_LTO=true build_intrinsics_test --release
145152
146153# Ensure no references to any symbols from core
147- update_rlib_paths
148- for rlib in " ${rlib_paths[@]} " ; do
154+ check_core_symbols () {
149155 set +x
156+ rlib=" $1 "
150157 echo " ================================================================"
151158 echo " checking $rlib for references to core"
152159 echo " ================================================================"
@@ -170,7 +177,9 @@ for rlib in "${rlib_paths[@]}"; do
170177 else
171178 echo " success; no references to core found"
172179 fi
173- done
180+ }
181+
182+ SUBDIR=" builtins-test-intrinsics/" for_each_rlib check_core_symbols
174183
175184# Test libm
176185
0 commit comments