Skip to content

Commit 751b42e

Browse files
committed
Merge pull request #1 from alexcrichton/std-merge
Std merge
2 parents 242d3d3 + 038aedb commit 751b42e

32 files changed

+834
-80
lines changed

.travis.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ matrix:
3131
- os: linux
3232
env: TARGET=mips-unknown-linux-gnu
3333
rust: nightly-2015-09-08
34-
addons:
35-
apt:
36-
packages:
37-
- gcc-multilib
34+
- os: linux
35+
env: TARGET=aarch64-unknown-linux-gnu
36+
rust: nightly-2015-09-08
3837
notifications:
3938
email:
4039
on_success: never

ci/Dockerfile-android

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# This is a Dockerfile for building the image that is used to build Android
2+
# binaries and run tests within. This will install the NDK, SDK, and set up an
3+
# emulator to run tests in.
4+
15
FROM ubuntu:latest
26

37
RUN mkdir /build

ci/README.md

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
The goal of the libc crate is to have CI running everywhere to have the
2+
strongest guarantees about the definitions that this library contains, and as a
3+
result the CI is pretty complicated and also pretty large! Hopefully this can
4+
serve as a guide through the sea of scripts in this directory and elsewhere in
5+
this project.
6+
7+
# Files
8+
9+
First up, let's talk about the files in this directory:
10+
11+
* `Dockerfile-android`, `android-accept-licenses.sh` -- these two files are
12+
used to build the Docker image that the android CI builder uses. The
13+
`Dockerfile` just installs the Android SDK, NDK, a Rust nightly, Rust target
14+
libraries for Android, and sets up an emulator to run tests in. You can build
15+
a new image with this command (from the root of the project):
16+
17+
docker build -t alexcrichton/rust-libc-test -f ci/Dockerfile-android .
18+
19+
When building a new image contact @alexcrichton to push it to the docker hub
20+
and have libc start using it. This hasn't needed to happen yet, so the process
21+
may be a little involved.
22+
23+
The script here, `android-accept-licenses.sh` is just a helper used to accept
24+
the licenses of the SDK of Android while the docker image is being created.
25+
26+
* `msys2.ps1` - a PowerShell script which is used to install MSYS2 on the
27+
AppVeyor bots. As of this writing MSYS2 isn't installed by default, and this
28+
script will install the right version/arch of msys2 in preparation of using
29+
the contained C compiler to compile C shims.
30+
31+
* `run-travis.sh` - a shell script run by all Travis builders, this is
32+
responsible for setting up the rest of the environment such as installing new
33+
packages, downloading Rust target libraries, etc.
34+
35+
* `run.sh` - the actual script which runs tests for a particular architecture.
36+
Called from the `run-travis.sh` script this will run all tests for the target
37+
specified.
38+
39+
* `cargo-config` - Cargo configuration of linkers to use copied into place by
40+
the `run-travis.sh` script before builds are run.
41+
42+
* `dox.sh` - script called from `run-travis.sh` on only the linux 64-bit nightly
43+
Travis bots to build documentation for this crate.
44+
45+
* `landing-page-*.html` - used by `dox.sh` to generate a landing page for all
46+
architectures' documentation.
47+
48+
# CI Systems
49+
50+
Currently this repository leverages a combination of Travis CI and AppVeyor for
51+
running tests. The triples tested are:
52+
53+
* AppVeyor
54+
* `{i686,x86_64}-pc-windows-{msvc,gnu}`
55+
* Travis
56+
* `{i686,x86_64,mips,aarch64}-unknown-linux-gnu`
57+
* `x86_64-unknown-linux-musl`
58+
* `arm-unknown-linux-gnueabihf`
59+
* `arm-linux-androideabi`
60+
* `{i686,x86_64}-apple-darwin`
61+
62+
The Windows triples are all pretty standard, they just set up their environment
63+
then run tests, no need for downloading any extra target libs (we just download
64+
the right installer). The Intel Linux/OSX builds are similar in that we just
65+
download the right target libs and run tests. Note that the Intel Linux/OSX
66+
builds are run on stable/beta/nightly, but are the only ones that do so.
67+
68+
The remaining architectures look like:
69+
70+
* Android runs in a docker image with an emulator, the NDK, and the SDK already
71+
set up (see `Dockerfile-android`). The entire build happens within the docker
72+
image.
73+
* The MIPS, ARM, and AArch64 builds all use QEMU to run the generated binary to
74+
actually verify the tests pass.
75+
* The MUSL build just has to download a MUSL compiler and target libraries and
76+
then otherwise runs tests normally.
77+
78+
Hopefully that's at least somewhat of an introduction to everything going on
79+
here, and feel free to ping @alexcrichton with questions!
80+

ci/cargo-config

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Configuration of which linkers to call on Travis for various architectures
2+
13
[target.arm-linux-androideabi]
24
linker = "arm-linux-androideabi-gcc"
35

@@ -6,3 +8,6 @@ linker = "arm-linux-gnueabihf-gcc-4.7"
68

79
[target.mips-unknown-linux-gnu]
810
linker = "mips-linux-gnu-gcc"
11+
12+
[target.aarch64-unknown-linux-gnu]
13+
linker = "aarch64-linux-gnu-gcc"

ci/dox.sh

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
#!/bin/sh
22

3+
# Builds documentation for all target triples that we have a registered URL for
4+
# in liblibc. This scrapes the list of triples to document from `src/lib.rs`
5+
# which has a bunch of `html_root_url` directives we pick up.
6+
37
set -e
48

9+
TARGETS=`grep html_root_url src/lib.rs | sed 's/.*".*\/\(.*\)"/\1/'`
10+
511
rm -rf target/doc
612
mkdir -p target/doc
713

814
cp ci/landing-page-head.html target/doc/index.html
915

10-
TARGETS=`grep html_root_url src/lib.rs | sed 's/.*".*\/\(.*\)"/\1/'`
11-
1216
for target in $TARGETS; do
1317
echo documenting $target
1418

@@ -21,7 +25,8 @@ done
2125

2226
cat ci/landing-page-footer.html >> target/doc/index.html
2327

24-
if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "autotest" ]; then
28+
# If we're on travis, not a PR, and on the right branch, publish!
29+
if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "master" ]; then
2530
pip install ghp-import --user $USER
2631
$HOME/.local/bin/ghp-import -n target/doc
2732
git push -qf https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages

ci/msys2.ps1

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Installs MSYS2 on AppVeyor builders
2+
13
If (!${env:MSYS2_ARCH}) {
24
Exit 0
35
}

ci/run-travis.sh

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Entry point for all travis builds, this will set up the Travis environment by
2+
# downloading any dependencies. It will then execute the `run.sh` script to
3+
# build and execute all tests.
4+
15
set -ex
26

37
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
@@ -11,6 +15,11 @@ export HOST=$ARCH-$OS
1115
MAIN_TARGETS=https://static.rust-lang.org/dist
1216
EXTRA_TARGETS=https://people.mozilla.org/~acrichton/libc-test/2015-09-08
1317

18+
install() {
19+
sudo apt-get update
20+
sudo apt-get install $@
21+
}
22+
1423
if [ "$TARGET" = "arm-linux-androideabi" ]; then
1524
# Pull a pre-built docker image for testing android, then run tests entirely
1625
# within that image.
@@ -19,10 +28,16 @@ if [ "$TARGET" = "arm-linux-androideabi" ]; then
1928
sh ci/run.sh $TARGET
2029
elif [ "$TARGET" = "x86_64-unknown-linux-musl" ]; then
2130
curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib
31+
install musl-tools
32+
export CC=musl-gcc
2233
elif [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]; then
2334
curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib
24-
sudo apt-get install gcc-4.7-arm-linux-gnueabihf qemu-user
35+
install gcc-4.7-arm-linux-gnueabihf qemu-user
2536
export CC=arm-linux-gnueabihf-gcc-4.7
37+
elif [ "$TARGET" = "aarch64-unknown-linux-gnu" ]; then
38+
curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib
39+
install gcc-aarch64-linux-gnu qemu-user
40+
export CC=aarch64-linux-gnu-gcc
2641
elif [ "$TARGET" = "mips-unknown-linux-gnu" ]; then
2742
# Download pre-built and custom MIPS libs and then also instsall the MIPS
2843
# compiler according to this post:
@@ -33,9 +48,8 @@ elif [ "$TARGET" = "mips-unknown-linux-gnu" ]; then
3348
sudo tee -a /etc/apt/sources.list
3449
echo 'deb http://www.emdebian.org/debian/ squeeze main' | \
3550
sudo tee -a /etc/apt/sources.list
36-
sudo apt-get update
37-
sudo apt-get install emdebian-archive-keyring
38-
sudo apt-get install qemu-user gcc-4.4-mips-linux-gnu -y --force-yes
51+
install emdebian-archive-keyring
52+
install qemu-user gcc-4.4-mips-linux-gnu -y --force-yes
3953
export CC=mips-linux-gnu-gcc
4054
else
4155
# Download the rustlib folder from the relevant portion of main distribution's
@@ -47,6 +61,10 @@ else
4761

4862
# clang has better error messages and implements alignof more broadly
4963
export CC=clang
64+
65+
if [ "$TARGET" = "i686-unknown-linux-gnu" ]; then
66+
install gcc-multilib
67+
fi
5068
fi
5169

5270
mkdir .cargo

ci/run.sh

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/bin/sh
22

3+
# Builds and runs tests for a particular target passed as an argument to this
4+
# script.
5+
36
set -ex
47

58
TARGET=$1
@@ -16,6 +19,8 @@ elif [ "$TARGET" = "mips-unknown-linux-gnu" ]; then
1619
# FIXME: this segfaults on travis, passes locally?
1720
#qemu-mips -L /usr/mips-linux-gnu libc-test/target/$TARGET/debug/all-*
1821
echo skip
22+
elif [ "$TARGET" = "aarch64-unknown-linux-gnu" ]; then
23+
qemu-aarch64 -L /usr/aarch64-linux-gnu/ libc-test/target/$TARGET/debug/libc-test
1924
else
2025
cargo run --manifest-path libc-test/Cargo.toml --target $TARGET
2126
fi

0 commit comments

Comments
 (0)