Use absolute compile time paths for some log files

This commit is contained in:
bjorn3
2018-10-06 14:48:34 +02:00
parent f4e544894a
commit 0fa547ac98
2 changed files with 9 additions and 3 deletions

View File

@@ -331,7 +331,11 @@ fn codegen_mono_items<'a, 'tcx: 'a>(
let mut caches = Caches::new();
let mut ccx = ConstantCx::default();
let mut log = ::std::fs::File::create("target/out/log.txt").unwrap();
let mut log = if cfg!(debug_assertions) {
Some(::std::fs::File::create(concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/log.txt")).unwrap())
} else {
None
};
let before = ::std::time::Instant::now();
println!("[codegen mono items] start");
@@ -344,7 +348,9 @@ fn codegen_mono_items<'a, 'tcx: 'a>(
if let Err(err) = res {
match err.downcast::<NonFatal>() {
Ok(non_fatal) => {
writeln!(log, "{}", &non_fatal.0);
if cfg!(debug_assertions) {
writeln!(log.as_mut().unwrap(), "{}", &non_fatal.0);
}
tcx.sess.err(&non_fatal.0)
}
Err(err) => ::std::panic::resume_unwind(err),