Skip to content

Commit 4442fd7

Browse files
committed
Add a run-make test that LLD is not being used by default on the x64 beta/stable channel
1 parent 9ed2ab3 commit 4442fd7

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Ensure that rust-lld is *not* used as the default linker on `x86_64-unknown-linux-gnu` on stable
2+
// or beta.
3+
4+
//@ ignore-nightly
5+
//@ only-x86_64-unknown-linux-gnu
6+
7+
use run_make_support::regex::Regex;
8+
use run_make_support::rustc;
9+
use std::process::Output;
10+
11+
fn main() {
12+
// A regular compilation should not use rust-lld by default. We'll check that by asking the
13+
// linker to display its version number with a link-arg.
14+
let output = rustc()
15+
.env("RUSTC_LOG", "rustc_codegen_ssa::back::link=info")
16+
.link_arg("-Wl,-v")
17+
.input("main.rs")
18+
.run();
19+
assert!(
20+
!find_lld_version_in_logs(output.stderr_utf8()),
21+
"the LLD version string should not be present in the output logs:\n{}",
22+
output.stderr_utf8()
23+
);
24+
}
25+
26+
fn find_lld_version_in_logs(stderr: String) -> bool {
27+
let lld_version_re = Regex::new(r"^LLD [0-9]+\.[0-9]+\.[0-9]+").unwrap();
28+
stderr.lines().any(|line| lld_version_re.is_match(line.trim()))
29+
}

tests/run-make/rust-lld-by-default/rmake.rs tests/run-make/rust-lld-by-default-nightly/rmake.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// Ensure that rust-lld is used as the default linker on `x86_64-unknown-linux-gnu`, and that it can
2-
// also be turned off with a CLI flag.
1+
// Ensure that rust-lld is used as the default linker on `x86_64-unknown-linux-gnu` on the nightly
2+
// channel, and that it can also be turned off with a CLI flag.
33

44
//@ needs-rust-lld
55
//@ ignore-beta

0 commit comments

Comments
 (0)