Skip to content

Commit e6e46ba

Browse files
Rollup merge of #110018 - jfgoog:host-and-target-linker, r=wesleywiser
Pass host linker to compiletest. Tests marked `// force-host` were using the default linker, even if a custom linker was configured in config.toml. This change adds a new flag, --host-linker, to compiletest, and renames --linker to --target-linker.
2 parents 90b5597 + 7944930 commit e6e46ba

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

src/bootstrap/test.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1535,7 +1535,10 @@ note: if you're sure you want to do this, please open an issue as to why. In the
15351535
flags.extend(builder.config.cmd.rustc_args().iter().map(|s| s.to_string()));
15361536

15371537
if let Some(linker) = builder.linker(target) {
1538-
cmd.arg("--linker").arg(linker);
1538+
cmd.arg("--target-linker").arg(linker);
1539+
}
1540+
if let Some(linker) = builder.linker(compiler.host) {
1541+
cmd.arg("--host-linker").arg(linker);
15391542
}
15401543

15411544
let mut hostflags = flags.clone();

src/tools/compiletest/src/common.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@ pub struct Config {
313313
pub cflags: String,
314314
pub cxxflags: String,
315315
pub ar: String,
316-
pub linker: Option<String>,
316+
pub target_linker: Option<String>,
317+
pub host_linker: Option<String>,
317318
pub llvm_components: String,
318319

319320
/// Path to a NodeJS executable. Used for JS doctests, emscripten and WASM tests

src/tools/compiletest/src/main.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
134134
.reqopt("", "cflags", "flags for the C compiler", "FLAGS")
135135
.reqopt("", "cxxflags", "flags for the CXX compiler", "FLAGS")
136136
.optopt("", "ar", "path to an archiver", "PATH")
137-
.optopt("", "linker", "path to a linker", "PATH")
137+
.optopt("", "target-linker", "path to a linker for the target", "PATH")
138+
.optopt("", "host-linker", "path to a linker for the host", "PATH")
138139
.reqopt("", "llvm-components", "list of LLVM components built in", "LIST")
139140
.optopt("", "llvm-bin-dir", "Path to LLVM's `bin` directory", "PATH")
140141
.optopt("", "nodejs", "the name of nodejs", "PATH")
@@ -307,7 +308,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
307308
cflags: matches.opt_str("cflags").unwrap(),
308309
cxxflags: matches.opt_str("cxxflags").unwrap(),
309310
ar: matches.opt_str("ar").unwrap_or_else(|| String::from("ar")),
310-
linker: matches.opt_str("linker"),
311+
target_linker: matches.opt_str("target-linker"),
312+
host_linker: matches.opt_str("host-linker"),
311313
llvm_components: matches.opt_str("llvm-components").unwrap(),
312314
nodejs: matches.opt_str("nodejs"),
313315
npm: matches.opt_str("npm"),
@@ -350,7 +352,8 @@ pub fn log_config(config: &Config) {
350352
logv(c, format!("adb_test_dir: {:?}", config.adb_test_dir));
351353
logv(c, format!("adb_device_status: {}", config.adb_device_status));
352354
logv(c, format!("ar: {}", config.ar));
353-
logv(c, format!("linker: {:?}", config.linker));
355+
logv(c, format!("target-linker: {:?}", config.target_linker));
356+
logv(c, format!("host-linker: {:?}", config.host_linker));
354357
logv(c, format!("verbose: {}", config.verbose));
355358
logv(c, format!("format: {:?}", config.format));
356359
logv(c, "\n".to_string());

src/tools/compiletest/src/runtest.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -1570,7 +1570,7 @@ impl<'test> TestCx<'test> {
15701570
rustdoc.arg("--output-format").arg("json").arg("-Zunstable-options");
15711571
}
15721572

1573-
if let Some(ref linker) = self.config.linker {
1573+
if let Some(ref linker) = self.config.target_linker {
15741574
rustdoc.arg(format!("-Clinker={}", linker));
15751575
}
15761576

@@ -2083,10 +2083,15 @@ impl<'test> TestCx<'test> {
20832083

20842084
if self.props.force_host {
20852085
self.maybe_add_external_args(&mut rustc, &self.config.host_rustcflags);
2086+
if !is_rustdoc {
2087+
if let Some(ref linker) = self.config.host_linker {
2088+
rustc.arg(format!("-Clinker={}", linker));
2089+
}
2090+
}
20862091
} else {
20872092
self.maybe_add_external_args(&mut rustc, &self.config.target_rustcflags);
20882093
if !is_rustdoc {
2089-
if let Some(ref linker) = self.config.linker {
2094+
if let Some(ref linker) = self.config.target_linker {
20902095
rustc.arg(format!("-Clinker={}", linker));
20912096
}
20922097
}
@@ -3039,7 +3044,7 @@ impl<'test> TestCx<'test> {
30393044
cmd.env("NODE", node);
30403045
}
30413046

3042-
if let Some(ref linker) = self.config.linker {
3047+
if let Some(ref linker) = self.config.target_linker {
30433048
cmd.env("RUSTC_LINKER", linker);
30443049
}
30453050

0 commit comments

Comments
 (0)