Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for latest nightly #574

Merged
merged 10 commits into from
Dec 18, 2018
Merged
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2018-12-08
nightly-2018-12-14
43 changes: 37 additions & 6 deletions src/bin/cargo-miri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
extern crate cargo_metadata;

use std::path::{PathBuf, Path};
use std::io::{self, Write};
use std::io::{self, Write, BufRead};
use std::process::Command;
use std::fs::{self, File};

Expand Down Expand Up @@ -114,6 +114,36 @@ fn list_targets() -> impl Iterator<Item=cargo_metadata::Target> {
package.targets.into_iter()
}

fn xargo_version() -> Option<(u32, u32, u32)> {
let out = Command::new("xargo").arg("--version").output().ok()?;
if !out.status.success() {
return None;
}
// Parse output. The first line looks like "xargo 0.3.12 (b004f1c 2018-12-13)".
let line = out.stderr.lines().nth(0)
.expect("malformed `xargo --version` output: not at least one line")
.expect("malformed `xargo --version` output: error reading first line");
let version = line.split(' ').nth(1)
.expect("malformed `xargo --version` output: not at least two words");
let mut version_pieces = version.split('.');
let major = version_pieces.next()
.expect("malformed `xargo --version` output: not a major version piece")
.parse()
.expect("malformed `xargo --version` output: major version is not an integer");
let minor = version_pieces.next()
.expect("malformed `xargo --version` output: not a minor version piece")
.parse()
.expect("malformed `xargo --version` output: minor version is not an integer");
let patch = version_pieces.next()
.expect("malformed `xargo --version` output: not a patch version piece")
.parse()
.expect("malformed `xargo --version` output: patch version is not an integer");
if !version_pieces.next().is_none() {
panic!("malformed `xargo --version` output: more than three pieces in version");
}
Some((major, minor, patch))
}

fn ask(question: &str) {
let mut buf = String::new();
print!("{} [Y/n] ", question);
Expand All @@ -134,14 +164,15 @@ fn setup(ask_user: bool) {
}

// First, we need xargo
if Command::new("xargo").arg("--version").output().is_err()
{
let xargo = xargo_version();
if xargo.map_or(true, |v| v < (0, 3, 13)) {
if ask_user {
ask("It seems you do not have xargo installed. I will run `cargo install xargo`. Proceed?");
ask("It seems you do not have a recent enough xargo installed. I will run `cargo install xargo -f`. Proceed?");
} else {
println!("Installing xargo: `cargo install xargo`");
println!("Installing xargo: `cargo install xargo -f`");
}
if !Command::new("cargo").args(&["install", "xargo"]).status().unwrap().success() {
// FIXME: Go back to using releases, once a 0.3.13 got released.
if !Command::new("cargo").args(&["install", "xargo", "-f", "--git", "https://github.com/japaric/xargo"]).status().unwrap().success() {
show_error(format!("Failed to install xargo"));
}
}
Expand Down
4 changes: 1 addition & 3 deletions tests/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ fn miri_pass(path: &str, target: &str, opt: bool) {
flags.push("-Dwarnings -Dunused".to_owned()); // overwrite the -Aunused in compiletest-rs
flags.push("--edition 2018".to_owned());
if opt {
// FIXME: We use opt level 1 because MIR inlining defeats the validation
// whitelist.
flags.push("-Zmir-opt-level=1".to_owned());
flags.push("-Zmir-opt-level=3".to_owned());
}

let mut config = mk_config("ui");
Expand Down
2 changes: 1 addition & 1 deletion tests/run-pass/foreign-fn-linkname.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

//ignore-windows: Uses POSIX APIs

#![feature(libc)]
#![feature(rustc_private)]
#![allow(unused_extern_crates)] // rustc bug https://github.com/rust-lang/rust/issues/56098

extern crate libc;
Expand Down
9 changes: 5 additions & 4 deletions tests/run-pass/function_pointers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ fn h(i: i32, j: i32) -> i32 {
j * i * 7
}

fn return_fn_ptr() -> fn() -> i32 {
fn return_fn_ptr(f: fn() -> i32) -> fn() -> i32 {
f
}

fn call_fn_ptr() -> i32 {
return_fn_ptr()()
return_fn_ptr(f)()
}

fn indirect<F: Fn() -> i32>(f: F) -> i32 { f() }
Expand All @@ -41,6 +41,7 @@ fn main() {
assert_eq!(indirect3(h), 210);
assert_eq!(indirect_mut3(h), 210);
assert_eq!(indirect_once3(h), 210);
assert!(return_fn_ptr() == f);
assert!(return_fn_ptr() as unsafe fn() -> i32 == f as fn() -> i32 as unsafe fn() -> i32);
let g = f as fn() -> i32;
assert!(return_fn_ptr(g) == g);
assert!(return_fn_ptr(g) as unsafe fn() -> i32 == g as fn() -> i32 as unsafe fn() -> i32);
}
5 changes: 4 additions & 1 deletion tests/run-pass/mir_coercions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ fn main() {
let a = [0,1,2];
let square_local : fn(u32) -> u32 = square;
let (f,g) = fn_coercions(&square_local);
assert_eq!(f as *const (), square as *const());
// cannot use `square as *const ()` because we can't know whether the compiler duplicates
// functions, so two function pointers are only equal if they result from the same function
// to function pointer cast
assert_eq!(f as *const (), square_local as *const());
assert_eq!(g(4), 16);
assert_eq!(identity_coercion(g)(5), 25);

Expand Down
2 changes: 1 addition & 1 deletion tests/run-pass/regions-mock-trans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

//ignore-windows: Uses POSIX APIs

#![feature(libc)]
#![feature(rustc_private)]

#![allow(dead_code)]

Expand Down
2 changes: 1 addition & 1 deletion tests/run-pass/thread-local.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//ignore-windows: Uses POSIX APIs

#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;

use std::mem;
Expand Down
3 changes: 0 additions & 3 deletions tests/run-pass/vecdeque.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// FIXME: Validation disabled until https://github.com/rust-lang/rust/pull/56161 lands
// compile-flags: -Zmiri-disable-validation

use std::collections::VecDeque;

fn main() {
Expand Down
10 changes: 5 additions & 5 deletions travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ else
fi

echo "Build and install miri"
cargo build --release --all-features --all-targets &&
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
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
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)
(cd test-cargo-miri && MIRI_SYSROOT="$MIRI_SYSROOT_BASE"/HOST ./run-test.py)
echo