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