Skip to content

Commit

Permalink
Auto merge of #45002 - oli-obk:miri, r=eddyb
Browse files Browse the repository at this point in the history
Validate miri against the HIR const evaluator

r? @eddyb

cc @alexcrichton @arielb1 @RalfJung

The interesting parts are the last few functions in `librustc_const_eval/eval.rs`

* We warn if miri produces an error while HIR const eval does not.
* We warn if miri produces a value that does not match the value produced by HIR const eval
* if miri succeeds and HIR const eval fails, nothing is emitted, but we still return the HIR error
* if both error, nothing is emitted and the HIR const eval error is returned

So there are no actual changes, except that miri is forced to produce the same values as the old const eval.

* This does **not** touch the const evaluator in trans at all. That will come in a future PR.
* This does **not** cause any code to compile that didn't compile before. That will also come in the future

It would be great if someone could start a crater run if travis passes
  • Loading branch information
bors committed Dec 14, 2017
2 parents 8624ea5 + 7a2bff7 commit 2974104
Show file tree
Hide file tree
Showing 40 changed files with 6,548 additions and 59 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -294,6 +294,7 @@ before_deploy:
cp -r obj/build/dist/* deploy/$TRAVIS_COMMIT;
fi
- travis_retry gem update --system
- ls -la deploy/$TRAVIS_COMMIT

deploy:
- provider: s3
Expand Down
21 changes: 21 additions & 0 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/bootstrap/bin/rustc.rs
Expand Up @@ -246,6 +246,9 @@ fn main() {
// When running miri tests, we need to generate MIR for all libraries
if env::var("TEST_MIRI").ok().map_or(false, |val| val == "true") {
cmd.arg("-Zalways-encode-mir");
if stage != "0" {
cmd.arg("-Zmiri");
}
cmd.arg("-Zmir-emit-validate=1");
}

Expand Down
7 changes: 4 additions & 3 deletions src/bootstrap/builder.rs
Expand Up @@ -499,9 +499,10 @@ impl<'a> Builder<'a> {
if mode != Mode::Tool {
// Tools don't get debuginfo right now, e.g. cargo and rls don't
// get compiled with debuginfo.
cargo.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string())
.env("RUSTC_DEBUGINFO_LINES", self.config.rust_debuginfo_lines.to_string())
.env("RUSTC_FORCE_UNSTABLE", "1");
// Adding debuginfo increases their sizes by a factor of 3-4.
cargo.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string());
cargo.env("RUSTC_DEBUGINFO_LINES", self.config.rust_debuginfo_lines.to_string());
cargo.env("RUSTC_FORCE_UNSTABLE", "1");

// Currently the compiler depends on crates from crates.io, and
// then other crates can depend on the compiler (e.g. proc-macro
Expand Down
6 changes: 5 additions & 1 deletion src/bootstrap/check.rs
Expand Up @@ -321,6 +321,7 @@ impl Step for Rustfmt {

#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct Miri {
stage: u32,
host: Interned<String>,
}

Expand All @@ -336,15 +337,17 @@ impl Step for Miri {

fn make_run(run: RunConfig) {
run.builder.ensure(Miri {
stage: run.builder.top_stage,
host: run.target,
});
}

/// Runs `cargo test` for miri.
fn run(self, builder: &Builder) {
let build = builder.build;
let stage = self.stage;
let host = self.host;
let compiler = builder.compiler(1, host);
let compiler = builder.compiler(stage, host);

if let Some(miri) = builder.ensure(tool::Miri { compiler, target: self.host }) {
let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test");
Expand Down Expand Up @@ -766,6 +769,7 @@ impl Step for Compiletest {
if build.config.rust_debuginfo_tests {
flags.push("-g".to_string());
}
flags.push("-Zmiri -Zunstable-options".to_string());

if let Some(linker) = build.linker(target) {
cmd.arg("--linker").arg(linker);
Expand Down
4 changes: 4 additions & 0 deletions src/librustc/Cargo.toml
Expand Up @@ -16,13 +16,17 @@ graphviz = { path = "../libgraphviz" }
jobserver = "0.1"
log = "0.3"
owning_ref = "0.3.3"
rustc_apfloat = { path = "../librustc_apfloat" }
rustc_back = { path = "../librustc_back" }
rustc_const_math = { path = "../librustc_const_math" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_errors = { path = "../librustc_errors" }
serialize = { path = "../libserialize" }
syntax = { path = "../libsyntax" }
syntax_pos = { path = "../libsyntax_pos" }
backtrace = "0.3.3"
byteorder = { version = "1.1", features = ["i128"]}


# Note that these dependencies are a lie, they're just here to get linkage to
# work.
Expand Down
5 changes: 5 additions & 0 deletions src/librustc/lib.rs
Expand Up @@ -64,6 +64,7 @@
#![feature(unboxed_closures)]
#![feature(underscore_lifetimes)]
#![feature(trace_macros)]
#![feature(catch_expr)]
#![feature(test)]

#![recursion_limit="512"]
Expand All @@ -89,6 +90,10 @@ extern crate jobserver;

extern crate serialize as rustc_serialize; // used by deriving

extern crate rustc_apfloat;
extern crate byteorder;
extern crate backtrace;

// Note that librustc doesn't actually depend on these crates, see the note in
// `Cargo.toml` for this crate about why these are here.
#[allow(unused_extern_crates)]
Expand Down

0 comments on commit 2974104

Please sign in to comment.