Skip to content

Commit 7944930

Browse files
committed
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.
1 parent 6066037 commit 7944930

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
@@ -369,7 +369,8 @@ pub struct Config {
369369
pub cflags: String,
370370
pub cxxflags: String,
371371
pub ar: String,
372-
pub linker: Option<String>,
372+
pub target_linker: Option<String>,
373+
pub host_linker: Option<String>,
373374
pub llvm_components: String,
374375

375376
/// 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
@@ -132,7 +132,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
132132
.reqopt("", "cflags", "flags for the C compiler", "FLAGS")
133133
.reqopt("", "cxxflags", "flags for the CXX compiler", "FLAGS")
134134
.optopt("", "ar", "path to an archiver", "PATH")
135-
.optopt("", "linker", "path to a linker", "PATH")
135+
.optopt("", "target-linker", "path to a linker for the target", "PATH")
136+
.optopt("", "host-linker", "path to a linker for the host", "PATH")
136137
.reqopt("", "llvm-components", "list of LLVM components built in", "LIST")
137138
.optopt("", "llvm-bin-dir", "Path to LLVM's `bin` directory", "PATH")
138139
.optopt("", "nodejs", "the name of nodejs", "PATH")
@@ -303,7 +304,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
303304
cflags: matches.opt_str("cflags").unwrap(),
304305
cxxflags: matches.opt_str("cxxflags").unwrap(),
305306
ar: matches.opt_str("ar").unwrap_or_else(|| String::from("ar")),
306-
linker: matches.opt_str("linker"),
307+
target_linker: matches.opt_str("target-linker"),
308+
host_linker: matches.opt_str("host-linker"),
307309
llvm_components: matches.opt_str("llvm-components").unwrap(),
308310
nodejs: matches.opt_str("nodejs"),
309311
npm: matches.opt_str("npm"),
@@ -346,7 +348,8 @@ pub fn log_config(config: &Config) {
346348
logv(c, format!("adb_test_dir: {:?}", config.adb_test_dir));
347349
logv(c, format!("adb_device_status: {}", config.adb_device_status));
348350
logv(c, format!("ar: {}", config.ar));
349-
logv(c, format!("linker: {:?}", config.linker));
351+
logv(c, format!("target-linker: {:?}", config.target_linker));
352+
logv(c, format!("host-linker: {:?}", config.host_linker));
350353
logv(c, format!("verbose: {}", config.verbose));
351354
logv(c, format!("format: {:?}", config.format));
352355
logv(c, "\n".to_string());

src/tools/compiletest/src/runtest.rs

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

1570-
if let Some(ref linker) = self.config.linker {
1570+
if let Some(ref linker) = self.config.target_linker {
15711571
rustdoc.arg(format!("-Clinker={}", linker));
15721572
}
15731573

@@ -2080,10 +2080,15 @@ impl<'test> TestCx<'test> {
20802080

20812081
if self.props.force_host {
20822082
self.maybe_add_external_args(&mut rustc, &self.config.host_rustcflags);
2083+
if !is_rustdoc {
2084+
if let Some(ref linker) = self.config.host_linker {
2085+
rustc.arg(format!("-Clinker={}", linker));
2086+
}
2087+
}
20832088
} else {
20842089
self.maybe_add_external_args(&mut rustc, &self.config.target_rustcflags);
20852090
if !is_rustdoc {
2086-
if let Some(ref linker) = self.config.linker {
2091+
if let Some(ref linker) = self.config.target_linker {
20872092
rustc.arg(format!("-Clinker={}", linker));
20882093
}
20892094
}
@@ -3035,7 +3040,7 @@ impl<'test> TestCx<'test> {
30353040
cmd.env("NODE", node);
30363041
}
30373042

3038-
if let Some(ref linker) = self.config.linker {
3043+
if let Some(ref linker) = self.config.target_linker {
30393044
cmd.env("RUSTC_LINKER", linker);
30403045
}
30413046

0 commit comments

Comments
 (0)