diff --git a/.travis.yml b/.travis.yml index a58ff4f67d..dfc4238a6c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,10 +12,8 @@ os: dist: xenial before_script: -# install extra stuff for cross-compilation +# Linux: install extra stuff for cross-compilation - if [[ "$TRAVIS_OS_NAME" == linux ]]; then sudo apt update && sudo apt install gcc-multilib; fi -# macOS weirdness (https://github.com/travis-ci/travis-ci/issues/6307, https://github.com/travis-ci/travis-ci/issues/10165) -- if [[ "$TRAVIS_OS_NAME" == osx ]]; then rvm get stable; fi # Compute the rust version we use. We do not use "language: rust" to have more control here. - | if [[ "$TRAVIS_EVENT_TYPE" == cron ]]; then @@ -23,40 +21,13 @@ before_script: else RUST_TOOLCHAIN=$(cat rust-version) fi -- | - if [ "$TRAVIS_OS_NAME" == osx ]; then - export MIRI_SYSROOT_BASE=~/Library/Caches/miri.miri.miri/ - else - export MIRI_SYSROOT_BASE=~/.cache/miri/ - fi -- | - if [[ "$TRAVIS_OS_NAME" == osx ]]; then - FOREIGN_TARGET=i686-apple-darwin - else - FOREIGN_TARGET=i686-unknown-linux-gnu - fi # install Rust - curl https://build.travis-ci.org/files/rustup-init.sh -sSf | sh -s -- -y --default-toolchain "$RUST_TOOLCHAIN" - export PATH=$HOME/.cargo/bin:$PATH - rustc --version script: -- set -e -- | - # Build and install miri - cargo build --release --all-features --all-targets && - cargo install --all-features --force --path . -- | - # Get ourselves a MIR-full libstd for the host and a foreign architecture - cargo miri setup && - cargo miri setup --target "$FOREIGN_TARGET" -- | - # Test miri with full MIR, on the host and other architectures - MIRI_SYSROOT=$MIRI_SYSROOT_BASE/HOST cargo test --release --all-features && - MIRI_SYSROOT=$MIRI_SYSROOT_BASE MIRI_TARGET=$FOREIGN_TARGET cargo test --release --all-features -- | - # Test cargo integration - (cd test-cargo-miri && MIRI_SYSROOT=$MIRI_SYSROOT_BASE/HOST ./run-test.py) +- ./travis.sh notifications: email: diff --git a/src/bin/cargo-miri.rs b/src/bin/cargo-miri.rs index 7e1785fd3b..6d2dc1dd2f 100644 --- a/src/bin/cargo-miri.rs +++ b/src/bin/cargo-miri.rs @@ -305,8 +305,8 @@ fn main() { _ => {} } } - } else { - // This arm is executed when cargo-miri runs `cargo rustc` with the `RUSTC` env var set to itself: + } else if let Some("rustc") = std::env::args().nth(1).as_ref().map(AsRef::as_ref) { + // This arm is executed when cargo-miri runs `cargo rustc` with the `RUSTC_WRAPPER` env var set to itself: // Dependencies get dispatched to rustc, the final test/binary to miri. let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME")); @@ -332,11 +332,11 @@ fn main() { // this conditional check for the --sysroot flag is there so users can call `cargo-miri` directly // without having to pass --sysroot or anything + let rustc_args = std::env::args().skip(2); let mut args: Vec = if std::env::args().any(|s| s == "--sysroot") { - std::env::args().skip(1).collect() + rustc_args.collect() } else { - std::env::args() - .skip(1) + rustc_args .chain(Some("--sysroot".to_owned())) .chain(Some(sys_root)) .collect() @@ -365,6 +365,8 @@ fn main() { Err(ref e) if miri_enabled => panic!("error during miri run: {:?}", e), Err(ref e) => panic!("error during rustc call: {:?}", e), } + } else { + show_error(format!("Must be called with either `miri` or `rustc` as first argument.")) } } @@ -389,7 +391,7 @@ where let path = std::env::current_exe().expect("current executable path invalid"); let exit_status = Command::new("cargo") .args(&args) - .env("RUSTC", path) + .env("RUSTC_WRAPPER", path) .spawn() .expect("could not run cargo") .wait() diff --git a/tests/compiletest.rs b/tests/compiletest.rs index a0862d0032..31f0eb0c13 100644 --- a/tests/compiletest.rs +++ b/tests/compiletest.rs @@ -3,7 +3,7 @@ #![test_runner(test_runner)] use std::slice::SliceConcatExt; -use std::path::{PathBuf, Path}; +use std::path::PathBuf; use std::env; use compiletest_rs as compiletest; diff --git a/travis.sh b/travis.sh new file mode 100755 index 0000000000..e11d3e17c0 --- /dev/null +++ b/travis.sh @@ -0,0 +1,30 @@ +#!/bin/bash +set -e + +# Determine configuration +if [ "$TRAVIS_OS_NAME" == osx ]; then + export MIRI_SYSROOT_BASE=~/Library/Caches/miri.miri.miri/ + FOREIGN_TARGET=i686-apple-darwin +else + export MIRI_SYSROOT_BASE=~/.cache/miri/ + FOREIGN_TARGET=i686-unknown-linux-gnu +fi + +echo "Build and install miri" +cargo build --release --all-features --all-targets && +cargo install --all-features --force --path . +echo + +echo "Get ourselves a MIR-full libstd for the host and a foreign architecture" +cargo miri setup && +cargo miri setup --target "$FOREIGN_TARGET" +echo + +echo "Test miri with full MIR, on the host and other architectures" +MIRI_SYSROOT=$MIRI_SYSROOT_BASE/HOST cargo test --release --all-features && +MIRI_SYSROOT=$MIRI_SYSROOT_BASE MIRI_TARGET=$FOREIGN_TARGET cargo test --release --all-features +echo + +echo "Test cargo integration" +(cd test-cargo-miri && MIRI_SYSROOT=$MIRI_SYSROOT_BASE/HOST ./run-test.py) +echo