Skip to content

Commit 0fa4388

Browse files
committed
Auto merge of #1263 - gnzlbg:no_core_build, r=gnzlbg
Test that targets without a shipping libcore / libstd build properly This PR tests that `libc` builds on targets that currently don't ship a `libcore`/`libstd` by cross-compiling to them from Linux and MacOSX using `Xargo`. This fixes the build on DragonflyBSD (superseeds #1237), Haiku, bitrig, and OpenBSD (superseeds #1259). cc @asomers @strangelittlemonkey @semarie
2 parents c2904a7 + a25a42b commit 0fa4388

File tree

13 files changed

+356
-470
lines changed

13 files changed

+356
-470
lines changed

.travis.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ matrix:
1414
- name: "Documentation"
1515
env: TARGET=x86_64-unknown-linux-gnu
1616
script: sh ci/dox.sh
17-
install: true
17+
install:
18+
- travis_retry rustup component add rust-src
19+
- travis_retry cargo install xargo
1820
stage: tools-and-build-and-tier1
1921
- name: "Shellcheck"
2022
install: true
@@ -48,7 +50,9 @@ matrix:
4850
script: sh ci/build.sh
4951
stage: tools-and-build-and-tier1
5052
rust: nightly
51-
install: true
53+
install:
54+
- travis_retry rustup component add rust-src
55+
- travis_retry cargo install xargo
5256
- name: "Build Stable Rust"
5357
script: sh ci/build.sh
5458
stage: tools-and-build-and-tier1

ci/build.sh

Lines changed: 67 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ OS=${TRAVIS_OS_NAME}
1111
echo "Testing Rust ${RUST} on ${OS}"
1212

1313
test_target() {
14-
TARGET="${1}"
14+
CARGO="${1}"
15+
TARGET="${2}"
16+
NO_STD="${3}"
1517

1618
opt=
1719
if [ "${TARGET}" = "x86_64-unknown-linux-gnux32" ]; then
@@ -22,31 +24,38 @@ test_target() {
2224
opt="--release"
2325
fi
2426

25-
NO_STD=
26-
case ${TARGET} in
27-
thumbv*)
28-
NO_STD=1
29-
;;
30-
esac
31-
32-
rustup target add "${TARGET}" --toolchain "${RUST}" || true
27+
# If there is a std component, fetch it:
28+
if [ "${NO_STD}" != "1" ]; then
29+
# FIXME: rustup often fails to download some artifacts due to network
30+
# issues, so we retry this N times.
31+
N=5
32+
n=0
33+
until [ $n -ge $N ]
34+
do
35+
if rustup target add "${TARGET}" --toolchain "${RUST}" ; then
36+
break
37+
fi
38+
n=$((n+1))
39+
sleep 1
40+
done
41+
fi
3342

3443
# Test that libc builds without any default features (no libstd)
35-
cargo "+${RUST}" build -vv $opt --no-default-features --target "${TARGET}"
44+
"$CARGO" "+${RUST}" build -vv $opt --no-default-features --target "${TARGET}"
3645

3746
# Test that libc builds with default features (e.g. libstd)
3847
# if the target supports libstd
3948
if [ "$NO_STD" != "1" ]; then
40-
cargo "+${RUST}" build -vv $opt --target "${TARGET}"
49+
"$CARGO" "+${RUST}" build -vv $opt --target "${TARGET}"
4150
fi
4251

4352
# Test that libc builds with the `extra_traits` feature
44-
cargo "+${RUST}" build -vv $opt --no-default-features --target "${TARGET}" \
53+
"$CARGO" "+${RUST}" build -vv $opt --no-default-features --target "${TARGET}" \
4554
--features extra_traits
4655

4756
# Also test that it builds with `extra_traits` and default features:
4857
if [ "$NO_STD" != "1" ]; then
49-
cargo "+${RUST}" build -vv $opt --target "${TARGET}" \
58+
"$CARGO" "+${RUST}" build -vv $opt --target "${TARGET}" \
5059
--features extra_traits
5160
fi
5261
}
@@ -103,24 +112,15 @@ x86_64-unknown-cloudabi \
103112

104113
RUST_NIGHTLY_LINUX_TARGETS="\
105114
aarch64-fuchsia \
106-
thumbv6m-none-eabi \
107-
thumbv7em-none-eabi \
108-
thumbv7em-none-eabihf \
109-
thumbv7m-none-eabi \
110-
thumbv7neon-linux-androideabi \
111-
thumbv7neon-unknown-linux-gnueabihf \
115+
armv5te-unknown-linux-gnueabi \
116+
armv5te-unknown-linux-musleabi \
117+
i686-pc-windows-gnu \
112118
x86_64-fortanix-unknown-sgx \
113119
x86_64-fuchsia \
120+
x86_64-pc-windows-gnu \
114121
x86_64-unknown-linux-gnux32 \
115122
x86_64-unknown-redox \
116123
"
117-
# FIXME: these do not have a rust-std component available
118-
# aarch64-unknown-cloudabi armv7-unknown-cloudabi-eabihf
119-
# i686-unknown-cloudabi powerpc-unknown-linux-gnuspe
120-
# sparc-unknown-linux-gnu mips-unknown-linux-uclib
121-
# i686-unknown-haiku mipsel-unknown-unknown-linux-uclib
122-
# sparc64-unknown-netbsd x86_64-unknown-bitrig x86_64-unknown-haiku
123-
# x86_64-unknown-openbsd i686-unknown-netbsd
124124

125125
RUST_OSX_TARGETS="\
126126
aarch64-apple-ios \
@@ -161,5 +161,45 @@ case "${OS}" in
161161
esac
162162

163163
for TARGET in $TARGETS; do
164-
test_target "$TARGET"
164+
test_target cargo "$TARGET"
165165
done
166+
167+
# FIXME: https://github.com/rust-lang/rust/issues/58564
168+
# sparc-unknown-linux-gnu
169+
RUST_LINUX_NO_CORE_TARGETS="\
170+
x86_64-unknown-dragonfly \
171+
aarch64-pc-windows-msvc \
172+
aarch64-unknown-cloudabi \
173+
armebv7r-none-eabi \
174+
armebv7r-none-eabihf \
175+
armv7-unknown-cloudabi-eabihf \
176+
armv7r-none-eabi \
177+
armv7r-none-eabihf \
178+
i586-pc-windows-msvc \
179+
i686-pc-windows-msvc \
180+
i686-unknown-cloudabi \
181+
i686-unknown-haiku \
182+
i686-unknown-netbsd \
183+
nvptx64-nvidia-cuda \
184+
powerpc-unknown-linux-gnuspe \
185+
riscv32imac-unknown-none-elf \
186+
riscv32imc-unknown-none-elf \
187+
sparc64-unknown-netbsd \
188+
thumbv6m-none-eabi \
189+
thumbv7em-none-eabi \
190+
thumbv7em-none-eabihf \
191+
thumbv7m-none-eabi \
192+
thumbv7neon-linux-androideabi \
193+
thumbv7neon-unknown-linux-gnueabihf \
194+
thumbv8m.main-none-eabi \
195+
x86_64-pc-windows-msvc
196+
x86_64-unknown-bitrig \
197+
x86_64-unknown-haiku \
198+
x86_64-unknown-openbsd
199+
"
200+
201+
if [ "${RUST}" = "nightly" ] && [ "${OS}" = "linux" ]; then
202+
for TARGET in $RUST_LINUX_NO_CORE_TARGETS; do
203+
test_target xargo "$TARGET" 1
204+
done
205+
fi

ci/dox.sh

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,30 @@ rm $PLATFORM_SUPPORT || true
2525
printf '### Platform-specific documentation\n' >> $PLATFORM_SUPPORT
2626

2727
while read -r target; do
28-
echo "documenting ${target}"
28+
echo "documenting ${target}"
2929

30-
#rustdoc -o "$TARGET_DOC_DIR/${target}" --target "${target}" src/lib.rs --cfg cross_platform_docs \
31-
# --crate-name libc
30+
case "${target}" in
31+
*apple*)
32+
# FIXME:
33+
# We can't build docs of apple targets from Linux yet.
34+
continue
35+
;;
36+
*)
37+
;;
38+
esac
3239

33-
echo "* [${target}](${target}/libc/index.html)" >> $PLATFORM_SUPPORT
40+
rustup target add "${target}" || true
41+
42+
# If cargo doc fails, then try xargo:
43+
if ! cargo doc --target "${target}" \
44+
--no-default-features --features extra_traits ; then
45+
xargo doc --target "${target}" \
46+
--no-default-features --features extra_traits
47+
fi
48+
49+
cp -r "target/${target}/doc" "${TARGET_DOC_DIR}/${target}"
50+
51+
echo "* [${target}](${target}/libc/index.html)" >> $PLATFORM_SUPPORT
3452
done < targets
3553

3654
# Replace <div class="platform_support"></div> with the contents of $PLATFORM_SUPPORT

0 commit comments

Comments
 (0)