2024-06-11 10:37:51 -05:00
|
|
|
// When two instances of rustc are invoked in parallel, they
|
|
|
|
// can conflict on their temporary files and overwrite each others',
|
|
|
|
// leading to unsuccessful compilation. The -Z temps-dir flag adds
|
|
|
|
// separate designated directories for each rustc invocation, preventing
|
|
|
|
// conflicts. This test uses this flag and checks for successful compilation.
|
|
|
|
// See https://github.com/rust-lang/rust/pull/83846
|
|
|
|
|
2024-06-11 11:53:33 -05:00
|
|
|
use std::sync::{Arc, Barrier};
|
2024-06-11 10:37:51 -05:00
|
|
|
use std::thread;
|
|
|
|
|
2024-07-17 08:31:38 -05:00
|
|
|
use run_make_support::{rfs, rustc};
|
2024-07-28 17:13:50 -05:00
|
|
|
|
2024-06-11 10:37:51 -05:00
|
|
|
fn main() {
|
2024-07-17 07:42:06 -05:00
|
|
|
rfs::create_file("lib.rs");
|
2024-06-11 11:53:33 -05:00
|
|
|
let barrier = Arc::new(Barrier::new(2));
|
|
|
|
let handle = {
|
|
|
|
let barrier = Arc::clone(&barrier);
|
|
|
|
thread::spawn(move || {
|
|
|
|
barrier.wait();
|
2024-06-11 15:12:36 -05:00
|
|
|
rustc().crate_type("lib").arg("-Ztemps-dir=temp1").input("lib.rs").run();
|
2024-06-11 11:53:33 -05:00
|
|
|
})
|
|
|
|
};
|
|
|
|
barrier.wait();
|
2024-06-11 15:12:36 -05:00
|
|
|
rustc().crate_type("staticlib").arg("-Ztemps-dir=temp2").input("lib.rs").run();
|
2024-06-11 11:53:33 -05:00
|
|
|
handle.join().expect("lib thread panicked");
|
2024-06-11 10:37:51 -05:00
|
|
|
}
|