Skip to content

Commit 3958d9d

Browse files
authored
Fix build-std lto test to run on other platforms (#16550)
The `-C linker-features=-lld` flag is only available on x86_64-unknown-linux-gnu. On all other platforms, this test was failing.
2 parents efcd9f5 + 85d815f commit 3958d9d

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

tests/build-std/main.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ fn basic() {
165165
.build_std_isolated()
166166
.target_host()
167167
.with_stderr_data(str![[r#"
168-
[COMPILING] test v0.0.0 ([..])
169168
...
170169
[COMPILING] foo v0.0.1 ([ROOT]/foo)
171170
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
@@ -211,10 +210,22 @@ fn lto() {
211210
)
212211
.build();
213212

214-
p.cargo("build")
215-
.build_std_arg("std")
216-
.env("RUSTFLAGS", "-C linker-features=-lld")
217-
.run();
213+
let mut exec = p.cargo("build");
214+
exec.build_std_arg("std");
215+
// Include `-lld` to disable the self-contained linker. This test is
216+
// checking for the behavior when using the system linker (like GNU ld or
217+
// older versions of lld) which have problems with the bitcode sections in
218+
// compiler_builtins.
219+
//
220+
// This option is only available on x86-64-unknown-linux-gnu.
221+
if cfg!(all(
222+
target_arch = "x86_64",
223+
target_os = "linux",
224+
target_env = "gnu"
225+
)) {
226+
exec.env("RUSTFLAGS", "-C linker-features=-lld");
227+
}
228+
exec.run();
218229
}
219230

220231
#[cargo_test(build_std_real)]

0 commit comments

Comments
 (0)