diff --git a/.travis.yml b/.travis.yml index 191c8cf553..63f548afcd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,11 @@ dist: xenial services: - docker -language: generic +language: minimal +addons: + apt: + packages: + - gdb git: depth: false @@ -55,8 +59,8 @@ matrix: env: MACOSX_DEPLOYMENT_TARGET=10.7 TARGET=i686-apple-darwin install: - - sh rustup-init.sh --default-toolchain=stable -y - - export PATH="$PATH:$HOME/.cargo/bin" + - sh ./rustup-init.sh --default-toolchain=stable -y + - . "$HOME/.cargo/env" - if [ -z "$NO_ADD" ]; then rustup target add "$TARGET"; fi - rustup component add rustfmt @@ -64,20 +68,52 @@ script: - mkdir -p target/"$TARGET"; - > case "$TARGET" in - *-linux-android) DOCKER=android ;; # Android uses a local docker image - *-linux-androideabi) DOCKER=android ;; - *-apple-darwin) ;; - *) DOCKER=$TARGET ;; + *-linux-android*) DOCKER=android ;; # Android uses a local docker image + *-apple-darwin) ;; + *) DOCKER="$TARGET";; esac; if [ -n "$DOCKER" ]; then sh ci/build-run-docker.sh "$DOCKER" "$TARGET" "$SKIP_TESTS"; else - PATH="$HOME/rust/bin:$PATH" sh ci/run.sh; + sh ci/run.sh; fi + # Check the formatting last because test failures are more interesting to have + # discovered for contributors lacking some platform access for testing beforehand - if [ "${TARGET}" = x86_64-unknown-linux-gnu ]; then shellcheck -s dash -e SC1090 -- rustup-init.sh ci/*.sh; + cargo fmt --all -- --check; fi +# Random attempt at debugging currently. Just poking around in here to see if +# anything shows up. +after_failure: + # Dump backtrace for macOS + - ls -lat "$HOME"/Library/Logs/DiagnosticReports/ + - find "$HOME"/Library/Logs/DiagnosticReports + -type f + -name '*.crash' + -not -name '*.stage2-*.crash' + -not -name 'com.apple.CoreSimulator.CoreSimulatorService-*.crash' + -exec printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" {} \; + -exec head -750 {} \; + -exec echo travis_fold":"end:crashlog \; || true + + # Dump backtrace for Linux + - ln -s . checkout && + for CORE in obj/cores/core.*; do + EXE=$(echo $CORE | sed 's@obj/cores/core\.[0-9]*\.!checkout!\(.*\)@\1@;y@!@/@'); + if [ -f "$EXE" ]; then + printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; + gdb --batch -q -c "$CORE" "$EXE" + -iex 'set auto-load off' + -iex 'dir src/' + -iex 'set sysroot .' + -ex bt + -ex q; + echo travis_fold":"end:crashlog; + fi; + done || true + before_deploy: - sh ci/prepare-deploy-travis.sh diff --git a/ci/build-run-docker.sh b/ci/build-run-docker.sh index 259d248af6..8a3ef5828a 100644 --- a/ci/build-run-docker.sh +++ b/ci/build-run-docker.sh @@ -1,13 +1,21 @@ #!/bin/bash -script_dir=$(cd "$(dirname "$0")" && pwd) +root_dir="$TRAVIS_BUILD_DIR" +script_dir="$root_dir/ci" +objdir="$root_dir"/obj + . "$script_dir/shared.sh" set -e # Disable cause it makes shared script not to work properly #set -x -mkdir -p target +mkdir -p "$HOME"/.cargo +mkdir -p "$objdir"/cores +mkdir -p "$HOME"/.cache/sccache + +# Enable core dump on Linux +sudo sh -c 'echo "/checkout/obj/cores/core.%p.%E" > /proc/sys/kernel/core_pattern'; DOCKER="$1" TARGET="$2" @@ -27,23 +35,34 @@ if [ -f "ci/docker/$DOCKER/Dockerfile" ]; then travis_fold end "build.Dockerfile.${DOCKER}" fi +# Run containers as privileged as it should give them access to some more +# syscalls such as ptrace and whatnot. In the upgrade to LLVM 5.0 it was +# discovered that the leak sanitizer apparently needs these syscalls nowadays so +# we'll need `--privileged` for at least the `x86_64-gnu` builder, so this just +# goes ahead and sets it for all builders. # shellcheck disable=SC2016 docker run \ - --entrypoint sh \ + --entrypoint /bin/sh \ --user "$(id -u)":"$(id -g)" \ - --volume "$(rustc --print sysroot)":/travis-rust:ro \ - --volume "$(pwd)":/src:ro \ - --volume "$(pwd)"/target:/src/target \ - --workdir /src \ + --volume "$(rustc --print sysroot)":/rustc-sysroot:ro \ + --volume "$root_dir":/checkout:ro \ + --volume "$root_dir"/target:/checkout/target \ + --volume "$objdir":/checkout/obj \ + --workdir /checkout \ + --privileged \ --env TARGET="$TARGET" \ --env SKIP_TESTS="$SKIP_TESTS" \ - --env CARGO_HOME=/src/target/cargo-home \ - --env CARGO_TARGET_DIR=/src/target \ + --volume "$HOME/.cargo:/cargo" \ + --env CARGO_HOME=/cargo \ + --env CARGO_TARGET_DIR=/checkout/target \ --env LIBZ_SYS_STATIC=1 \ + --volume "$HOME"/.cache/sccache:/sccache \ + --env SCCACHE_DIR=/sccache \ --tty \ --init \ + --rm \ "$DOCKER" \ - -c 'PATH="$PATH":/travis-rust/bin exec sh ci/run.sh' + -c 'PATH="$PATH":/rustc-sysroot/bin sh ci/run.sh' # check that rustup-init was built with ssl support # see https://github.com/rust-lang/rustup.rs/issues/1051 diff --git a/ci/fetch-rust-docker.sh b/ci/fetch-rust-docker.sh index 4f18ff3f94..7555e1b876 100644 --- a/ci/fetch-rust-docker.sh +++ b/ci/fetch-rust-docker.sh @@ -1,6 +1,8 @@ #!/bin/bash -script_dir=$(cd "$(dirname "$0")" && pwd) +root_dir="$TRAVIS_BUILD_DIR" +script_dir="$root_dir/ci" + . "$script_dir/shared.sh" set -e diff --git a/ci/run.sh b/ci/run.sh index fba69e2b22..1fc16d79c1 100644 --- a/ci/run.sh +++ b/ci/run.sh @@ -2,6 +2,13 @@ set -ex +# only enable core dump on Linux +if [ -f /proc/sys/kernel/core_pattern ]; then + # shellcheck disable=SC2169 + # `-c` exists in Ubuntu 14.04 and later at least + ulimit -c unlimited +fi + rustc -vV cargo -vV rustfmt -vV @@ -12,7 +19,3 @@ if [ -z "$SKIP_TESTS" ]; then cargo test --release -p download --target "$TARGET" --features vendored-openssl cargo test --release --target "$TARGET" --features vendored-openssl fi - -# Check the formatting last because test failures are more interesting to have -# discovered for contributors lacking some platform access for testing beforehand -cargo fmt --all -- --check