-
Notifications
You must be signed in to change notification settings - Fork 1k
/
build.sh
300 lines (268 loc) · 8.16 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
#!/usr/bin/env sh
# Checks that libc builds properly for all supported targets on a particular
# Rust version:
# The FILTER environment variable can be used to select which target(s) to build.
# For example: set FILTER to vxworks to select the targets that has vxworks in name
set -ex
: "${TOOLCHAIN?The TOOLCHAIN environment variable must be set.}"
: "${OS?The OS environment variable must be set.}"
RUST=${TOOLCHAIN}
echo "Testing Rust ${RUST} on ${OS}"
if [ "${TOOLCHAIN}" = "nightly" ] ; then
rustup component add rust-src
fi
test_target() {
BUILD_CMD="${1}"
TARGET="${2}"
NO_STD="${3}"
# If there is a std component, fetch it:
if [ "${NO_STD}" != "1" ]; then
# FIXME: rustup often fails to download some artifacts due to network
# issues, so we retry this N times.
N=5
n=0
until [ $n -ge $N ]
do
if rustup target add "${TARGET}" --toolchain "${RUST}" ; then
break
fi
n=$((n+1))
sleep 1
done
fi
# Test that libc builds without any default features (no libstd)
if [ "${NO_STD}" != "1" ]; then
cargo "+${RUST}" "${BUILD_CMD}" -vv --no-default-features --target "${TARGET}"
else
# FIXME: With `build-std` feature, `compiler_builtins` emits a lof of lint warnings.
RUSTFLAGS="-A improper_ctypes_definitions" cargo "+${RUST}" "${BUILD_CMD}" \
-Z build-std=core,alloc -vv --no-default-features --target "${TARGET}"
fi
# Test that libc builds with default features (e.g. libstd)
# if the target supports libstd
if [ "$NO_STD" != "1" ]; then
cargo "+${RUST}" "${BUILD_CMD}" -vv --target "${TARGET}"
else
RUSTFLAGS="-A improper_ctypes_definitions" cargo "+${RUST}" "${BUILD_CMD}" \
-Z build-std=core,alloc -vv --target "${TARGET}"
fi
# Test that libc builds with the `extra_traits` feature
if [ "${NO_STD}" != "1" ]; then
cargo "+${RUST}" "${BUILD_CMD}" -vv --no-default-features --target "${TARGET}" \
--features extra_traits
else
RUSTFLAGS="-A improper_ctypes_definitions" cargo "+${RUST}" "${BUILD_CMD}" \
-Z build-std=core,alloc -vv --no-default-features \
--target "${TARGET}" --features extra_traits
fi
# Test the 'const-extern-fn' feature on nightly
if [ "${RUST}" = "nightly" ]; then
if [ "${NO_STD}" != "1" ]; then
cargo "+${RUST}" "${BUILD_CMD}" -vv --no-default-features --target "${TARGET}" \
--features const-extern-fn
else
RUSTFLAGS="-A improper_ctypes_definitions" cargo "+${RUST}" "${BUILD_CMD}" \
-Z build-std=core,alloc -vv --no-default-features \
--target "${TARGET}" --features const-extern-fn
fi
fi
# Also test that it builds with `extra_traits` and default features:
if [ "$NO_STD" != "1" ]; then
cargo "+${RUST}" "${BUILD_CMD}" -vv --target "${TARGET}" \
--features extra_traits
else
RUSTFLAGS="-A improper_ctypes_definitions" cargo "+${RUST}" "${BUILD_CMD}" \
-Z build-std=core,alloc -vv --target "${TARGET}" \
--features extra_traits
fi
}
RUST_LINUX_TARGETS="\
aarch64-linux-android \
aarch64-unknown-linux-gnu \
arm-linux-androideabi \
arm-unknown-linux-gnueabi \
arm-unknown-linux-gnueabihf \
armv7-linux-androideabi \
armv7-unknown-linux-gnueabihf \
i586-unknown-linux-gnu \
i686-linux-android \
i686-unknown-freebsd \
i686-unknown-linux-gnu \
i686-unknown-linux-musl \
powerpc-unknown-linux-gnu \
powerpc64-unknown-linux-gnu \
powerpc64le-unknown-linux-gnu \
s390x-unknown-linux-gnu \
x86_64-unknown-freebsd \
x86_64-unknown-linux-gnu \
x86_64-unknown-linux-musl \
x86_64-unknown-netbsd \
"
# FIXME: builds of MIPS targets are currently broken on nightly.
# mips-unknown-linux-gnu \
# mips-unknown-linux-musl \
# mips64-unknown-linux-gnuabi64 \
# mips64el-unknown-linux-gnuabi64 \
# mipsel-unknown-linux-gnu \
# mipsel-unknown-linux-musl \
RUST_GT_1_13_LINUX_TARGETS="\
arm-unknown-linux-musleabi \
arm-unknown-linux-musleabihf \
armv7-unknown-linux-musleabihf \
sparc64-unknown-linux-gnu \
wasm32-unknown-emscripten \
x86_64-linux-android \
"
RUST_GT_1_19_LINUX_TARGETS="\
aarch64-unknown-linux-musl \
sparcv9-sun-solaris \
wasm32-unknown-unknown \
"
RUST_GT_1_24_LINUX_TARGETS="\
i586-unknown-linux-musl \
"
RUST_NIGHTLY_LINUX_TARGETS="\
aarch64-unknown-fuchsia \
armv5te-unknown-linux-gnueabi \
armv5te-unknown-linux-musleabi \
i686-pc-windows-gnu \
riscv64gc-unknown-linux-gnu \
wasm32-wasi \
x86_64-fortanix-unknown-sgx \
x86_64-unknown-fuchsia \
x86_64-pc-solaris \
x86_64-pc-windows-gnu \
x86_64-unknown-illumos \
x86_64-unknown-linux-gnux32 \
x86_64-unknown-redox \
"
RUST_APPLE_TARGETS="\
aarch64-apple-ios \
x86_64-apple-darwin \
x86_64-apple-ios \
"
RUST_NIGHTLY_APPLE_TARGETS="\
aarch64-apple-darwin \
"
# Must start with `x86_64-pc-windows-msvc` first.
RUST_NIGHTLY_WINDOWS_TARGETS="\
x86_64-pc-windows-msvc \
x86_64-pc-windows-gnu \
i686-pc-windows-msvc \
"
# The targets are listed here alphabetically
TARGETS=""
case "${OS}" in
linux*)
TARGETS="${RUST_LINUX_TARGETS}"
if [ "${RUST}" != "1.13.0" ]; then
TARGETS="${TARGETS} ${RUST_GT_1_13_LINUX_TARGETS}"
if [ "${RUST}" != "1.19.0" ]; then
TARGETS="${TARGETS} ${RUST_GT_1_19_LINUX_TARGETS}"
if [ "${RUST}" != "1.24.0" ]; then
TARGETS="${TARGETS} ${RUST_GT_1_24_LINUX_TARGETS}"
fi
fi
fi
if [ "${RUST}" = "nightly" ]; then
TARGETS="${TARGETS} ${RUST_NIGHTLY_LINUX_TARGETS}"
fi
;;
macos*)
TARGETS="${RUST_APPLE_TARGETS}"
if [ "${RUST}" = "nightly" ]; then
TARGETS="${TARGETS} ${RUST_NIGHTLY_APPLE_TARGETS}"
fi
;;
windows*)
TARGETS=${RUST_NIGHTLY_WINDOWS_TARGETS}
;;
*)
;;
esac
for TARGET in $TARGETS; do
if echo "$TARGET"|grep -q "$FILTER"; then
if [ "${OS}" = "windows" ]; then
TARGET="$TARGET" sh ./ci/install-rust.sh
test_target build "$TARGET"
else
test_target build "$TARGET"
fi
fi
done
# Targets which are not available via rustup and must be built with -Zbuild-std
RUST_LINUX_NO_CORE_TARGETS="\
aarch64-pc-windows-msvc \
aarch64-unknown-freebsd \
aarch64-unknown-hermit \
aarch64-unknown-netbsd \
aarch64-unknown-openbsd \
aarch64-wrs-vxworks \
armebv7r-none-eabi \
armebv7r-none-eabihf \
armv7-wrs-vxworks-eabihf \
armv7r-none-eabi \
armv7r-none-eabihf \
hexagon-unknown-linux-musl \
i586-pc-windows-msvc \
i686-pc-windows-msvc \
i686-unknown-haiku \
i686-unknown-netbsd \
i686-unknown-openbsd \
i686-wrs-vxworks \
mipsel-sony-psp \
mips64-unknown-linux-muslabi64 \
mips64el-unknown-linux-muslabi64 \
nvptx64-nvidia-cuda \
powerpc-unknown-linux-gnuspe \
powerpc-unknown-netbsd \
powerpc-wrs-vxworks \
powerpc-wrs-vxworks-spe \
powerpc64-unknown-freebsd \
powerpc64-wrs-vxworks \
riscv32i-unknown-none-elf \
riscv32imac-unknown-none-elf \
riscv32imc-unknown-none-elf \
riscv32gc-unknown-linux-gnu \
riscv64gc-unknown-freebsd \
riscv64gc-unknown-hermit \
riscv64gc-unknown-linux-musl \
riscv64gc-unknown-none-elf \
riscv64imac-unknown-none-elf \
s390x-unknown-linux-musl \
sparc-unknown-linux-gnu \
sparc64-unknown-netbsd \
thumbv6m-none-eabi \
thumbv7em-none-eabi \
thumbv7em-none-eabihf \
thumbv7m-none-eabi \
thumbv7neon-linux-androideabi \
thumbv7neon-unknown-linux-gnueabihf \
thumbv8m.main-none-eabi \
x86_64-pc-windows-msvc \
x86_64-unknown-dragonfly \
x86_64-unknown-haiku \
x86_64-unknown-hermit \
x86_64-unknown-l4re-uclibc \
x86_64-unknown-openbsd \
x86_64-wrs-vxworks \
"
if [ "${RUST}" = "nightly" ] && [ "${OS}" = "linux" ]; then
for TARGET in $RUST_LINUX_NO_CORE_TARGETS; do
if echo "$TARGET"|grep -q "$FILTER"; then
test_target build "$TARGET" 1
fi
done
fi
RUST_APPLE_NO_CORE_TARGETS="\
armv7s-apple-ios \
i686-apple-darwin \
i386-apple-ios \
"
if [ "${RUST}" = "nightly" ] && [ "${OS}" = "macos" ]; then
for TARGET in $RUST_APPLE_NO_CORE_TARGETS; do
if echo "$TARGET" | grep -q "$FILTER"; then
test_target build "$TARGET" 1
fi
done
fi