1 #![feature(rustc_private, custom_attribute)]
2 #![allow(unused_attributes)]
7 extern crate rustc_driver;
8 extern crate env_logger;
9 extern crate log_settings;
12 use miri::interpreter;
13 use rustc::session::Session;
14 use rustc_driver::{driver, CompilerCalls};
16 struct MiriCompilerCalls;
18 impl<'a> CompilerCalls<'a> for MiriCompilerCalls {
23 ) -> driver::CompileController<'a> {
24 let mut control = driver::CompileController::basic();
26 control.after_analysis.callback = Box::new(|state| {
27 state.session.abort_if_errors();
28 interpreter::interpret_start_points(state.tcx.unwrap(), state.mir_map.unwrap());
38 let args: Vec<String> = std::env::args().collect();
39 rustc_driver::run_compiler(&args, &mut MiriCompilerCalls);
44 let format = |record: &log::LogRecord| {
45 // prepend spaces to indent the final string
46 let indentation = log_settings::settings().indentation;
48 let depth = indentation / spaces.len();
49 let indentation = indentation % spaces.len();
50 let indentation = &spaces[..indentation];
51 format!("{}:{}{:2}{} {}", record.level(), record.location().module_path(), depth, indentation, record.args())
54 let mut builder = env_logger::LogBuilder::new();
55 builder.format(format).filter(None, log::LogLevelFilter::Info);
57 if std::env::var("MIRI_LOG").is_ok() {
58 builder.parse(&std::env::var("MIRI_LOG").unwrap());
61 builder.init().unwrap();