Skip to content

Commit 2974104

Browse files
committed
Auto merge of #45002 - oli-obk:miri, r=eddyb
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
2 parents 8624ea5 + 7a2bff7 commit 2974104

40 files changed

+6548
-59
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ before_deploy:
294294
cp -r obj/build/dist/* deploy/$TRAVIS_COMMIT;
295295
fi
296296
- travis_retry gem update --system
297+
- ls -la deploy/$TRAVIS_COMMIT
297298

298299
deploy:
299300
- provider: s3

src/Cargo.lock

+21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bootstrap/bin/rustc.rs

+3
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@ fn main() {
246246
// When running miri tests, we need to generate MIR for all libraries
247247
if env::var("TEST_MIRI").ok().map_or(false, |val| val == "true") {
248248
cmd.arg("-Zalways-encode-mir");
249+
if stage != "0" {
250+
cmd.arg("-Zmiri");
251+
}
249252
cmd.arg("-Zmir-emit-validate=1");
250253
}
251254

src/bootstrap/builder.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,10 @@ impl<'a> Builder<'a> {
499499
if mode != Mode::Tool {
500500
// Tools don't get debuginfo right now, e.g. cargo and rls don't
501501
// get compiled with debuginfo.
502-
cargo.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string())
503-
.env("RUSTC_DEBUGINFO_LINES", self.config.rust_debuginfo_lines.to_string())
504-
.env("RUSTC_FORCE_UNSTABLE", "1");
502+
// Adding debuginfo increases their sizes by a factor of 3-4.
503+
cargo.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string());
504+
cargo.env("RUSTC_DEBUGINFO_LINES", self.config.rust_debuginfo_lines.to_string());
505+
cargo.env("RUSTC_FORCE_UNSTABLE", "1");
505506

506507
// Currently the compiler depends on crates from crates.io, and
507508
// then other crates can depend on the compiler (e.g. proc-macro

src/bootstrap/check.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ impl Step for Rustfmt {
321321

322322
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
323323
pub struct Miri {
324+
stage: u32,
324325
host: Interned<String>,
325326
}
326327

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

337338
fn make_run(run: RunConfig) {
338339
run.builder.ensure(Miri {
340+
stage: run.builder.top_stage,
339341
host: run.target,
340342
});
341343
}
342344

343345
/// Runs `cargo test` for miri.
344346
fn run(self, builder: &Builder) {
345347
let build = builder.build;
348+
let stage = self.stage;
346349
let host = self.host;
347-
let compiler = builder.compiler(1, host);
350+
let compiler = builder.compiler(stage, host);
348351

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

770774
if let Some(linker) = build.linker(target) {
771775
cmd.arg("--linker").arg(linker);

src/librustc/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@ graphviz = { path = "../libgraphviz" }
1616
jobserver = "0.1"
1717
log = "0.3"
1818
owning_ref = "0.3.3"
19+
rustc_apfloat = { path = "../librustc_apfloat" }
1920
rustc_back = { path = "../librustc_back" }
2021
rustc_const_math = { path = "../librustc_const_math" }
2122
rustc_data_structures = { path = "../librustc_data_structures" }
2223
rustc_errors = { path = "../librustc_errors" }
2324
serialize = { path = "../libserialize" }
2425
syntax = { path = "../libsyntax" }
2526
syntax_pos = { path = "../libsyntax_pos" }
27+
backtrace = "0.3.3"
28+
byteorder = { version = "1.1", features = ["i128"]}
29+
2630

2731
# Note that these dependencies are a lie, they're just here to get linkage to
2832
# work.

src/librustc/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
#![feature(unboxed_closures)]
6565
#![feature(underscore_lifetimes)]
6666
#![feature(trace_macros)]
67+
#![feature(catch_expr)]
6768
#![feature(test)]
6869

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

9091
extern crate serialize as rustc_serialize; // used by deriving
9192

93+
extern crate rustc_apfloat;
94+
extern crate byteorder;
95+
extern crate backtrace;
96+
9297
// Note that librustc doesn't actually depend on these crates, see the note in
9398
// `Cargo.toml` for this crate about why these are here.
9499
#[allow(unused_extern_crates)]

0 commit comments

Comments
 (0)