Skip to content

Commit fed612c

Browse files
committed
Output clif ir to output dir instead of hardcoded path
This is necessary for reproducable builds.
1 parent a233646 commit fed612c

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

src/pretty_clif.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,21 @@ pub(crate) fn write_clif_file<'tcx>(
226226
.expect("value location ranges")
227227
});
228228

229-
let symbol_name = tcx.symbol_name(instance).name;
230-
let clif_file_name = format!(
231-
"{}/{}__{}.{}.clif",
232-
concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/clif"),
233-
tcx.crate_name(LOCAL_CRATE),
234-
symbol_name,
235-
postfix,
236-
);
229+
let clif_output_dir = tcx
230+
.output_filenames(LOCAL_CRATE)
231+
.with_extension("clif");
232+
233+
match std::fs::create_dir(&clif_output_dir) {
234+
Ok(()) => {}
235+
Err(err) if err.kind() == std::io::ErrorKind::AlreadyExists => {}
236+
res @ Err(_) => res.unwrap(),
237+
}
238+
239+
let clif_file_name = clif_output_dir.join(format!(
240+
"{}.{}.clif",
241+
tcx.symbol_name(instance).name,
242+
postfix
243+
));
237244

238245
let mut clif = String::new();
239246
cranelift_codegen::write::decorate_function(

test.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ RUSTC=$RUSTC" "$RUSTFLAGS" -L crate=target/out --out-dir target/out -Cdebuginfo=
1818

1919
# Cleanup
2020
rm -r target/out || true
21-
mkdir -p target/out/clif
2221

2322
# Perform all tests
2423
echo "[BUILD] mini_core"

0 commit comments

Comments
 (0)