Skip to content

Commit 2911b93

Browse files
authored
Rollup merge of #84865 - petrochenkov:llthread, r=Mark-Simulacrum
rustbuild: Pass a `threads` flag that works to windows-gnu lld MinGW driver for COFF LLD doesn't currently translate GNU-style `--threads=N` to native `/threads:N`, so we have to pass the option in its native form to avoid an error. Also pass the `threads` flag to lld-link (windows-msvc lld) as well.
2 parents 6b4bc2b + f9eda61 commit 2911b93

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

Diff for: src/bootstrap/test.rs

+15-8
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,19 @@ struct Compiletest {
11101110
compare_mode: Option<&'static str>,
11111111
}
11121112

1113+
impl Compiletest {
1114+
fn add_lld_flags(builder: &Builder<'_>, target: TargetSelection, flags: &mut Vec<String>) {
1115+
if builder.config.use_lld {
1116+
if builder.is_fuse_ld_lld(target) {
1117+
flags.push("-Clink-arg=-fuse-ld=lld".to_string());
1118+
}
1119+
1120+
let threads = if target.contains("windows") { "/threads:1" } else { "--threads=1" };
1121+
flags.push(format!("-Clink-arg=-Wl,{}", threads));
1122+
}
1123+
}
1124+
}
1125+
11131126
impl Step for Compiletest {
11141127
type Output = ();
11151128

@@ -1250,18 +1263,12 @@ note: if you're sure you want to do this, please open an issue as to why. In the
12501263

12511264
let mut hostflags = flags.clone();
12521265
hostflags.push(format!("-Lnative={}", builder.test_helpers_out(compiler.host).display()));
1253-
if builder.is_fuse_ld_lld(compiler.host) {
1254-
hostflags.push("-Clink-args=-fuse-ld=lld".to_string());
1255-
hostflags.push("-Clink-arg=-Wl,--threads=1".to_string());
1256-
}
1266+
Self::add_lld_flags(builder, compiler.host, &mut hostflags);
12571267
cmd.arg("--host-rustcflags").arg(hostflags.join(" "));
12581268

12591269
let mut targetflags = flags;
12601270
targetflags.push(format!("-Lnative={}", builder.test_helpers_out(target).display()));
1261-
if builder.is_fuse_ld_lld(target) {
1262-
targetflags.push("-Clink-args=-fuse-ld=lld".to_string());
1263-
targetflags.push("-Clink-arg=-Wl,--threads=1".to_string());
1264-
}
1271+
Self::add_lld_flags(builder, target, &mut targetflags);
12651272
cmd.arg("--target-rustcflags").arg(targetflags.join(" "));
12661273

12671274
cmd.arg("--docck-python").arg(builder.python());

0 commit comments

Comments
 (0)