Skip to content

Commit

Permalink
Merge pull request #573 from RalfJung/rustc-wrapper
Browse files Browse the repository at this point in the history
use RUSTC_WRAPPER for the cargo hook
  • Loading branch information
RalfJung committed Dec 12, 2018
2 parents ff140da + ee2b5bb commit 0610a81
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 38 deletions.
33 changes: 2 additions & 31 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,51 +12,22 @@ 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
RUST_TOOLCHAIN=nightly
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:
Expand Down
14 changes: 8 additions & 6 deletions src/bin/cargo-miri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand All @@ -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<String> = 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()
Expand Down Expand Up @@ -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."))
}
}

Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
30 changes: 30 additions & 0 deletions travis.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0610a81

Please sign in to comment.