@@ -10,29 +10,27 @@ set -ex
10
10
: " ${TOOLCHAIN?The TOOLCHAIN environment variable must be set.} "
11
11
: " ${OS?The OS environment variable must be set.} "
12
12
13
- RUST=${TOOLCHAIN}
14
- VERBOSE=-v
13
+ rust=" $TOOLCHAIN "
15
14
16
- echo " Testing Rust ${RUST} on ${OS} "
15
+ echo " Testing Rust $rust on $OS "
17
16
18
- if [ " ${ TOOLCHAIN} " = " nightly" ] ; then
17
+ if [ " $TOOLCHAIN " = " nightly" ] ; then
19
18
rustup component add rust-src
20
19
fi
21
20
22
21
test_target () {
23
- BUILD_CMD =" ${1} "
24
- TARGET =" ${2} "
25
- NO_STD =" ${3} "
22
+ build_cmd =" ${1} "
23
+ target =" ${2} "
24
+ no_std =" ${3} "
26
25
27
26
# If there is a std component, fetch it:
28
- if [ " ${NO_STD } " != " 1" ]; then
27
+ if [ " ${no_std } " != " 1" ]; then
29
28
# FIXME: rustup often fails to download some artifacts due to network
30
29
# issues, so we retry this N times.
31
30
N=5
32
31
n=0
33
- until [ $n -ge $N ]
34
- do
35
- if rustup target add " ${TARGET} " --toolchain " ${RUST} " ; then
32
+ until [ $n -ge $N ]; do
33
+ if rustup target add " $target " --toolchain " $rust " ; then
36
34
break
37
35
fi
38
36
n=$(( n+ 1 ))
@@ -41,56 +39,75 @@ test_target() {
41
39
fi
42
40
43
41
# Test that libc builds without any default features (no std)
44
- if [ " ${NO_STD} " != " 1" ]; then
45
- cargo " +${RUST} " " ${BUILD_CMD} " " $VERBOSE " --no-default-features --target " ${TARGET} "
42
+ if [ " $no_std " != " 1" ]; then
43
+ cargo " +$rust " " $build_cmd " --no-default-features --target " $target "
46
44
else
47
45
# FIXME: With `build-std` feature, `compiler_builtins` emits a lof of lint warnings.
48
- RUSTFLAGS=" -A improper_ctypes_definitions" cargo " +${RUST} " " ${BUILD_CMD} " \
49
- -Z build-std=core,alloc " $VERBOSE " --no-default-features --target " ${TARGET} "
46
+ RUSTFLAGS=" -A improper_ctypes_definitions" \
47
+ cargo " +$rust " " $build_cmd " \
48
+ -Z build-std=core,alloc \
49
+ --no-default-features \
50
+ --target " $target "
50
51
fi
52
+
51
53
# Test that libc builds with default features (e.g. std)
52
54
# if the target supports std
53
- if [ " $NO_STD " != " 1" ]; then
54
- cargo " +${RUST} " " ${BUILD_CMD} " " $VERBOSE " --target " ${TARGET} "
55
+ if [ " $no_std " != " 1" ]; then
56
+ cargo " +$rust " " $build_cmd " --target " $target "
55
57
else
56
- RUSTFLAGS=" -A improper_ctypes_definitions" cargo " +${RUST} " " ${BUILD_CMD} " \
57
- -Z build-std=core,alloc " $VERBOSE " --target " ${TARGET} "
58
+ RUSTFLAGS=" -A improper_ctypes_definitions" \
59
+ cargo " +$rust " " ${build_cmd} " \
60
+ -Z build-std=core,alloc \
61
+ --target " $target "
58
62
fi
59
63
60
64
# Test that libc builds with the `extra_traits` feature
61
- if [ " ${NO_STD} " != " 1" ]; then
62
- cargo " +${RUST} " " ${BUILD_CMD} " " $VERBOSE " --no-default-features --target " ${TARGET} " \
63
- --features extra_traits
65
+ if [ " $no_std " != " 1" ]; then
66
+ cargo " +$rust " " $build_cmd " \
67
+ --no-default-features \
68
+ --features extra_traits \
69
+ --target " $target "
64
70
else
65
- RUSTFLAGS=" -A improper_ctypes_definitions" cargo " +${RUST} " " ${BUILD_CMD} " \
66
- -Z build-std=core,alloc " $VERBOSE " --no-default-features \
67
- --target " ${TARGET} " --features extra_traits
71
+ RUSTFLAGS=" -A improper_ctypes_definitions" \
72
+ cargo " +$rust " " $build_cmd " \
73
+ -Z build-std=core,alloc \
74
+ --no-default-features \
75
+ --features extra_traits \
76
+ --target " $target "
68
77
fi
69
78
70
79
# Test the 'const-extern-fn' feature on nightly
71
- if [ " ${RUST} " = " nightly" ]; then
72
- if [ " ${NO_STD} " != " 1" ]; then
73
- cargo " +${RUST} " " ${BUILD_CMD} " " $VERBOSE " --no-default-features --target " ${TARGET} " \
74
- --features const-extern-fn
80
+ if [ " ${rust} " = " nightly" ]; then
81
+ if [ " ${no_std} " != " 1" ]; then
82
+ cargo " +$rust " " $build_cmd " \
83
+ --no-default-features \
84
+ --features const-extern-fn \
85
+ --target " $target "
75
86
else
76
- RUSTFLAGS=" -A improper_ctypes_definitions" cargo " +${RUST} " " ${BUILD_CMD} " \
77
- -Z build-std=core,alloc " $VERBOSE " --no-default-features \
78
- --target " ${TARGET} " --features const-extern-fn
87
+ RUSTFLAGS=" -A improper_ctypes_definitions" \
88
+ cargo " +$rust " " $build_cmd " \
89
+ -Z build-std=core,alloc \
90
+ --no-default-features \
91
+ --features const-extern-fn \
92
+ --target " $target "
79
93
fi
80
94
fi
81
95
82
96
# Also test that it builds with `extra_traits` and default features:
83
- if [ " $NO_STD " != " 1" ]; then
84
- cargo " +${RUST} " " ${BUILD_CMD} " " $VERBOSE " --target " ${TARGET} " \
97
+ if [ " $no_std " != " 1" ]; then
98
+ cargo " +$rust " " $build_cmd " \
99
+ --target " $target " \
85
100
--features extra_traits
86
101
else
87
- RUSTFLAGS=" -A improper_ctypes_definitions" cargo " +${RUST} " " ${BUILD_CMD} " \
88
- -Z build-std=core,alloc " $VERBOSE " --target " ${TARGET} " \
102
+ RUSTFLAGS=" -A improper_ctypes_definitions" \
103
+ cargo " +$rust " " $build_cmd " \
104
+ -Z build-std=core,alloc \
105
+ --target " $target " \
89
106
--features extra_traits
90
107
fi
91
108
}
92
109
93
- RUST_LINUX_TARGETS =" \
110
+ rust_linux_targets =" \
94
111
aarch64-linux-android \
95
112
aarch64-unknown-linux-gnu \
96
113
arm-linux-androideabi \
@@ -113,24 +130,24 @@ x86_64-unknown-linux-musl \
113
130
x86_64-unknown-netbsd \
114
131
"
115
132
116
- RUST_GT_1_13_LINUX_TARGETS =" \
133
+ rust_gt_1_13_linux_targets =" \
117
134
arm-unknown-linux-musleabi \
118
135
arm-unknown-linux-musleabihf \
119
136
armv7-unknown-linux-musleabihf \
120
137
sparc64-unknown-linux-gnu \
121
138
wasm32-unknown-emscripten \
122
139
x86_64-linux-android \
123
140
"
124
- RUST_GT_1_19_LINUX_TARGETS =" \
141
+ rust_gt_1_19_linux_targets =" \
125
142
aarch64-unknown-linux-musl \
126
143
sparcv9-sun-solaris \
127
144
wasm32-unknown-unknown \
128
145
"
129
- RUST_GT_1_24_LINUX_TARGETS =" \
146
+ rust_gt_1_24_linux_targets =" \
130
147
i586-unknown-linux-musl \
131
148
"
132
149
133
- RUST_NIGHTLY_LINUX_TARGETS =" \
150
+ rust_nightly_linux_targets =" \
134
151
aarch64-unknown-fuchsia \
135
152
armv5te-unknown-linux-gnueabi \
136
153
armv5te-unknown-linux-musleabi \
@@ -145,75 +162,71 @@ x86_64-unknown-linux-gnux32 \
145
162
x86_64-unknown-redox \
146
163
"
147
164
148
- RUST_APPLE_TARGETS =" \
165
+ rust_apple_targets =" \
149
166
aarch64-apple-ios \
150
- x86_64-apple-darwin \
151
- x86_64-apple-ios \
152
167
"
153
168
154
- RUST_NIGHTLY_APPLE_TARGETS =" \
169
+ rust_nightly_apple_targets =" \
155
170
aarch64-apple-darwin \
156
171
"
157
172
158
173
# Must start with `x86_64-pc-windows-msvc` first.
159
- RUST_NIGHTLY_WINDOWS_TARGETS =" \
174
+ rust_nightly_windows_targets =" \
160
175
x86_64-pc-windows-msvc \
161
176
x86_64-pc-windows-gnu \
162
177
i686-pc-windows-msvc \
163
178
"
164
179
165
180
# The targets are listed here alphabetically
166
- TARGETS =" "
181
+ targets =" "
167
182
case " ${OS} " in
168
183
linux* )
169
- TARGETS =" ${RUST_LINUX_TARGETS} "
184
+ targets =" $rust_linux_targets "
170
185
171
- if [ " ${RUST} " != " 1.13.0" ]; then
172
- TARGETS =" ${TARGETS} ${RUST_GT_1_13_LINUX_TARGETS} "
173
- if [ " ${RUST} " != " 1.19.0" ]; then
174
- TARGETS =" ${TARGETS} ${RUST_GT_1_19_LINUX_TARGETS} "
175
- if [ " ${RUST } " != " 1.24.0" ]; then
176
- TARGETS =" ${TARGETS} ${RUST_GT_1_24_LINUX_TARGETS} "
186
+ if [ " $rust " != " 1.13.0" ]; then
187
+ targets =" $targets $rust_gt_1_13_linux_targets "
188
+ if [ " $rust " != " 1.19.0" ]; then
189
+ targets =" $targets $rust_gt_1_19_linux_targets "
190
+ if [ " ${rust } " != " 1.24.0" ]; then
191
+ targets =" $targets $rust_gt_1_24_linux_targets "
177
192
fi
178
193
fi
179
194
fi
180
195
181
- if [ " ${RUST} " = " nightly" ]; then
182
- TARGETS =" ${TARGETS} ${RUST_NIGHTLY_LINUX_TARGETS} "
196
+ if [ " $rust " = " nightly" ]; then
197
+ targets =" $targets $rust_nightly_linux_targets "
183
198
fi
184
199
185
200
;;
186
201
macos* )
187
- TARGETS =" ${RUST_APPLE_TARGETS} "
202
+ targets =" $rust_apple_targets "
188
203
189
- if [ " ${RUST} " = " nightly" ]; then
190
- TARGETS =" ${TARGETS} ${RUST_NIGHTLY_APPLE_TARGETS} "
204
+ if [ " $rust " = " nightly" ]; then
205
+ targets =" $targets $rust_nightly_apple_targets "
191
206
fi
192
207
193
208
;;
194
209
windows* )
195
- TARGETS=${RUST_NIGHTLY_WINDOWS_TARGETS}
196
-
197
- ;;
198
- * )
210
+ targets=${rust_nightly_windows_targets}
199
211
;;
212
+ * ) ;;
200
213
esac
201
214
202
- for TARGET in $TARGETS ; do
203
- if echo " $TARGET " | grep -q " $FILTER " ; then
215
+ for target in $targets ; do
216
+ if echo " $target " | grep -q " $FILTER " ; then
204
217
if [ " ${OS} " = " windows" ]; then
205
- TARGET=" $TARGET " sh ./ci/install-rust.sh
206
- test_target build " $TARGET "
218
+ TARGET=" $target " sh ./ci/install-rust.sh
219
+ test_target build " $target "
207
220
else
208
- test_target build " $TARGET "
221
+ test_target build " $target "
209
222
fi
210
223
fi
211
224
done
212
225
213
226
# Targets which are not available via rustup and must be built with -Zbuild-std
214
227
# FIXME(hexagon): hexagon-unknown-linux-musl should be tested but currently has
215
228
# duplicate symbol errors from `compiler_builtins`.
216
- RUST_LINUX_NO_CORE_TARGETS =" \
229
+ rust_linux_no_core_targets =" \
217
230
aarch64-pc-windows-msvc \
218
231
aarch64-unknown-freebsd \
219
232
aarch64-unknown-hermit \
@@ -239,7 +252,6 @@ mips64el-unknown-linux-gnuabi64 \
239
252
mips64el-unknown-linux-muslabi64 \
240
253
mipsel-unknown-linux-gnu \
241
254
mipsel-unknown-linux-musl \
242
- mipsel-sony-psp \
243
255
nvptx64-nvidia-cuda \
244
256
powerpc-unknown-linux-gnuspe \
245
257
powerpc-unknown-netbsd \
@@ -278,24 +290,24 @@ x86_64-unknown-openbsd \
278
290
x86_64-wrs-vxworks \
279
291
"
280
292
281
- if [ " ${RUST } " = " nightly" ] && [ " ${OS} " = " linux" ]; then
282
- for TARGET in $RUST_LINUX_NO_CORE_TARGETS ; do
283
- if echo " $TARGET " | grep -q " $FILTER " ; then
284
- test_target build " $TARGET " 1
293
+ if [ " ${rust } " = " nightly" ] && [ " ${OS} " = " linux" ]; then
294
+ for target in $rust_linux_no_core_targets ; do
295
+ if echo " $target " | grep -q " $FILTER " ; then
296
+ test_target build " $target " 1
285
297
fi
286
298
done
287
299
fi
288
300
289
- RUST_APPLE_NO_CORE_TARGETS =" \
301
+ rust_apple_no_core_targets =" \
290
302
armv7s-apple-ios \
291
303
i686-apple-darwin \
292
304
i386-apple-ios \
293
305
"
294
306
295
- if [ " ${RUST } " = " nightly" ] && [ " ${OS} " = " macos" ]; then
296
- for TARGET in $RUST_APPLE_NO_CORE_TARGETS ; do
297
- if echo " $TARGET " | grep -q " $FILTER " ; then
298
- test_target build " $TARGET " 1
307
+ if [ " ${rust } " = " nightly" ] && [ " ${OS} " = " macos" ]; then
308
+ for target in $rust_apple_no_core_targets ; do
309
+ if echo " $target " | grep -q " $FILTER " ; then
310
+ test_target build " $target " 1
299
311
fi
300
312
done
301
313
fi
0 commit comments