47
47
fi
48
48
fi
49
49
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
55
53
if [ -d /builtins-target ]; then
56
54
rlib_paths=( /builtins-target/" ${target} " /debug/deps/libcompiler_builtins-* .rlib )
57
55
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
59
62
fi
63
+
64
+ for rlib in " ${rlib_paths[@]} " ; do
65
+ " $@ " " $rlib "
66
+ done
60
67
}
61
68
62
69
# 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
65
71
66
72
cargo build -p compiler_builtins --target " $target "
67
73
cargo build -p compiler_builtins --target " $target " --release
@@ -98,9 +104,9 @@ if [[ "$TOOLCHAIN" == *i686-pc-windows-gnu ]]; then
98
104
fi
99
105
100
106
# 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 () {
103
108
set +x
109
+ rlib=" $1 "
104
110
echo " ================================================================"
105
111
echo " checking $rlib for duplicate symbols"
106
112
echo " ================================================================"
@@ -122,9 +128,10 @@ for rlib in "${rlib_paths[@]}"; do
122
128
else
123
129
echo " success; no duplicate symbols found"
124
130
fi
125
- done
131
+ }
126
132
127
- rm -f " ${rlib_paths[@]} "
133
+ for_each_rlib check_duplicate_symbols
134
+ for_each_rlib rm
128
135
129
136
build_intrinsics_test () {
130
137
cargo build \
@@ -144,9 +151,9 @@ CARGO_PROFILE_DEV_LTO=true build_intrinsics_test
144
151
CARGO_PROFILE_RELEASE_LTO=true build_intrinsics_test --release
145
152
146
153
# Ensure no references to any symbols from core
147
- update_rlib_paths
148
- for rlib in " ${rlib_paths[@]} " ; do
154
+ check_core_symbols () {
149
155
set +x
156
+ rlib=" $1 "
150
157
echo " ================================================================"
151
158
echo " checking $rlib for references to core"
152
159
echo " ================================================================"
@@ -170,7 +177,9 @@ for rlib in "${rlib_paths[@]}"; do
170
177
else
171
178
echo " success; no references to core found"
172
179
fi
173
- done
180
+ }
181
+
182
+ SUBDIR=" builtins-test-intrinsics/" for_each_rlib check_core_symbols
174
183
175
184
# Test libm
176
185
0 commit comments