about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeón Orell Valerian Liehr <me@fmease.dev>2024-05-23 20:09:09 +0200
committerGitHub <noreply@github.com>2024-05-23 20:09:09 +0200
commitd392d6849ccdc580502d5f189b46436428af5773 (patch)
tree187891ae2cf8f8b03493fd77433d95749888caf8
parente282b1f753296b85e21cfc984098f654989b6fea (diff)
parentf377ea165f2d3e977731e9746876a15b2c7e48a6 (diff)
downloadrust-d392d6849ccdc580502d5f189b46436428af5773.tar.gz
rust-d392d6849ccdc580502d5f189b46436428af5773.zip
Rollup merge of #125227 - Oneirical:seventh, r=jieyouxu
Migrate `run-make/issue-30063` to `rmake`

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

(Sorry about the [inconvenience](https://github.com/rust-lang/rust/pull/125224#issuecomment-2118340932) of all these PRs, this is the last one batched for today. I will discuss how we can cut these down a bit.)

The last check was previously commented out in the Makefile, and I have readded it. If it fails the CI, this can be reconsidered.
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt1
-rw-r--r--tests/run-make/issue-30063/Makefile36
-rw-r--r--tests/run-make/reset-codegen-1/foo.rs (renamed from tests/run-make/issue-30063/foo.rs)0
-rw-r--r--tests/run-make/reset-codegen-1/rmake.rs38
4 files changed, 38 insertions, 37 deletions
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index f509754a64d..5c6b9d11d0c 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -101,7 +101,6 @@ run-make/issue-25581/Makefile
 run-make/issue-26006/Makefile
 run-make/issue-26092/Makefile
 run-make/issue-28595/Makefile
-run-make/issue-30063/Makefile
 run-make/issue-33329/Makefile
 run-make/issue-35164/Makefile
 run-make/issue-36710/Makefile
diff --git a/tests/run-make/issue-30063/Makefile b/tests/run-make/issue-30063/Makefile
deleted file mode 100644
index 8a69ca79f51..00000000000
--- a/tests/run-make/issue-30063/Makefile
+++ /dev/null
@@ -1,36 +0,0 @@
-# ignore-cross-compile
-include ../tools.mk
-
-all:
-	rm -f $(TMPDIR)/foo-output
-	$(RUSTC) -C codegen-units=4 -o $(TMPDIR)/foo-output foo.rs
-	rm $(TMPDIR)/foo-output
-
-	rm -f $(TMPDIR)/asm-output
-	$(RUSTC) -C codegen-units=4 --emit=asm -o $(TMPDIR)/asm-output foo.rs
-	rm $(TMPDIR)/asm-output
-
-	rm -f $(TMPDIR)/bc-output
-	$(RUSTC) -C codegen-units=4 --emit=llvm-bc -o $(TMPDIR)/bc-output foo.rs
-	rm $(TMPDIR)/bc-output
-
-	rm -f $(TMPDIR)/ir-output
-	$(RUSTC) -C codegen-units=4 --emit=llvm-ir -o $(TMPDIR)/ir-output foo.rs
-	rm $(TMPDIR)/ir-output
-
-	rm -f $(TMPDIR)/link-output
-	$(RUSTC) -C codegen-units=4 --emit=link -o $(TMPDIR)/link-output foo.rs
-	rm $(TMPDIR)/link-output
-
-	rm -f $(TMPDIR)/obj-output
-	$(RUSTC) -C codegen-units=4 --emit=obj -o $(TMPDIR)/obj-output foo.rs
-	rm $(TMPDIR)/obj-output
-
-	rm -f $(TMPDIR)/dep-output
-	$(RUSTC) -C codegen-units=4 --emit=dep-info -o $(TMPDIR)/dep-output foo.rs
-	rm $(TMPDIR)/dep-output
-
-#	# (This case doesn't work yet, and may be fundamentally wrong-headed anyway.)
-#	rm -f $(TMPDIR)/multi-output
-#	$(RUSTC) -C codegen-units=4 --emit=asm,obj -o $(TMPDIR)/multi-output foo.rs
-#	rm $(TMPDIR)/multi-output
diff --git a/tests/run-make/issue-30063/foo.rs b/tests/run-make/reset-codegen-1/foo.rs
index 45590d86ba6..45590d86ba6 100644
--- a/tests/run-make/issue-30063/foo.rs
+++ b/tests/run-make/reset-codegen-1/foo.rs
diff --git a/tests/run-make/reset-codegen-1/rmake.rs b/tests/run-make/reset-codegen-1/rmake.rs
new file mode 100644
index 00000000000..4b91ba7df90
--- /dev/null
+++ b/tests/run-make/reset-codegen-1/rmake.rs
@@ -0,0 +1,38 @@
+// When rustc received 4 codegen-units, an output path and an emit flag all simultaneously,
+// this could cause an annoying recompilation issue, uselessly lengthening the build process.
+// A fix was delivered, which resets codegen-units to 1 when necessary,
+// but as it directly affected the way codegen-units are manipulated,
+// this test was created to check that this fix did not cause compilation failures.
+// See https://github.com/rust-lang/rust/issues/30063
+
+//@ ignore-cross-compile
+
+use run_make_support::{rustc, tmp_dir};
+use std::fs;
+
+fn compile(output_file: &str, emit: Option<&str>) {
+    let mut rustc = rustc();
+    let rustc = rustc.codegen_units(4).output(tmp_dir().join(output_file)).input("foo.rs");
+    if let Some(emit) = emit {
+        rustc.emit(emit);
+    }
+    rustc.run();
+}
+
+fn main() {
+    let flags = [
+        ("foo-output", None),
+        ("asm-output", Some("asm")),
+        ("bc-output", Some("llvm-bc")),
+        ("ir-output", Some("llvm-ir")),
+        ("link-output", Some("link")),
+        ("obj-output", Some("obj")),
+        ("dep-output", Some("dep-info")),
+        ("multi-output", Some("asm,obj")),
+    ];
+    for (output_file, emit) in flags {
+        fs::remove_file(output_file).unwrap_or_default();
+        compile(output_file, emit);
+        fs::remove_file(output_file);
+    }
+}