1
Fork 0

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

@ -120,7 +120,7 @@ fn trans_fn<'a, 'tcx: 'a>(
if cfg!(debug_assertions) {
::cranelift::codegen::write::decorate_function(&mut writer, &mut cton, &func, None)
.unwrap();
let clif_file_name = "target/out/clif/".to_string() + &tcx.symbol_name(instance).as_str();
let clif_file_name = concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/clif/").to_string() + &tcx.symbol_name(instance).as_str();
::std::fs::write(clif_file_name, cton.as_bytes()).unwrap();
}

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),