about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRémy Rakic <remy.rakic+github@gmail.com>2024-04-15 18:08:55 +0000
committerRémy Rakic <remy.rakic+github@gmail.com>2024-04-15 18:08:55 +0000
commit8acfe9a1380f73fade8dfe35aa054b3b6870faee (patch)
tree1e6807cca36d4f4805ddb1cdea5aded681df990c
parent8fa6984e8edda921d34620f4eca657dc164c0f6f (diff)
downloadrust-8acfe9a1380f73fade8dfe35aa054b3b6870faee.tar.gz
rust-8acfe9a1380f73fade8dfe35aa054b3b6870faee.zip
add `link_arg` helper to `run_make_support`
and use it in the `rust-lld` tests
-rw-r--r--src/tools/run-make-support/src/rustc.rs6
-rw-r--r--tests/run-make/rust-lld-custom-target/rmake.rs4
-rw-r--r--tests/run-make/rust-lld/rmake.rs6
3 files changed, 11 insertions, 5 deletions
diff --git a/src/tools/run-make-support/src/rustc.rs b/src/tools/run-make-support/src/rustc.rs
index ebda151b908..88e409a588a 100644
--- a/src/tools/run-make-support/src/rustc.rs
+++ b/src/tools/run-make-support/src/rustc.rs
@@ -149,6 +149,12 @@ impl Rustc {
         self
     }
 
+    /// Add an extra argument to the linker invocation, via `-Clink-arg`.
+    pub fn link_arg(&mut self, link_arg: &str) -> &mut Self {
+        self.cmd.arg(format!("-Clink-arg={link_arg}"));
+        self
+    }
+
     #[track_caller]
     pub fn run_fail_assert_exit_code(&mut self, code: i32) -> Output {
         let caller_location = std::panic::Location::caller();
diff --git a/tests/run-make/rust-lld-custom-target/rmake.rs b/tests/run-make/rust-lld-custom-target/rmake.rs
index 1b6e7c65b47..b5341725e36 100644
--- a/tests/run-make/rust-lld-custom-target/rmake.rs
+++ b/tests/run-make/rust-lld-custom-target/rmake.rs
@@ -21,7 +21,7 @@ fn main() {
         .env("RUSTC_LOG", "rustc_codegen_ssa::back::link=info")
         .crate_type("cdylib")
         .target("custom-target.json")
-        .arg("-Clink-args=-Wl,-v")
+        .link_arg("-Wl,-v")
         .input("lib.rs")
         .run();
     assert!(
@@ -35,7 +35,7 @@ fn main() {
         .crate_type("cdylib")
         .target("custom-target.json")
         .arg("-Zlinker-features=-lld")
-        .arg("-Clink-args=-Wl,-v")
+        .link_arg("-Wl,-v")
         .input("lib.rs")
         .run();
     assert!(
diff --git a/tests/run-make/rust-lld/rmake.rs b/tests/run-make/rust-lld/rmake.rs
index 053b580ebd1..acb6d74aaa8 100644
--- a/tests/run-make/rust-lld/rmake.rs
+++ b/tests/run-make/rust-lld/rmake.rs
@@ -19,7 +19,7 @@ fn main() {
         .arg("-Zlinker-features=+lld")
         .arg("-Clink-self-contained=+linker")
         .arg("-Zunstable-options")
-        .arg("-Clink-args=-Wl,-v")
+        .link_arg("-Wl,-v")
         .input("main.rs")
         .run();
     assert!(
@@ -30,7 +30,7 @@ fn main() {
     // It should not be used when we explictly opt-out of lld.
     let output = rustc()
         .env("RUSTC_LOG", "rustc_codegen_ssa::back::link=info")
-        .arg("-Clink-args=-Wl,-v")
+        .link_arg("-Wl,-v")
         .arg("-Zlinker-features=-lld")
         .input("main.rs")
         .run();
@@ -43,7 +43,7 @@ fn main() {
     // times to rustc.
     let output = rustc()
         .env("RUSTC_LOG", "rustc_codegen_ssa::back::link=info")
-        .arg("-Clink-args=-Wl,-v")
+        .link_arg("-Wl,-v")
         .arg("-Clink-self-contained=+linker")
         .arg("-Zunstable-options")
         .arg("-Zlinker-features=-lld")