@@ -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
52
fi
47
53
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
- fi
54
+ # Test with expected combinations of features
55
+ $cmd
56
+ $cmd --features const-extern-fn
57
+ $cmd --features extra_traits
57
58
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
97
-
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=" \
@@ -200,9 +153,9 @@ for target in $targets; do
200
153
if echo " $target " | grep -q " $filter " ; then
201
154
if [ " ${OS} " = " windows" ]; then
202
155
TARGET=" $target " ./ci/install-rust.sh
203
- test_target build " $target "
156
+ test_target " $target "
204
157
else
205
- test_target build " $target "
158
+ test_target " $target "
206
159
fi
207
160
208
161
test_run=1
212
165
# Targets which are not available via rustup and must be built with -Zbuild-std
213
166
# FIXME(hexagon): hexagon-unknown-linux-musl should be tested but currently has
214
167
# duplicate symbol errors from `compiler_builtins`.
215
- rust_linux_no_core_targets =" \
168
+ rust_linux_no_dist_targets =" \
216
169
aarch64-pc-windows-msvc \
217
170
aarch64-unknown-freebsd \
218
171
aarch64-unknown-hermit \
@@ -277,7 +230,7 @@ x86_64-wrs-vxworks \
277
230
"
278
231
279
232
if [ " ${rust} " = " nightly" ] && [ " ${OS} " = " linux" ]; then
280
- for target in $rust_linux_no_core_targets ; do
233
+ for target in $rust_linux_no_dist_targets ; do
281
234
if echo " $target " | grep -q " $FILTER " ; then
282
235
test_target " $target " 1
283
236
fi
@@ -286,14 +239,14 @@ if [ "${rust}" = "nightly" ] && [ "${OS}" = "linux" ]; then
286
239
done
287
240
fi
288
241
289
- rust_apple_no_core_targets =" \
242
+ rust_apple_no_dist_targets =" \
290
243
armv7s-apple-ios \
291
244
i686-apple-darwin \
292
245
i386-apple-ios \
293
246
"
294
247
295
248
if [ " ${rust} " = " nightly" ] && [ " ${OS} " = " macos" ]; then
296
- for target in $rust_apple_no_core_targets ; do
249
+ for target in $rust_apple_no_dist_targets ; do
297
250
if echo " $target " | grep -q " $FILTER " ; then
298
251
test_target " $target " 1
299
252
fi
0 commit comments