about summary refs log tree commit diff
diff options
context:
space:
mode:
author许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com>2024-05-29 03:25:10 +0100
committerGitHub <noreply@github.com>2024-05-29 03:25:10 +0100
commit7e93a632a82b44a7ff05b0bf1d62bba01503dfe6 (patch)
tree10ef0f4ff43353f4871b26e9389e20c67ee3b621
parent305137de1825ca44d6aece42fcaffa8bc5bfb3be (diff)
parentcc97376adeba686f6d1e1d77c290a02d9d688a68 (diff)
downloadrust-7e93a632a82b44a7ff05b0bf1d62bba01503dfe6.tar.gz
rust-7e93a632a82b44a7ff05b0bf1d62bba01503dfe6.zip
Rollup merge of #125638 - Oneirical:lets-find-some-tests, r=jieyouxu
Rewrite `lto-smoke`, `simple-rlib` and `mixing-deps` `run-make` tests in `rmake.rs` format

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt3
-rw-r--r--tests/run-make/lto-smoke/Makefile31
-rw-r--r--tests/run-make/lto-smoke/rmake.rs16
-rw-r--r--tests/run-make/mixing-deps/Makefile8
-rw-r--r--tests/run-make/mixing-deps/rmake.rs13
-rw-r--r--tests/run-make/simple-rlib/Makefile6
-rw-r--r--tests/run-make/simple-rlib/bar.rs1
-rw-r--r--tests/run-make/simple-rlib/foo.rs5
-rw-r--r--tests/ui/imports/auxiliary/simple-rlib.rs2
-rw-r--r--tests/ui/imports/simple-rlib-import.rs12
10 files changed, 43 insertions, 54 deletions
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index 9ca27834cf7..75cd2b4c773 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -144,7 +144,6 @@ run-make/lto-linkage-used-attr/Makefile
 run-make/lto-no-link-whole-rlib/Makefile
 run-make/lto-readonly-lib/Makefile
 run-make/lto-smoke-c/Makefile
-run-make/lto-smoke/Makefile
 run-make/macos-deployment-target/Makefile
 run-make/macos-fat-archive/Makefile
 run-make/manual-crate-name/Makefile
@@ -156,7 +155,6 @@ run-make/min-global-align/Makefile
 run-make/mingw-export-call-convention/Makefile
 run-make/mismatching-target-triples/Makefile
 run-make/missing-crate-dependency/Makefile
-run-make/mixing-deps/Makefile
 run-make/mixing-formats/Makefile
 run-make/mixing-libs/Makefile
 run-make/msvc-opt-minsize/Makefile
@@ -238,7 +236,6 @@ run-make/short-ice/Makefile
 run-make/silly-file-names/Makefile
 run-make/simd-ffi/Makefile
 run-make/simple-dylib/Makefile
-run-make/simple-rlib/Makefile
 run-make/split-debuginfo/Makefile
 run-make/stable-symbol-names/Makefile
 run-make/static-dylib-by-default/Makefile
diff --git a/tests/run-make/lto-smoke/Makefile b/tests/run-make/lto-smoke/Makefile
deleted file mode 100644
index 13a09fce734..00000000000
--- a/tests/run-make/lto-smoke/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-# ignore-cross-compile
-include ../tools.mk
-
-all: noparam bool_true bool_false thin fat
-
-noparam:
-	$(RUSTC) lib.rs
-	$(RUSTC) main.rs -C lto
-	$(call RUN,main)
-
-bool_true:
-	$(RUSTC) lib.rs
-	$(RUSTC) main.rs -C lto=yes
-	$(call RUN,main)
-
-
-bool_false:
-	$(RUSTC) lib.rs
-	$(RUSTC) main.rs -C lto=off
-	$(call RUN,main)
-
-thin:
-	$(RUSTC) lib.rs
-	$(RUSTC) main.rs -C lto=thin
-	$(call RUN,main)
-
-fat:
-	$(RUSTC) lib.rs
-	$(RUSTC) main.rs -C lto=fat
-	$(call RUN,main)
-
diff --git a/tests/run-make/lto-smoke/rmake.rs b/tests/run-make/lto-smoke/rmake.rs
new file mode 100644
index 00000000000..692945135cd
--- /dev/null
+++ b/tests/run-make/lto-smoke/rmake.rs
@@ -0,0 +1,16 @@
+// A simple smoke test to check that link time optimization
+// (LTO) is accepted by the compiler, and that
+// passing its various flags still results in successful compilation.
+// See https://github.com/rust-lang/rust/issues/10741
+
+//@ ignore-cross-compile
+
+use run_make_support::rustc;
+
+fn main() {
+    let lto_flags = ["-Clto", "-Clto=yes", "-Clto=off", "-Clto=thin", "-Clto=fat"];
+    for flag in lto_flags {
+        rustc().input("lib.rs").run();
+        rustc().input("main.rs").arg(flag).run();
+    }
+}
diff --git a/tests/run-make/mixing-deps/Makefile b/tests/run-make/mixing-deps/Makefile
deleted file mode 100644
index c2a5a2a0abb..00000000000
--- a/tests/run-make/mixing-deps/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-# ignore-cross-compile
-include ../tools.mk
-
-all:
-	$(RUSTC) both.rs -C prefer-dynamic
-	$(RUSTC) dylib.rs -C prefer-dynamic
-	$(RUSTC) prog.rs
-	$(call RUN,prog)
diff --git a/tests/run-make/mixing-deps/rmake.rs b/tests/run-make/mixing-deps/rmake.rs
new file mode 100644
index 00000000000..fb31bbef9d1
--- /dev/null
+++ b/tests/run-make/mixing-deps/rmake.rs
@@ -0,0 +1,13 @@
+// This test invokes the main function in prog.rs, which has dependencies
+// in both an rlib and a dylib. This test checks that these different library
+// types can be successfully mixed.
+//@ ignore-cross-compile
+
+use run_make_support::{run, rustc};
+
+fn main() {
+    rustc().input("both.rs").arg("-Cprefer-dynamic").run();
+    rustc().input("dylib.rs").arg("-Cprefer-dynamic").run();
+    rustc().input("prog.rs").run();
+    run("prog");
+}
diff --git a/tests/run-make/simple-rlib/Makefile b/tests/run-make/simple-rlib/Makefile
deleted file mode 100644
index 28df61a1547..00000000000
--- a/tests/run-make/simple-rlib/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-# ignore-cross-compile
-include ../tools.mk
-all:
-	$(RUSTC) bar.rs --crate-type=rlib
-	$(RUSTC) foo.rs
-	$(call RUN,foo)
diff --git a/tests/run-make/simple-rlib/bar.rs b/tests/run-make/simple-rlib/bar.rs
deleted file mode 100644
index c5c0bc606cd..00000000000
--- a/tests/run-make/simple-rlib/bar.rs
+++ /dev/null
@@ -1 +0,0 @@
-pub fn bar() {}
diff --git a/tests/run-make/simple-rlib/foo.rs b/tests/run-make/simple-rlib/foo.rs
deleted file mode 100644
index 8d68535e3b6..00000000000
--- a/tests/run-make/simple-rlib/foo.rs
+++ /dev/null
@@ -1,5 +0,0 @@
-extern crate bar;
-
-fn main() {
-    bar::bar();
-}
diff --git a/tests/ui/imports/auxiliary/simple-rlib.rs b/tests/ui/imports/auxiliary/simple-rlib.rs
new file mode 100644
index 00000000000..28a6273840f
--- /dev/null
+++ b/tests/ui/imports/auxiliary/simple-rlib.rs
@@ -0,0 +1,2 @@
+#![crate_type = "rlib"]
+pub fn bar() {}
diff --git a/tests/ui/imports/simple-rlib-import.rs b/tests/ui/imports/simple-rlib-import.rs
new file mode 100644
index 00000000000..6eab7ba04cf
--- /dev/null
+++ b/tests/ui/imports/simple-rlib-import.rs
@@ -0,0 +1,12 @@
+// A simple test, where foo.rs has a dependency
+// on the rlib (a static Rust-specific library format) bar.rs. If the test passes,
+// rlibs can be built and linked into another file successfully..
+
+//@ aux-crate:bar=simple-rlib.rs
+//@ run-pass
+
+extern crate bar;
+
+fn main() {
+    bar::bar();
+}