Skip to content

Commit

Permalink
Merge pull request #1 from alexcrichton/std-merge
Browse files Browse the repository at this point in the history
Std merge
  • Loading branch information
alexcrichton committed Sep 18, 2015
2 parents 242d3d3 + 038aedb commit 751b42e
Show file tree
Hide file tree
Showing 32 changed files with 834 additions and 80 deletions.
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ matrix:
- os: linux
env: TARGET=mips-unknown-linux-gnu
rust: nightly-2015-09-08
addons:
apt:
packages:
- gcc-multilib
- os: linux
env: TARGET=aarch64-unknown-linux-gnu
rust: nightly-2015-09-08
notifications:
email:
on_success: never
Expand Down
4 changes: 4 additions & 0 deletions ci/Dockerfile-android
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# This is a Dockerfile for building the image that is used to build Android
# binaries and run tests within. This will install the NDK, SDK, and set up an
# emulator to run tests in.

FROM ubuntu:latest

RUN mkdir /build
Expand Down
80 changes: 80 additions & 0 deletions ci/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
The goal of the libc crate is to have CI running everywhere to have the
strongest guarantees about the definitions that this library contains, and as a
result the CI is pretty complicated and also pretty large! Hopefully this can
serve as a guide through the sea of scripts in this directory and elsewhere in
this project.

# Files

First up, let's talk about the files in this directory:

* `Dockerfile-android`, `android-accept-licenses.sh` -- these two files are
used to build the Docker image that the android CI builder uses. The
`Dockerfile` just installs the Android SDK, NDK, a Rust nightly, Rust target
libraries for Android, and sets up an emulator to run tests in. You can build
a new image with this command (from the root of the project):

docker build -t alexcrichton/rust-libc-test -f ci/Dockerfile-android .

When building a new image contact @alexcrichton to push it to the docker hub
and have libc start using it. This hasn't needed to happen yet, so the process
may be a little involved.

The script here, `android-accept-licenses.sh` is just a helper used to accept
the licenses of the SDK of Android while the docker image is being created.

* `msys2.ps1` - a PowerShell script which is used to install MSYS2 on the
AppVeyor bots. As of this writing MSYS2 isn't installed by default, and this
script will install the right version/arch of msys2 in preparation of using
the contained C compiler to compile C shims.

* `run-travis.sh` - a shell script run by all Travis builders, this is
responsible for setting up the rest of the environment such as installing new
packages, downloading Rust target libraries, etc.

* `run.sh` - the actual script which runs tests for a particular architecture.
Called from the `run-travis.sh` script this will run all tests for the target
specified.

* `cargo-config` - Cargo configuration of linkers to use copied into place by
the `run-travis.sh` script before builds are run.

* `dox.sh` - script called from `run-travis.sh` on only the linux 64-bit nightly
Travis bots to build documentation for this crate.

* `landing-page-*.html` - used by `dox.sh` to generate a landing page for all
architectures' documentation.

# CI Systems

Currently this repository leverages a combination of Travis CI and AppVeyor for
running tests. The triples tested are:

* AppVeyor
* `{i686,x86_64}-pc-windows-{msvc,gnu}`
* Travis
* `{i686,x86_64,mips,aarch64}-unknown-linux-gnu`
* `x86_64-unknown-linux-musl`
* `arm-unknown-linux-gnueabihf`
* `arm-linux-androideabi`
* `{i686,x86_64}-apple-darwin`

The Windows triples are all pretty standard, they just set up their environment
then run tests, no need for downloading any extra target libs (we just download
the right installer). The Intel Linux/OSX builds are similar in that we just
download the right target libs and run tests. Note that the Intel Linux/OSX
builds are run on stable/beta/nightly, but are the only ones that do so.

The remaining architectures look like:

* Android runs in a docker image with an emulator, the NDK, and the SDK already
set up (see `Dockerfile-android`). The entire build happens within the docker
image.
* The MIPS, ARM, and AArch64 builds all use QEMU to run the generated binary to
actually verify the tests pass.
* The MUSL build just has to download a MUSL compiler and target libraries and
then otherwise runs tests normally.

Hopefully that's at least somewhat of an introduction to everything going on
here, and feel free to ping @alexcrichton with questions!

5 changes: 5 additions & 0 deletions ci/cargo-config
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Configuration of which linkers to call on Travis for various architectures

[target.arm-linux-androideabi]
linker = "arm-linux-androideabi-gcc"

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

[target.mips-unknown-linux-gnu]
linker = "mips-linux-gnu-gcc"

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
11 changes: 8 additions & 3 deletions ci/dox.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
#!/bin/sh

# Builds documentation for all target triples that we have a registered URL for
# in liblibc. This scrapes the list of triples to document from `src/lib.rs`
# which has a bunch of `html_root_url` directives we pick up.

set -e

TARGETS=`grep html_root_url src/lib.rs | sed 's/.*".*\/\(.*\)"/\1/'`

rm -rf target/doc
mkdir -p target/doc

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

TARGETS=`grep html_root_url src/lib.rs | sed 's/.*".*\/\(.*\)"/\1/'`

for target in $TARGETS; do
echo documenting $target

Expand All @@ -21,7 +25,8 @@ done

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

if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "autotest" ]; then
# If we're on travis, not a PR, and on the right branch, publish!
if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "master" ]; then
pip install ghp-import --user $USER
$HOME/.local/bin/ghp-import -n target/doc
git push -qf https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages
Expand Down
2 changes: 2 additions & 0 deletions ci/msys2.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Installs MSYS2 on AppVeyor builders

If (!${env:MSYS2_ARCH}) {
Exit 0
}
Expand Down
26 changes: 22 additions & 4 deletions ci/run-travis.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Entry point for all travis builds, this will set up the Travis environment by
# downloading any dependencies. It will then execute the `run.sh` script to
# build and execute all tests.

set -ex

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

install() {
sudo apt-get update
sudo apt-get install $@
}

if [ "$TARGET" = "arm-linux-androideabi" ]; then
# Pull a pre-built docker image for testing android, then run tests entirely
# within that image.
Expand All @@ -19,10 +28,16 @@ if [ "$TARGET" = "arm-linux-androideabi" ]; then
sh ci/run.sh $TARGET
elif [ "$TARGET" = "x86_64-unknown-linux-musl" ]; then
curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib
install musl-tools
export CC=musl-gcc
elif [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]; then
curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib
sudo apt-get install gcc-4.7-arm-linux-gnueabihf qemu-user
install gcc-4.7-arm-linux-gnueabihf qemu-user
export CC=arm-linux-gnueabihf-gcc-4.7
elif [ "$TARGET" = "aarch64-unknown-linux-gnu" ]; then
curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib
install gcc-aarch64-linux-gnu qemu-user
export CC=aarch64-linux-gnu-gcc
elif [ "$TARGET" = "mips-unknown-linux-gnu" ]; then
# Download pre-built and custom MIPS libs and then also instsall the MIPS
# compiler according to this post:
Expand All @@ -33,9 +48,8 @@ elif [ "$TARGET" = "mips-unknown-linux-gnu" ]; then
sudo tee -a /etc/apt/sources.list
echo 'deb http://www.emdebian.org/debian/ squeeze main' | \
sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get install emdebian-archive-keyring
sudo apt-get install qemu-user gcc-4.4-mips-linux-gnu -y --force-yes
install emdebian-archive-keyring
install qemu-user gcc-4.4-mips-linux-gnu -y --force-yes
export CC=mips-linux-gnu-gcc
else
# Download the rustlib folder from the relevant portion of main distribution's
Expand All @@ -47,6 +61,10 @@ else

# clang has better error messages and implements alignof more broadly
export CC=clang

if [ "$TARGET" = "i686-unknown-linux-gnu" ]; then
install gcc-multilib
fi
fi

mkdir .cargo
Expand Down
5 changes: 5 additions & 0 deletions ci/run.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/sh

# Builds and runs tests for a particular target passed as an argument to this
# script.

set -ex

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

0 comments on commit 751b42e

Please sign in to comment.