From fed612c75af364ae72eee3a8a087dcc33218df00 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 15 Oct 2020 10:57:56 +0200 Subject: [PATCH] Output clif ir to output dir instead of hardcoded path This is necessary for reproducable builds. --- src/pretty_clif.rs | 23 +++++++++++++++-------- test.sh | 1 - 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index e99bec45a5e..a37a832a231 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -226,14 +226,21 @@ pub(crate) fn write_clif_file<'tcx>( .expect("value location ranges") }); - let symbol_name = tcx.symbol_name(instance).name; - let clif_file_name = format!( - "{}/{}__{}.{}.clif", - concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/clif"), - tcx.crate_name(LOCAL_CRATE), - symbol_name, - postfix, - ); + let clif_output_dir = tcx + .output_filenames(LOCAL_CRATE) + .with_extension("clif"); + + match std::fs::create_dir(&clif_output_dir) { + Ok(()) => {} + Err(err) if err.kind() == std::io::ErrorKind::AlreadyExists => {} + res @ Err(_) => res.unwrap(), + } + + let clif_file_name = clif_output_dir.join(format!( + "{}.{}.clif", + tcx.symbol_name(instance).name, + postfix + )); let mut clif = String::new(); cranelift_codegen::write::decorate_function( diff --git a/test.sh b/test.sh index 0d2b5c6a392..a1c4d9f2872 100755 --- a/test.sh +++ b/test.sh @@ -18,7 +18,6 @@ RUSTC=$RUSTC" "$RUSTFLAGS" -L crate=target/out --out-dir target/out -Cdebuginfo= # Cleanup rm -r target/out || true -mkdir -p target/out/clif # Perform all tests echo "[BUILD] mini_core"