1
Fork 0

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.
This commit is contained in:
Michael Goulet 2023-04-11 20:28:47 -07:00 committed by GitHub
commit e6e46bae6f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 8 deletions

View file

@ -1535,7 +1535,10 @@ note: if you're sure you want to do this, please open an issue as to why. In the
flags.extend(builder.config.cmd.rustc_args().iter().map(|s| s.to_string())); flags.extend(builder.config.cmd.rustc_args().iter().map(|s| s.to_string()));
if let Some(linker) = builder.linker(target) { if let Some(linker) = builder.linker(target) {
cmd.arg("--linker").arg(linker); cmd.arg("--target-linker").arg(linker);
}
if let Some(linker) = builder.linker(compiler.host) {
cmd.arg("--host-linker").arg(linker);
} }
let mut hostflags = flags.clone(); let mut hostflags = flags.clone();

View file

@ -313,7 +313,8 @@ pub struct Config {
pub cflags: String, pub cflags: String,
pub cxxflags: String, pub cxxflags: String,
pub ar: String, pub ar: String,
pub linker: Option<String>, pub target_linker: Option<String>,
pub host_linker: Option<String>,
pub llvm_components: String, pub llvm_components: String,
/// Path to a NodeJS executable. Used for JS doctests, emscripten and WASM tests /// Path to a NodeJS executable. Used for JS doctests, emscripten and WASM tests

View file

@ -134,7 +134,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
.reqopt("", "cflags", "flags for the C compiler", "FLAGS") .reqopt("", "cflags", "flags for the C compiler", "FLAGS")
.reqopt("", "cxxflags", "flags for the CXX compiler", "FLAGS") .reqopt("", "cxxflags", "flags for the CXX compiler", "FLAGS")
.optopt("", "ar", "path to an archiver", "PATH") .optopt("", "ar", "path to an archiver", "PATH")
.optopt("", "linker", "path to a linker", "PATH") .optopt("", "target-linker", "path to a linker for the target", "PATH")
.optopt("", "host-linker", "path to a linker for the host", "PATH")
.reqopt("", "llvm-components", "list of LLVM components built in", "LIST") .reqopt("", "llvm-components", "list of LLVM components built in", "LIST")
.optopt("", "llvm-bin-dir", "Path to LLVM's `bin` directory", "PATH") .optopt("", "llvm-bin-dir", "Path to LLVM's `bin` directory", "PATH")
.optopt("", "nodejs", "the name of nodejs", "PATH") .optopt("", "nodejs", "the name of nodejs", "PATH")
@ -307,7 +308,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
cflags: matches.opt_str("cflags").unwrap(), cflags: matches.opt_str("cflags").unwrap(),
cxxflags: matches.opt_str("cxxflags").unwrap(), cxxflags: matches.opt_str("cxxflags").unwrap(),
ar: matches.opt_str("ar").unwrap_or_else(|| String::from("ar")), ar: matches.opt_str("ar").unwrap_or_else(|| String::from("ar")),
linker: matches.opt_str("linker"), target_linker: matches.opt_str("target-linker"),
host_linker: matches.opt_str("host-linker"),
llvm_components: matches.opt_str("llvm-components").unwrap(), llvm_components: matches.opt_str("llvm-components").unwrap(),
nodejs: matches.opt_str("nodejs"), nodejs: matches.opt_str("nodejs"),
npm: matches.opt_str("npm"), npm: matches.opt_str("npm"),
@ -350,7 +352,8 @@ pub fn log_config(config: &Config) {
logv(c, format!("adb_test_dir: {:?}", config.adb_test_dir)); logv(c, format!("adb_test_dir: {:?}", config.adb_test_dir));
logv(c, format!("adb_device_status: {}", config.adb_device_status)); logv(c, format!("adb_device_status: {}", config.adb_device_status));
logv(c, format!("ar: {}", config.ar)); logv(c, format!("ar: {}", config.ar));
logv(c, format!("linker: {:?}", config.linker)); logv(c, format!("target-linker: {:?}", config.target_linker));
logv(c, format!("host-linker: {:?}", config.host_linker));
logv(c, format!("verbose: {}", config.verbose)); logv(c, format!("verbose: {}", config.verbose));
logv(c, format!("format: {:?}", config.format)); logv(c, format!("format: {:?}", config.format));
logv(c, "\n".to_string()); logv(c, "\n".to_string());

View file

@ -1570,7 +1570,7 @@ impl<'test> TestCx<'test> {
rustdoc.arg("--output-format").arg("json").arg("-Zunstable-options"); rustdoc.arg("--output-format").arg("json").arg("-Zunstable-options");
} }
if let Some(ref linker) = self.config.linker { if let Some(ref linker) = self.config.target_linker {
rustdoc.arg(format!("-Clinker={}", linker)); rustdoc.arg(format!("-Clinker={}", linker));
} }
@ -2083,10 +2083,15 @@ impl<'test> TestCx<'test> {
if self.props.force_host { if self.props.force_host {
self.maybe_add_external_args(&mut rustc, &self.config.host_rustcflags); self.maybe_add_external_args(&mut rustc, &self.config.host_rustcflags);
if !is_rustdoc {
if let Some(ref linker) = self.config.host_linker {
rustc.arg(format!("-Clinker={}", linker));
}
}
} else { } else {
self.maybe_add_external_args(&mut rustc, &self.config.target_rustcflags); self.maybe_add_external_args(&mut rustc, &self.config.target_rustcflags);
if !is_rustdoc { if !is_rustdoc {
if let Some(ref linker) = self.config.linker { if let Some(ref linker) = self.config.target_linker {
rustc.arg(format!("-Clinker={}", linker)); rustc.arg(format!("-Clinker={}", linker));
} }
} }
@ -3039,7 +3044,7 @@ impl<'test> TestCx<'test> {
cmd.env("NODE", node); cmd.env("NODE", node);
} }
if let Some(ref linker) = self.config.linker { if let Some(ref linker) = self.config.target_linker {
cmd.env("RUSTC_LINKER", linker); cmd.env("RUSTC_LINKER", linker);
} }