run_make_support/parallel.rs
1use std::rc::Rc;
2
3use crate::{bin_name, is_windows_msvc, rfs, run_in_tmpdir, rustc};
4
5pub fn check_reproducibility(file: &str, args: &[&str]) {
6 let mut reference = None;
7 let bin_name = bin_name(file);
8
9 for _ in 0..10 {
10 // Tmp dir as previous runs affect output binary on windows.
11 run_in_tmpdir(|| {
12 let mut rustc = rustc();
13 rustc.input(format!("{file}.rs")).output(&bin_name);
14
15 for arg in args {
16 rustc.arg(arg);
17 }
18
19 if is_windows_msvc() {
20 rustc.arg("-Clink-arg=/Brepro");
21 }
22
23 rustc.run();
24
25 let current = Rc::new(rfs::read(&bin_name));
26 reference.get_or_insert(Rc::clone(¤t));
27
28 assert_eq!(Some(current), reference);
29 });
30 }
31}