@@ -20,14 +20,24 @@ if [ "$TOOLCHAIN" = "nightly" ] ; then
20
20
fi
21
21
22
22
test_target () {
23
- build_cmd=" ${1} "
24
- target=" ${2} "
25
- no_std=" ${3:- } "
23
+ target=" ${1} "
24
+ no_dist=" ${2:- 0} "
26
25
27
26
RUSTFLAGS=" ${RUSTFLAGS:- } "
28
27
29
- # If there is a std component, fetch it:
30
- if [ " ${no_std} " != " 1" ]; then
28
+ # The basic command that is run each time
29
+ cmd=" cargo +$rust build --target $target "
30
+
31
+ if [ " ${no_dist} " != " 0" ]; then
32
+ # If we can't download a `core`, we need to build it
33
+ cmd=" $cmd -Zbuild-std=core,alloc"
34
+
35
+ # FIXME: With `build-std` feature, `compiler_builtins` emits a lof of lint warnings.
36
+ RUSTFLAGS=" ${RUSTFLAGS:- } -Aimproper_ctypes_definitions"
37
+ export RUSTFLAGS
38
+ else
39
+ # Otherwise it is available for download; fetch it:
40
+
31
41
# FIXME: rustup often fails to download some artifacts due to network
32
42
# issues, so we retry this N times.
33
43
N=5
@@ -39,73 +49,16 @@ test_target() {
39
49
n=$(( n+ 1 ))
40
50
sleep 1
41
51
done
42
-
43
- # FIXME: With `build-std` feature, `compiler_builtins` emits a lof of lint warnings.
44
- RUSTFLAGS=" ${RUSTFLAGS:- } -Aimproper_ctypes_definitions"
45
- export RUSTFLAGS
46
- fi
47
-
48
- # Test that libc builds without any default features (no std)
49
- if [ " $no_std " != " 1" ]; then
50
- cargo " +$rust " " $build_cmd " --no-default-features --target " $target "
51
- else
52
- cargo " +$rust " " $build_cmd " \
53
- -Z build-std=core,alloc \
54
- --no-default-features \
55
- --target " $target "
56
52
fi
57
53
58
- # Test that libc builds with default features (e.g. std)
59
- # if the target supports std
60
- if [ " $no_std " != " 1" ]; then
61
- cargo " +$rust " " $build_cmd " --target " $target "
62
- else
63
- cargo " +$rust " " ${build_cmd} " \
64
- -Z build-std=core,alloc \
65
- --target " $target "
66
- fi
67
-
68
- # Test that libc builds with the `extra_traits` feature
69
- if [ " $no_std " != " 1" ]; then
70
- cargo " +$rust " " $build_cmd " \
71
- --no-default-features \
72
- --features extra_traits \
73
- --target " $target "
74
- else
75
- cargo " +$rust " " $build_cmd " \
76
- -Z build-std=core,alloc \
77
- --no-default-features \
78
- --features extra_traits \
79
- --target " $target "
80
- fi
81
-
82
- # Test the 'const-extern-fn' feature on nightly
83
- if [ " ${rust} " = " nightly" ]; then
84
- if [ " ${no_std} " != " 1" ]; then
85
- cargo " +$rust " " $build_cmd " \
86
- --no-default-features \
87
- --features const-extern-fn \
88
- --target " $target "
89
- else
90
- cargo " +$rust " " $build_cmd " \
91
- -Z build-std=core,alloc \
92
- --no-default-features \
93
- --features const-extern-fn \
94
- --target " $target "
95
- fi
96
- fi
54
+ # Test with expected combinations of features
55
+ $cmd
56
+ $cmd --features const-extern-fn
57
+ $cmd --features extra_traits
97
58
98
- # Also test that it builds with `extra_traits` and default features:
99
- if [ " $no_std " != " 1" ]; then
100
- cargo " +$rust " " $build_cmd " \
101
- --target " $target " \
102
- --features extra_traits
103
- else
104
- cargo " +$rust " " $build_cmd " \
105
- -Z build-std=core,alloc \
106
- --target " $target " \
107
- --features extra_traits
108
- fi
59
+ # Test again without default features, i.e. without "std"
60
+ $cmd --no-default-features
61
+ $cmd --no-default-features --features extra_traits
109
62
}
110
63
111
64
rust_linux_targets=" \
@@ -173,48 +126,10 @@ x86_64-pc-windows-gnu \
173
126
i686-pc-windows-msvc \
174
127
"
175
128
176
- # The targets are listed here alphabetically
177
- targets=" "
178
- case " ${OS} " in
179
- linux* )
180
- targets=" $rust_linux_targets "
181
-
182
- if [ " $rust " = " nightly" ]; then
183
- targets=" $targets $rust_nightly_linux_targets "
184
- fi
185
-
186
- ;;
187
- macos* )
188
- targets=" $rust_apple_targets "
189
-
190
- if [ " $rust " = " nightly" ]; then
191
- targets=" $targets $rust_nightly_apple_targets "
192
- fi
193
-
194
- ;;
195
- windows* )
196
- targets=${rust_nightly_windows_targets}
197
- ;;
198
- * ) ;;
199
- esac
200
-
201
- for target in $targets ; do
202
- if echo " $target " | grep -q " $filter " ; then
203
- if [ " ${OS} " = " windows" ]; then
204
- TARGET=" $target " ./ci/install-rust.sh
205
- test_target build " $target "
206
- else
207
- test_target build " $target "
208
- fi
209
-
210
- test_run=1
211
- fi
212
- done
213
-
214
129
# Targets which are not available via rustup and must be built with -Zbuild-std
215
130
# FIXME(hexagon): hexagon-unknown-linux-musl should be tested but currently has
216
131
# duplicate symbol errors from `compiler_builtins`.
217
- rust_linux_no_core_targets =" \
132
+ rust_linux_no_dist_targets =" \
218
133
aarch64-pc-windows-msvc \
219
134
aarch64-unknown-freebsd \
220
135
aarch64-unknown-hermit \
@@ -279,31 +194,69 @@ x86_64-unknown-openbsd \
279
194
x86_64-wrs-vxworks \
280
195
"
281
196
282
- if [ " ${rust} " = " nightly" ] && [ " ${OS} " = " linux" ]; then
283
- for target in $rust_linux_no_core_targets ; do
284
- if echo " $target " | grep -q " $FILTER " ; then
285
- test_target " $target " 1
286
- fi
287
-
288
- test_run=1
289
- done
290
- fi
291
-
292
- rust_apple_no_core_targets=" \
197
+ rust_apple_no_dist_targets=" \
293
198
armv7s-apple-ios \
294
199
i686-apple-darwin \
295
200
i386-apple-ios \
296
201
"
297
202
298
- if [ " ${rust} " = " nightly" ] && [ " ${OS} " = " macos" ]; then
299
- for target in $rust_apple_no_core_targets ; do
300
- if echo " $target " | grep -q " $FILTER " ; then
203
+ # The targets are listed here alphabetically
204
+ targets=" "
205
+ no_dist_targets=" "
206
+
207
+ case " ${OS} " in
208
+ linux* )
209
+ targets=" $rust_linux_targets "
210
+
211
+ if [ " $rust " = " nightly" ]; then
212
+ targets=" $targets $rust_nightly_linux_targets "
213
+ no_dist_targets=" $rust_linux_no_dist_targets "
214
+ fi
215
+
216
+ ;;
217
+ macos* )
218
+ targets=" $rust_apple_targets "
219
+
220
+ if [ " $rust " = " nightly" ]; then
221
+ targets=" $targets $rust_nightly_apple_targets "
222
+ no_dist_targets=" $rust_apple_no_dist_targets "
223
+ fi
224
+
225
+ ;;
226
+ windows* )
227
+ targets=${rust_nightly_windows_targets}
228
+ ;;
229
+ * )
230
+ echo " Unrecognized OS $OS "
231
+ exit 1
232
+ ;;
233
+ esac
234
+
235
+ for target in $targets ; do
236
+ if echo " $target " | grep -q " $filter " ; then
237
+ if [ " ${OS} " = " windows" ]; then
238
+ TARGET=" $target " ./ci/install-rust.sh
239
+ test_target " $target "
240
+ else
241
+ test_target " $target "
242
+ fi
243
+
244
+ test_run=1
245
+ fi
246
+ done
247
+
248
+ for target in $no_dist_targets ; do
249
+ if echo " $target " | grep -q " $filter " ; then
250
+ if [ " ${OS} " = " windows" ]; then
251
+ TARGET=" $target " ./ci/install-rust.sh
252
+ test_target " $target " 1
253
+ else
301
254
test_target " $target " 1
302
255
fi
303
256
304
257
test_run=1
305
- done
306
- fi
258
+ fi
259
+ done
307
260
308
261
# Make sure we didn't accidentally filter everything
309
262
if [ " ${test_run:- } " != 1 ]; then
0 commit comments