rewrite and rename issue-10971-temps-dir to rmake format

This commit is contained in:
Oneirical 2024-06-11 11:37:51 -04:00
parent bbe9a9c20b
commit d2268902f7
3 changed files with 22 additions and 11 deletions

View file

@ -79,7 +79,6 @@ run-make/invalid-library/Makefile
run-make/invalid-so/Makefile
run-make/invalid-staticlib/Makefile
run-make/issue-107094/Makefile
run-make/issue-10971-temps-dir/Makefile
run-make/issue-109934-lto-debuginfo/Makefile
run-make/issue-14698/Makefile
run-make/issue-15460/Makefile

View file

@ -1,10 +0,0 @@
include ../tools.mk
# Regression test for issue #10971
# Running two invocations in parallel would overwrite each other's temp files.
all:
touch $(TMPDIR)/lib.rs
$(RUSTC) --crate-type=lib -Z temps-dir=$(TMPDIR)/temp1 $(TMPDIR)/lib.rs & \
$(RUSTC) --crate-type=staticlib -Z temps-dir=$(TMPDIR)/temp2 $(TMPDIR)/lib.rs

View file

@ -0,0 +1,22 @@
// 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
use run_make_support::{fs_wrapper, rustc};
use std::thread;
fn main() {
fs_wrapper::create_file("lib.rs");
let handle1 = thread::spawn(move || {
rustc().crate_type("lib").arg("-Ztemps-dir=temp1").input("lib.rs");
});
let handle2 = thread::spawn(move || {
rustc().crate_type("staticlib").arg("-Ztemps-dir=temp2").input("lib.rs");
});
handle1.join().expect("lib thread panicked");
handle2.join().expect("staticlib thread panicked");
}