From 8bd1f78563b33bfc8664289ca3dad88cf4da613e Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 13 Dec 2018 20:25:24 +0100 Subject: [PATCH 1/8] fix libc feature gate --- tests/run-pass/foreign-fn-linkname.rs | 2 +- tests/run-pass/regions-mock-trans.rs | 2 +- tests/run-pass/thread-local.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/run-pass/foreign-fn-linkname.rs b/tests/run-pass/foreign-fn-linkname.rs index 3dd30fd676..f2ed67385c 100644 --- a/tests/run-pass/foreign-fn-linkname.rs +++ b/tests/run-pass/foreign-fn-linkname.rs @@ -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; diff --git a/tests/run-pass/regions-mock-trans.rs b/tests/run-pass/regions-mock-trans.rs index 130eaa288e..62931493aa 100644 --- a/tests/run-pass/regions-mock-trans.rs +++ b/tests/run-pass/regions-mock-trans.rs @@ -10,7 +10,7 @@ //ignore-windows: Uses POSIX APIs -#![feature(libc)] +#![feature(rustc_private)] #![allow(dead_code)] diff --git a/tests/run-pass/thread-local.rs b/tests/run-pass/thread-local.rs index 8c20e89ab5..aeedb7034c 100644 --- a/tests/run-pass/thread-local.rs +++ b/tests/run-pass/thread-local.rs @@ -1,6 +1,6 @@ //ignore-windows: Uses POSIX APIs -#![feature(libc)] +#![feature(rustc_private)] extern crate libc; use std::mem; From b0581caeef3278d020aee44c7f5a7736504df401 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 13 Dec 2018 22:05:46 +0100 Subject: [PATCH 2/8] VecDeque got fixed --- tests/run-pass/vecdeque.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/run-pass/vecdeque.rs b/tests/run-pass/vecdeque.rs index d92cff0b08..381169505e 100644 --- a/tests/run-pass/vecdeque.rs +++ b/tests/run-pass/vecdeque.rs @@ -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() { From e2505dd945923fa5ed057a2ee3080154fa356e0a Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 13 Dec 2018 22:07:57 +0100 Subject: [PATCH 3/8] we have no whitelist any more, go back to opt-level 3 --- tests/compiletest.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/compiletest.rs b/tests/compiletest.rs index 31f0eb0c13..f125100f83 100644 --- a/tests/compiletest.rs +++ b/tests/compiletest.rs @@ -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"); From fbad6c031083d6c30b6e3dd7d685f9c0c688b716 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 14 Dec 2018 08:12:39 +0100 Subject: [PATCH 4/8] bump Rust nightly --- rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-version b/rust-version index 69d072f1bf..2ad896fe05 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -nightly-2018-12-08 +nightly-2018-12-14 From 6bc3a488025b5525173b64fc691785aa67fced47 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 15 Dec 2018 14:13:46 +0100 Subject: [PATCH 5/8] tweak travis.sh --- travis.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/travis.sh b/travis.sh index e11d3e17c0..aded53b157 100755 --- a/travis.sh +++ b/travis.sh @@ -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 From 6a37e723c4af5760cec21d6a1684ed6d7f344a93 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 15 Dec 2018 15:08:03 +0100 Subject: [PATCH 6/8] detect outdated xargo version --- src/bin/cargo-miri.rs | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/src/bin/cargo-miri.rs b/src/bin/cargo-miri.rs index 6d2dc1dd2f..310bf4f583 100644 --- a/src/bin/cargo-miri.rs +++ b/src/bin/cargo-miri.rs @@ -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}; @@ -114,6 +114,36 @@ fn list_targets() -> impl Iterator { 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); @@ -134,14 +164,14 @@ 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() { + if !Command::new("cargo").args(&["install", "xargo", "-f"]).status().unwrap().success() { show_error(format!("Failed to install xargo")); } } From 96b2c347d74cef4b93ddb681fb3244b98ab883f1 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 15 Dec 2018 18:39:42 +0100 Subject: [PATCH 7/8] temporarily use git version of xargo --- src/bin/cargo-miri.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bin/cargo-miri.rs b/src/bin/cargo-miri.rs index 310bf4f583..5b1b720da7 100644 --- a/src/bin/cargo-miri.rs +++ b/src/bin/cargo-miri.rs @@ -171,7 +171,8 @@ fn setup(ask_user: bool) { } else { println!("Installing xargo: `cargo install xargo -f`"); } - if !Command::new("cargo").args(&["install", "xargo", "-f"]).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")); } } From 77ef84e1e8a48ffa1a7d63e858e3d158bc1a8ecb Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Mon, 17 Dec 2018 10:12:04 +0100 Subject: [PATCH 8/8] Adjust tests for funciton pointer changes --- tests/run-pass/function_pointers.rs | 9 +++++---- tests/run-pass/mir_coercions.rs | 5 ++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/run-pass/function_pointers.rs b/tests/run-pass/function_pointers.rs index 4f597d4a2e..6819a2af3e 100644 --- a/tests/run-pass/function_pointers.rs +++ b/tests/run-pass/function_pointers.rs @@ -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 i32>(f: F) -> i32 { f() } @@ -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); } diff --git a/tests/run-pass/mir_coercions.rs b/tests/run-pass/mir_coercions.rs index 36155297e3..1dab492f9d 100644 --- a/tests/run-pass/mir_coercions.rs +++ b/tests/run-pass/mir_coercions.rs @@ -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);