about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOneirical <manchot@videotron.ca>2024-07-04 11:58:49 -0400
committerOneirical <manchot@videotron.ca>2024-07-04 12:48:17 -0400
commitf11ab15e9af77b87a4d201eedb2e16f9947b6e85 (patch)
tree172d1ffc3005238fd1a944e87106a27fa67ff760
parente2cf31a6148725bde4ea48acf1e4fe72675257a2 (diff)
downloadrust-f11ab15e9af77b87a4d201eedb2e16f9947b6e85.tar.gz
rust-f11ab15e9af77b87a4d201eedb2e16f9947b6e85.zip
rewrite pass-linker-flags to rmake
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt1
-rw-r--r--tests/run-make/pass-linker-flags/Makefile5
-rw-r--r--tests/run-make/pass-linker-flags/rmake.rs27
3 files changed, 27 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 2da4e476e90..bdb20255dd9 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -108,7 +108,6 @@ run-make/output-type-permutations/Makefile
 run-make/panic-abort-eh_frame/Makefile
 run-make/pass-linker-flags-flavor/Makefile
 run-make/pass-linker-flags-from-dep/Makefile
-run-make/pass-linker-flags/Makefile
 run-make/pass-non-c-like-enum-to-c/Makefile
 run-make/pdb-buildinfo-cl-cmd/Makefile
 run-make/pgo-gen-lto/Makefile
diff --git a/tests/run-make/pass-linker-flags/Makefile b/tests/run-make/pass-linker-flags/Makefile
deleted file mode 100644
index 226943e93bd..00000000000
--- a/tests/run-make/pass-linker-flags/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-include ../tools.mk
-
-all:
-	$(RUSTC) empty.rs -Z unstable-options -l static=l1 -l link-arg=a1 -l static=l2 -l link-arg=a2 -l dylib=d1 -l link-arg=a3 --print link-args | $(CGREP) -e 'l1.*a1.*l2.*a2.*d1.*a3'
-	$(RUSTC) attribute.rs --print link-args | $(CGREP) -e 'l1.*a1.*l2.*a2.*d1.*a3'
diff --git a/tests/run-make/pass-linker-flags/rmake.rs b/tests/run-make/pass-linker-flags/rmake.rs
new file mode 100644
index 00000000000..cc6c5d066de
--- /dev/null
+++ b/tests/run-make/pass-linker-flags/rmake.rs
@@ -0,0 +1,27 @@
+// This test checks the proper function of `-l link-arg=NAME`, which, unlike
+// -C link-arg, is supposed to guarantee that the order relative to other -l
+// options will be respected. In this test, compilation fails (because none of the
+// link arguments like `a1` exist), but it is still checked if the output contains the
+// link arguments in the exact order they were passed in. `attribute.rs` is a variant
+// of the test where the flags are defined in the rust file itself.
+// See https://github.com/rust-lang/rust/issues/99427
+
+use run_make_support::{regex, rustc};
+
+fn main() {
+    let out = rustc()
+        .input("empty.rs")
+        .arg("-Zunstable-options")
+        .args(&["-l", "static=l1"])
+        .arg("-llink-arg=a1")
+        .arg("-lstatic=l2")
+        .arg("-llink-arg=a2")
+        .arg("-ldylib=d1")
+        .arg("-llink-arg=a3")
+        .print("link-args")
+        .run_unchecked()
+        .stdout_utf8();
+    let out2 = rustc().input("attribute.rs").print("link-args").run_unchecked().stdout_utf8();
+    let re = regex::Regex::new("l1.*a1.*l2.*a2.*d1.*a3").unwrap();
+    assert!(re.is_match(&out) && re.is_match(&out2));
+}