about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOneirical <manchot@videotron.ca>2024-05-24 10:02:53 -0400
committerOneirical <manchot@videotron.ca>2024-06-17 10:43:44 -0400
commit553204d26d800084431f328612da01c3d15ea01f (patch)
tree0a7c3ca892c0cf4092c4d43a72af29146fa7554b
parent9b584a6f6fa7e1ab7c65444a7902578c1786ce18 (diff)
downloadrust-553204d26d800084431f328612da01c3d15ea01f.tar.gz
rust-553204d26d800084431f328612da01c3d15ea01f.zip
Rewrite `link-arg` in rmake.rs
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt1
-rw-r--r--tests/run-make/link-arg/Makefile5
-rw-r--r--tests/run-make/link-arg/rmake.rs24
3 files changed, 24 insertions, 6 deletions
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index fdd0be79a4d..4ef23a19e79 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -109,7 +109,6 @@ run-make/libtest-json/Makefile
 run-make/libtest-junit/Makefile
 run-make/libtest-padding/Makefile
 run-make/libtest-thread-limit/Makefile
-run-make/link-arg/Makefile
 run-make/link-args-order/Makefile
 run-make/link-cfg/Makefile
 run-make/link-dedup/Makefile
diff --git a/tests/run-make/link-arg/Makefile b/tests/run-make/link-arg/Makefile
deleted file mode 100644
index 103527c3e14..00000000000
--- a/tests/run-make/link-arg/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-include ../tools.mk
-RUSTC_FLAGS = -C link-arg="-lfoo" -C link-arg="-lbar" --print link-args
-
-all:
-	$(RUSTC) $(RUSTC_FLAGS) empty.rs | $(CGREP) lfoo lbar
diff --git a/tests/run-make/link-arg/rmake.rs b/tests/run-make/link-arg/rmake.rs
new file mode 100644
index 00000000000..dd496101f6a
--- /dev/null
+++ b/tests/run-make/link-arg/rmake.rs
@@ -0,0 +1,24 @@
+// In 2016, the rustc flag "-C link-arg" was introduced - it can be repeatedly used
+// to add single arguments to the linker. This test passes 2 arguments to the linker using it,
+// then checks that the compiler's output contains the arguments passed to it.
+// This ensures that the compiler successfully parses this flag.
+// See https://github.com/rust-lang/rust/pull/36574
+
+use run_make_support::rustc;
+
+fn main() {
+    let output = String::from_utf8(
+        rustc()
+            .input("empty.rs")
+            .link_arg("-lfoo")
+            .link_arg("-lbar")
+            .print("link-args")
+            .command_output()
+            .stdout,
+    )
+    .unwrap();
+    assert!(
+        output.contains("lfoo") || output.contains("lbar"),
+        "The output did not contain the expected \"lfoo\" or \"lbar\" strings."
+    );
+}