Skip to content

Commit 8acfe9a

Browse files
committed
add link_arg helper to run_make_support
and use it in the `rust-lld` tests
1 parent 8fa6984 commit 8acfe9a

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/tools/run-make-support/src/rustc.rs

+6
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ impl Rustc {
149149
self
150150
}
151151

152+
/// Add an extra argument to the linker invocation, via `-Clink-arg`.
153+
pub fn link_arg(&mut self, link_arg: &str) -> &mut Self {
154+
self.cmd.arg(format!("-Clink-arg={link_arg}"));
155+
self
156+
}
157+
152158
#[track_caller]
153159
pub fn run_fail_assert_exit_code(&mut self, code: i32) -> Output {
154160
let caller_location = std::panic::Location::caller();

tests/run-make/rust-lld-custom-target/rmake.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn main() {
2121
.env("RUSTC_LOG", "rustc_codegen_ssa::back::link=info")
2222
.crate_type("cdylib")
2323
.target("custom-target.json")
24-
.arg("-Clink-args=-Wl,-v")
24+
.link_arg("-Wl,-v")
2525
.input("lib.rs")
2626
.run();
2727
assert!(
@@ -35,7 +35,7 @@ fn main() {
3535
.crate_type("cdylib")
3636
.target("custom-target.json")
3737
.arg("-Zlinker-features=-lld")
38-
.arg("-Clink-args=-Wl,-v")
38+
.link_arg("-Wl,-v")
3939
.input("lib.rs")
4040
.run();
4141
assert!(

tests/run-make/rust-lld/rmake.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn main() {
1919
.arg("-Zlinker-features=+lld")
2020
.arg("-Clink-self-contained=+linker")
2121
.arg("-Zunstable-options")
22-
.arg("-Clink-args=-Wl,-v")
22+
.link_arg("-Wl,-v")
2323
.input("main.rs")
2424
.run();
2525
assert!(
@@ -30,7 +30,7 @@ fn main() {
3030
// It should not be used when we explictly opt-out of lld.
3131
let output = rustc()
3232
.env("RUSTC_LOG", "rustc_codegen_ssa::back::link=info")
33-
.arg("-Clink-args=-Wl,-v")
33+
.link_arg("-Wl,-v")
3434
.arg("-Zlinker-features=-lld")
3535
.input("main.rs")
3636
.run();
@@ -43,7 +43,7 @@ fn main() {
4343
// times to rustc.
4444
let output = rustc()
4545
.env("RUSTC_LOG", "rustc_codegen_ssa::back::link=info")
46-
.arg("-Clink-args=-Wl,-v")
46+
.link_arg("-Wl,-v")
4747
.arg("-Clink-self-contained=+linker")
4848
.arg("-Zunstable-options")
4949
.arg("-Zlinker-features=-lld")

0 commit comments

Comments
 (0)