about summary refs log tree commit diff
path: root/tests/run-make
diff options
context:
space:
mode:
authorMichael Baikov <manpacket@gmail.com>2024-04-06 11:22:21 -0400
committerMichael Baikov <manpacket@gmail.com>2024-04-19 08:31:41 -0400
commitc8390cdbfaccc55aa374222e39cdf9092a1e5ff6 (patch)
tree577135d1f960834ad4bc2b8b53278096ba6aa106 /tests/run-make
parent43a0686f8d18fa068e2689d5bd889bd2670dbf50 (diff)
downloadrust-c8390cdbfaccc55aa374222e39cdf9092a1e5ff6.tar.gz
rust-c8390cdbfaccc55aa374222e39cdf9092a1e5ff6.zip
Show files produced by --emit foo in json artifact notifications
Diffstat (limited to 'tests/run-make')
-rw-r--r--tests/run-make/notify-all-emit-artifacts/lib.rs21
-rw-r--r--tests/run-make/notify-all-emit-artifacts/rmake.rs45
2 files changed, 66 insertions, 0 deletions
diff --git a/tests/run-make/notify-all-emit-artifacts/lib.rs b/tests/run-make/notify-all-emit-artifacts/lib.rs
new file mode 100644
index 00000000000..6ed194204b4
--- /dev/null
+++ b/tests/run-make/notify-all-emit-artifacts/lib.rs
@@ -0,0 +1,21 @@
+fn one() -> usize {
+    1
+}
+
+pub mod a {
+    pub fn two() -> usize {
+        ::one() + ::one()
+    }
+}
+
+pub mod b {
+    pub fn three() -> usize {
+        ::one() + ::a::two()
+    }
+}
+
+#[inline(never)]
+pub fn main() {
+    a::two();
+    b::three();
+}
diff --git a/tests/run-make/notify-all-emit-artifacts/rmake.rs b/tests/run-make/notify-all-emit-artifacts/rmake.rs
new file mode 100644
index 00000000000..c866d9179f9
--- /dev/null
+++ b/tests/run-make/notify-all-emit-artifacts/rmake.rs
@@ -0,0 +1,45 @@
+// rust should produce artifact notifications about files it was asked to --emit.
+//
+// It should work in incremental mode both on the first pass where files are generated as well
+// as on subsequent passes where they are taken from the incremental cache
+//
+// See <https://internals.rust-lang.org/t/easier-access-to-files-generated-by-emit-foo/20477>
+extern crate run_make_support;
+
+use run_make_support::{rustc, tmp_dir};
+
+fn main() {
+    let inc_dir = tmp_dir();
+
+    // With single codegen unit files are renamed to match the source file name
+    for _ in 0..=1 {
+        let output = rustc()
+            .input("lib.rs")
+            .emit("obj,asm,llvm-ir,llvm-bc,mir")
+            .codegen_units(1)
+            .json("artifacts")
+            .error_format("json")
+            .incremental(&inc_dir)
+            .run();
+        let stderr = String::from_utf8_lossy(&output.stderr);
+        for file in &["lib.o", "lib.ll", "lib.bc", "lib.s"] {
+            assert!(stderr.contains(file), "No {:?} in {:?}", file, stderr);
+        }
+    }
+
+    // with multiple codegen units files keep codegen unit id part.
+    for _ in 0..=1 {
+        let output = rustc()
+            .input("lib.rs")
+            .emit("obj,asm,llvm-ir,llvm-bc,mir")
+            .codegen_units(2)
+            .json("artifacts")
+            .error_format("json")
+            .incremental(&inc_dir)
+            .run();
+        let stderr = String::from_utf8_lossy(&output.stderr);
+        for file in &["rcgu.o", "rcgu.ll", "rcgu.bc", "rcgu.s"] {
+            assert!(stderr.contains(file), "No {:?} in {:?}", file, stderr);
+        }
+    }
+}