Skip to content

Commit ac385e3

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 ac385e3

File tree

4 files changed

+31
-2
lines changed

4 files changed

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

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)