about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-07-09 02:17:37 +0000
committerbors <bors@rust-lang.org>2024-07-09 02:17:37 +0000
commit99b7134389e9766462601a2fc4013840b9d31745 (patch)
tree4b248ae656e7a4cd4c6f09ce97b6d8acdd6379fa
parentd4a620058bbfc02548c0f7b3221c3d8b4c7d59af (diff)
parent7c23872836f6b536ed4a59786a1d46fbb5f0dafd (diff)
downloadrust-99b7134389e9766462601a2fc4013840b9d31745.tar.gz
rust-99b7134389e9766462601a2fc4013840b9d31745.zip
Auto merge of #127378 - Oneirical:cetestial-meteorite, r=jieyouxu
Migrate `issue-37839`, `track-path-dep-info` and `track-pgo-dep-info` `run-make` tests 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).

Please try:

try-job: test-various
try-job: dist-x86_64-musl
-rw-r--r--src/tools/run-make-support/src/lib.rs2
-rw-r--r--src/tools/run-make-support/src/rustc.rs15
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt3
-rw-r--r--tests/run-make/issue-37839/Makefile7
-rw-r--r--tests/run-make/proc-macro-three-crates/a.rs (renamed from tests/run-make/issue-37839/a.rs)0
-rw-r--r--tests/run-make/proc-macro-three-crates/b.rs (renamed from tests/run-make/issue-37839/b.rs)0
-rw-r--r--tests/run-make/proc-macro-three-crates/c.rs (renamed from tests/run-make/issue-37839/c.rs)0
-rw-r--r--tests/run-make/proc-macro-three-crates/rmake.rs20
-rw-r--r--tests/run-make/track-path-dep-info/Makefile13
-rw-r--r--tests/run-make/track-path-dep-info/rmake.rs13
-rw-r--r--tests/run-make/track-pgo-dep-info/Makefile25
-rw-r--r--tests/run-make/track-pgo-dep-info/rmake.rs23
12 files changed, 71 insertions, 50 deletions
diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs
index 3fdf94804f1..5655318267a 100644
--- a/src/tools/run-make-support/src/lib.rs
+++ b/src/tools/run-make-support/src/lib.rs
@@ -35,7 +35,7 @@ pub use llvm::{
     LlvmProfdata, LlvmReadobj,
 };
 pub use run::{cmd, run, run_fail, run_with_args};
-pub use rustc::{aux_build, rustc, Rustc};
+pub use rustc::{aux_build, bare_rustc, rustc, Rustc};
 pub use rustdoc::{bare_rustdoc, rustdoc, Rustdoc};
 
 #[track_caller]
diff --git a/src/tools/run-make-support/src/rustc.rs b/src/tools/run-make-support/src/rustc.rs
index 885b361f72a..a2a7c8064dc 100644
--- a/src/tools/run-make-support/src/rustc.rs
+++ b/src/tools/run-make-support/src/rustc.rs
@@ -10,6 +10,12 @@ pub fn rustc() -> Rustc {
     Rustc::new()
 }
 
+/// Construct a plain `rustc` invocation with no flags set.
+#[track_caller]
+pub fn bare_rustc() -> Rustc {
+    Rustc::bare()
+}
+
 /// Construct a new `rustc` aux-build invocation.
 #[track_caller]
 pub fn aux_build() -> Rustc {
@@ -30,7 +36,6 @@ fn setup_common() -> Command {
     let rustc = env_var("RUSTC");
     let mut cmd = Command::new(rustc);
     set_host_rpath(&mut cmd);
-    cmd.arg("-L").arg(cwd());
     cmd
 }
 
@@ -40,6 +45,14 @@ impl Rustc {
     /// Construct a new `rustc` invocation.
     #[track_caller]
     pub fn new() -> Self {
+        let mut cmd = setup_common();
+        cmd.arg("-L").arg(cwd());
+        Self { cmd }
+    }
+
+    /// Construct a bare `rustc` invocation with no flags set.
+    #[track_caller]
+    pub fn bare() -> Self {
         let cmd = setup_common();
         Self { cmd }
     }
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index d3924054401..d26d6fe360d 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -59,7 +59,6 @@ run-make/issue-28595/Makefile
 run-make/issue-33329/Makefile
 run-make/issue-35164/Makefile
 run-make/issue-36710/Makefile
-run-make/issue-37839/Makefile
 run-make/issue-47551/Makefile
 run-make/issue-69368/Makefile
 run-make/issue-83045/Makefile
@@ -143,8 +142,6 @@ run-make/sysroot-crates-are-unstable/Makefile
 run-make/test-benches/Makefile
 run-make/thumb-none-cortex-m/Makefile
 run-make/thumb-none-qemu/Makefile
-run-make/track-path-dep-info/Makefile
-run-make/track-pgo-dep-info/Makefile
 run-make/translation/Makefile
 run-make/type-mismatch-same-crate-name/Makefile
 run-make/unstable-flag-required/Makefile
diff --git a/tests/run-make/issue-37839/Makefile b/tests/run-make/issue-37839/Makefile
deleted file mode 100644
index 6bad27b7bdc..00000000000
--- a/tests/run-make/issue-37839/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-# ignore-cross-compile
-include ../tools.mk
-
-all:
-	$(RUSTC) a.rs && $(RUSTC) b.rs
-	$(BARE_RUSTC) c.rs -L dependency=$(TMPDIR) --extern b=$(TMPDIR)/libb.rlib \
-		--out-dir=$(TMPDIR)
diff --git a/tests/run-make/issue-37839/a.rs b/tests/run-make/proc-macro-three-crates/a.rs
index b5dffac3ff6..b5dffac3ff6 100644
--- a/tests/run-make/issue-37839/a.rs
+++ b/tests/run-make/proc-macro-three-crates/a.rs
diff --git a/tests/run-make/issue-37839/b.rs b/tests/run-make/proc-macro-three-crates/b.rs
index 067f47c1b7a..067f47c1b7a 100644
--- a/tests/run-make/issue-37839/b.rs
+++ b/tests/run-make/proc-macro-three-crates/b.rs
diff --git a/tests/run-make/issue-37839/c.rs b/tests/run-make/proc-macro-three-crates/c.rs
index 4c7ce01b6a0..4c7ce01b6a0 100644
--- a/tests/run-make/issue-37839/c.rs
+++ b/tests/run-make/proc-macro-three-crates/c.rs
diff --git a/tests/run-make/proc-macro-three-crates/rmake.rs b/tests/run-make/proc-macro-three-crates/rmake.rs
new file mode 100644
index 00000000000..d3735540fdd
--- /dev/null
+++ b/tests/run-make/proc-macro-three-crates/rmake.rs
@@ -0,0 +1,20 @@
+// A compiler bug caused the following issue:
+// If a crate A depends on crate B, and crate B
+// depends on crate C, and crate C contains a procedural
+// macro, compiling crate A would fail.
+// This was fixed in #37846, and this test checks
+// that this bug does not make a resurgence.
+
+use run_make_support::{bare_rustc, cwd, rust_lib_name, rustc};
+
+fn main() {
+    rustc().input("a.rs").run();
+    rustc().input("b.rs").run();
+    let curr_dir = cwd().display().to_string();
+    bare_rustc()
+        .input("c.rs")
+        .arg(format!("-Ldependency={curr_dir}"))
+        .extern_("b", cwd().join(rust_lib_name("b")))
+        .out_dir(cwd())
+        .run();
+}
diff --git a/tests/run-make/track-path-dep-info/Makefile b/tests/run-make/track-path-dep-info/Makefile
deleted file mode 100644
index 0d6c9b1d2f0..00000000000
--- a/tests/run-make/track-path-dep-info/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-include ../tools.mk
-
-# FIXME(eddyb) provide `HOST_RUSTC` and `TARGET_RUSTC`
-# instead of hardcoding them everywhere they're needed.
-ifeq ($(IS_MUSL_HOST),1)
-ADDITIONAL_ARGS := $(RUSTFLAGS)
-endif
-
-all:
-	# Proc macro
-	$(BARE_RUSTC) $(ADDITIONAL_ARGS) --out-dir $(TMPDIR) macro_def.rs
-	EXISTING_PROC_MACRO_ENV=1 $(RUSTC) --emit dep-info macro_use.rs
-	$(CGREP) "emojis.txt:" < $(TMPDIR)/macro_use.d
diff --git a/tests/run-make/track-path-dep-info/rmake.rs b/tests/run-make/track-path-dep-info/rmake.rs
new file mode 100644
index 00000000000..f108dc66051
--- /dev/null
+++ b/tests/run-make/track-path-dep-info/rmake.rs
@@ -0,0 +1,13 @@
+// This test checks the functionality of `tracked_path::path`, a procedural macro
+// feature that adds a dependency to another file inside the procmacro. In this case,
+// the text file is added through this method, and the test checks that the compilation
+// output successfully added the file as a dependency.
+// See https://github.com/rust-lang/rust/pull/84029
+
+use run_make_support::{fs_wrapper, rustc};
+
+fn main() {
+    rustc().input("macro_def.rs").run();
+    rustc().env("EXISTING_PROC_MACRO_ENV", "1").emit("dep-info").input("macro_use.rs").run();
+    assert!(fs_wrapper::read_to_string("macro_use.d").contains("emojis.txt:"));
+}
diff --git a/tests/run-make/track-pgo-dep-info/Makefile b/tests/run-make/track-pgo-dep-info/Makefile
deleted file mode 100644
index 3afe3662fa7..00000000000
--- a/tests/run-make/track-pgo-dep-info/Makefile
+++ /dev/null
@@ -1,25 +0,0 @@
-# needs-profiler-support
-
-include ../tools.mk
-
-# FIXME(eddyb) provide `HOST_RUSTC` and `TARGET_RUSTC`
-# instead of hardcoding them everywhere they're needed.
-ifeq ($(IS_MUSL_HOST),1)
-ADDITIONAL_ARGS := $(RUSTFLAGS)
-endif
-
-all:
-	# Generate PGO profiles
-	$(BARE_RUSTC) $(ADDITIONAL_ARGS) -Cprofile-generate=$(TMPDIR)/profiles --out-dir $(TMPDIR) main.rs
-	$(TMPDIR)/main
-
-	# Merge profiles
-	"$(LLVM_BIN_DIR)/llvm-profdata" merge \
-		-o "$(TMPDIR)/merged.profdata" \
-		"$(TMPDIR)/profiles" || exit 1
-
-	# Use the profile
-	$(RUSTC) -Cprofile-use=$(TMPDIR)/merged.profdata --emit dep-info main.rs
-
-	# Check that profile file is in depinfo
-	$(CGREP) "merged.profdata" < $(TMPDIR)/main.d
diff --git a/tests/run-make/track-pgo-dep-info/rmake.rs b/tests/run-make/track-pgo-dep-info/rmake.rs
new file mode 100644
index 00000000000..acfe05cf8ea
--- /dev/null
+++ b/tests/run-make/track-pgo-dep-info/rmake.rs
@@ -0,0 +1,23 @@
+// Emitting dep-info files used to not have any mention of PGO profiles used
+// in compilation, which meant these profiles could be changed without consequence.
+// After changing this in #100801, this test checks that the profile data is successfully
+// included in dep-info emit files.
+// See https://github.com/rust-lang/rust/pull/100801
+
+//@ ignore-cross-compile
+// Reason: the binary is executed
+//@ needs-profiler-support
+
+use run_make_support::{fs_wrapper, llvm_profdata, run, rustc};
+
+fn main() {
+    // Generate the profile-guided-optimization (PGO) profiles
+    rustc().profile_generate("profiles").input("main.rs").run();
+    // Merge the profiles
+    run("main");
+    llvm_profdata().merge().output("merged.profdata").input("profiles").run();
+    // Use the profiles in compilation
+    rustc().profile_use("merged.profdata").emit("dep-info").input("main.rs").run();
+    // Check that the profile file is in the dep-info emit file
+    assert!(fs_wrapper::read_to_string("main.d").contains("merged.profdata"));
+}