summaryrefslogtreecommitdiffstats
path: root/vendor/cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /vendor/cc
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/cc')
-rw-r--r--vendor/cc/.cargo-checksum.json2
-rw-r--r--vendor/cc/Cargo.lock6
-rw-r--r--vendor/cc/Cargo.toml2
-rw-r--r--vendor/cc/src/bin/gcc-shim.rs68
-rw-r--r--vendor/cc/src/lib.rs320
-rw-r--r--vendor/cc/src/windows_registry.rs4
6 files changed, 285 insertions, 117 deletions
diff --git a/vendor/cc/.cargo-checksum.json b/vendor/cc/.cargo-checksum.json
index 4dc2fe239..347071415 100644
--- a/vendor/cc/.cargo-checksum.json
+++ b/vendor/cc/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.lock":"23c26d62ba5114f5ac6e7ffa3ea233cea77e5cb7f98d9f056f40fe2c49971f67","Cargo.toml":"fd4b39488866b6717476fadc460ff91c89511628080769516eec452c0def8bc7","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"58af5106352aafa62175a90f8a5f25fa114028bf909220dc0735d79745999ec1","src/bin/gcc-shim.rs":"b77907875029494b6288841c3aed2e4939ed40708c7f597fca5c9e2570490ca6","src/com.rs":"29d0dee08a656ab1a4cc3e5fe24542e0fab5c1373cbc9b05059f7572cf9b8313","src/lib.rs":"e0cc228db97675d6a0d86b219a20e9e48925a1ccbfd9e9fd038ccf6ef129957e","src/registry.rs":"98ae2b71781acc49297e5544fa0cf059f735636f8f1338edef8dbf7232443945","src/setup_config.rs":"72deaf1927c0b713fd5c2b2d5b8f0ea3a303a00fda1579427895cac26a94122d","src/vs_instances.rs":"2d3f8278a803b0e7052f4eeb1979b29f963dd0143f4458e2cb5f33c4e5f0963b","src/winapi.rs":"e128e95b2d39ae7a02f54a7e25d33c488c14759b9f1a50a449e10545856950c3","src/windows_registry.rs":"c0340379c1f540cf96f45bbd4cf8fc28db555826f30ac937b75b87e4377b716b","tests/cc_env.rs":"e02b3b0824ad039b47e4462c5ef6dbe6c824c28e7953af94a0f28f7b5158042e","tests/cflags.rs":"57f06eb5ce1557e5b4a032d0c4673e18fbe6f8d26c1deb153126e368b96b41b3","tests/cxxflags.rs":"c2c6c6d8a0d7146616fa1caed26876ee7bc9fcfffd525eb4743593cade5f3371","tests/support/mod.rs":"a3c8d116973bb16066bf6ec4de5143183f97de7aad085d85f8118a2eaac3e1e0","tests/test.rs":"61fb35ae6dd5cf506ada000bdd82c92e9f8eac9cc053b63e83d3f897436fbf8f"},"package":"a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d"} \ No newline at end of file
+{"files":{"Cargo.lock":"dddb9c49058d411a098e98dc1c06e3bc89f859a2080d96c11b11aec67394bb8c","Cargo.toml":"1953a8bc4b98e351fe75917c151b1e08a46531d562aebba25a90add4aadecac2","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"58af5106352aafa62175a90f8a5f25fa114028bf909220dc0735d79745999ec1","src/bin/gcc-shim.rs":"36dc4e447428e73c548cc7106ca1e8f282c098463b014e13a729a44445de4880","src/com.rs":"29d0dee08a656ab1a4cc3e5fe24542e0fab5c1373cbc9b05059f7572cf9b8313","src/lib.rs":"17a4659710aa290c4ed9c23063c7b202c5bcf2a84de33aa1f01fc6fded69a1f8","src/registry.rs":"98ae2b71781acc49297e5544fa0cf059f735636f8f1338edef8dbf7232443945","src/setup_config.rs":"72deaf1927c0b713fd5c2b2d5b8f0ea3a303a00fda1579427895cac26a94122d","src/vs_instances.rs":"2d3f8278a803b0e7052f4eeb1979b29f963dd0143f4458e2cb5f33c4e5f0963b","src/winapi.rs":"e128e95b2d39ae7a02f54a7e25d33c488c14759b9f1a50a449e10545856950c3","src/windows_registry.rs":"1f973f804b4b451e48ff6d98ce660355772f164dfdf79a6ae514645c7c764005","tests/cc_env.rs":"e02b3b0824ad039b47e4462c5ef6dbe6c824c28e7953af94a0f28f7b5158042e","tests/cflags.rs":"57f06eb5ce1557e5b4a032d0c4673e18fbe6f8d26c1deb153126e368b96b41b3","tests/cxxflags.rs":"c2c6c6d8a0d7146616fa1caed26876ee7bc9fcfffd525eb4743593cade5f3371","tests/support/mod.rs":"a3c8d116973bb16066bf6ec4de5143183f97de7aad085d85f8118a2eaac3e1e0","tests/test.rs":"61fb35ae6dd5cf506ada000bdd82c92e9f8eac9cc053b63e83d3f897436fbf8f"},"package":"50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"} \ No newline at end of file
diff --git a/vendor/cc/Cargo.lock b/vendor/cc/Cargo.lock
index 2d065bc6a..0beba240c 100644
--- a/vendor/cc/Cargo.lock
+++ b/vendor/cc/Cargo.lock
@@ -10,7 +10,7 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "cc"
-version = "1.0.78"
+version = "1.0.79"
dependencies = [
"jobserver",
"tempfile",
@@ -51,9 +51,9 @@ dependencies = [
[[package]]
name = "libc"
-version = "0.2.138"
+version = "0.2.139"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8"
+checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
[[package]]
name = "redox_syscall"
diff --git a/vendor/cc/Cargo.toml b/vendor/cc/Cargo.toml
index c4ec0bf79..bbdd986d0 100644
--- a/vendor/cc/Cargo.toml
+++ b/vendor/cc/Cargo.toml
@@ -12,7 +12,7 @@
[package]
edition = "2018"
name = "cc"
-version = "1.0.78"
+version = "1.0.79"
authors = ["Alex Crichton <alex@alexcrichton.com>"]
exclude = ["/.github"]
description = """
diff --git a/vendor/cc/src/bin/gcc-shim.rs b/vendor/cc/src/bin/gcc-shim.rs
index 1731df82e..e5b537258 100644
--- a/vendor/cc/src/bin/gcc-shim.rs
+++ b/vendor/cc/src/bin/gcc-shim.rs
@@ -2,7 +2,7 @@
use std::env;
use std::fs::File;
-use std::io::prelude::*;
+use std::io::{self, prelude::*};
use std::path::PathBuf;
fn main() {
@@ -10,39 +10,61 @@ fn main() {
let program = args.next().expect("Unexpected empty args");
let out_dir = PathBuf::from(
- env::var_os("GCCTEST_OUT_DIR").expect(&format!("{}: GCCTEST_OUT_DIR not found", program)),
+ env::var_os("GCCTEST_OUT_DIR")
+ .unwrap_or_else(|| panic!("{}: GCCTEST_OUT_DIR not found", program)),
);
// Find the first nonexistent candidate file to which the program's args can be written.
- for i in 0.. {
- let candidate = &out_dir.join(format!("out{}", i));
+ let candidate = (0..).find_map(|i| {
+ let candidate = out_dir.join(format!("out{}", i));
- // If the file exists, commands have already run. Try again.
if candidate.exists() {
- continue;
+ // If the file exists, commands have already run. Try again.
+ None
+ } else {
+ Some(candidate)
}
+ }).unwrap_or_else(|| panic!("Cannot find the first nonexistent candidate file to which the program's args can be written under out_dir '{}'", out_dir.display()));
- // Create a file and record the args passed to the command.
- let mut f = File::create(candidate).expect(&format!(
- "{}: can't create candidate: {}",
+ // Create a file and record the args passed to the command.
+ let f = File::create(&candidate).unwrap_or_else(|e| {
+ panic!(
+ "{}: can't create candidate: {}, error: {}",
program,
- candidate.to_string_lossy()
- ));
+ candidate.display(),
+ e
+ )
+ });
+ let mut f = io::BufWriter::new(f);
+
+ (|| {
for arg in args {
- writeln!(f, "{}", arg).expect(&format!(
- "{}: can't write to candidate: {}",
- program,
- candidate.to_string_lossy()
- ));
+ writeln!(f, "{}", arg)?;
}
- break;
- }
+
+ f.flush()?;
+
+ let mut f = f.into_inner()?;
+ f.flush()?;
+ f.sync_all()
+ })()
+ .unwrap_or_else(|e| {
+ panic!(
+ "{}: can't write to candidate: {}, error: {}",
+ program,
+ candidate.display(),
+ e
+ )
+ });
// Create a file used by some tests.
let path = &out_dir.join("libfoo.a");
- File::create(path).expect(&format!(
- "{}: can't create libfoo.a: {}",
- program,
- path.to_string_lossy()
- ));
+ File::create(path).unwrap_or_else(|e| {
+ panic!(
+ "{}: can't create libfoo.a: {}, error: {}",
+ program,
+ path.display(),
+ e
+ )
+ });
}
diff --git a/vendor/cc/src/lib.rs b/vendor/cc/src/lib.rs
index 1ebd2cc7a..abc5d7a95 100644
--- a/vendor/cc/src/lib.rs
+++ b/vendor/cc/src/lib.rs
@@ -115,6 +115,7 @@ pub struct Build {
env: Vec<(OsString, OsString)>,
compiler: Option<PathBuf>,
archiver: Option<PathBuf>,
+ ranlib: Option<PathBuf>,
cargo_metadata: bool,
link_lib_modifiers: Vec<String>,
pic: Option<bool>,
@@ -320,6 +321,7 @@ impl Build {
env: Vec::new(),
compiler: None,
archiver: None,
+ ranlib: None,
cargo_metadata: true,
link_lib_modifiers: Vec::new(),
pic: None,
@@ -538,7 +540,7 @@ impl Build {
cmd.arg(&src);
let output = cmd.output()?;
- let is_supported = output.stderr.is_empty();
+ let is_supported = output.status.success() && output.stderr.is_empty();
known_status.insert(flag.to_owned(), is_supported);
Ok(is_supported)
@@ -916,6 +918,17 @@ impl Build {
self.archiver = Some(archiver.as_ref().to_owned());
self
}
+
+ /// Configures the tool used to index archives.
+ ///
+ /// This option is automatically determined from the target platform or a
+ /// number of environment variables, so it's not required to call this
+ /// function.
+ pub fn ranlib<P: AsRef<Path>>(&mut self, ranlib: P) -> &mut Build {
+ self.ranlib = Some(ranlib.as_ref().to_owned());
+ self
+ }
+
/// Define whether metadata should be emitted for cargo allowing it to
/// automatically link the binary. Defaults to `true`.
///
@@ -2094,7 +2107,11 @@ impl Build {
// Non-msvc targets (those using `ar`) need a separate step to add
// the symbol table to archives since our construction command of
// `cq` doesn't add it for us.
- let (mut ar, cmd) = self.get_ar()?;
+ let (mut ar, cmd, _any_flags) = self.get_ar()?;
+
+ // NOTE: We add `s` even if flags were passed using $ARFLAGS/ar_flag, because `s`
+ // here represents a _mode_, not an arbitrary flag. Further discussion of this choice
+ // can be seen in https://github.com/rust-lang/cc-rs/pull/763.
run(ar.arg("s").arg(dst), &cmd)?;
}
@@ -2105,12 +2122,16 @@ impl Build {
let target = self.get_target()?;
if target.contains("msvc") {
- let (mut cmd, program) = self.get_ar()?;
+ let (mut cmd, program, any_flags) = self.get_ar()?;
+ // NOTE: -out: here is an I/O flag, and so must be included even if $ARFLAGS/ar_flag is
+ // in use. -nologo on the other hand is just a regular flag, and one that we'll skip if
+ // the caller has explicitly dictated the flags they want. See
+ // https://github.com/rust-lang/cc-rs/pull/763 for further discussion.
let mut out = OsString::from("-out:");
out.push(dst);
- cmd.arg(out).arg("-nologo");
- for flag in self.ar_flags.iter() {
- cmd.arg(flag);
+ cmd.arg(out);
+ if !any_flags {
+ cmd.arg("-nologo");
}
// If the library file already exists, add the library name
// as an argument to let lib.exe know we are appending the objs.
@@ -2120,7 +2141,7 @@ impl Build {
cmd.args(objs);
run(&mut cmd, &program)?;
} else {
- let (mut ar, cmd) = self.get_ar()?;
+ let (mut ar, cmd, _any_flags) = self.get_ar()?;
// Set an environment variable to tell the OSX archiver to ensure
// that all dates listed in the archive are zero, improving
@@ -2145,9 +2166,10 @@ impl Build {
// In any case if this doesn't end up getting read, it shouldn't
// cause that many issues!
ar.env("ZERO_AR_DATE", "1");
- for flag in self.ar_flags.iter() {
- ar.arg(flag);
- }
+
+ // NOTE: We add cq here regardless of whether $ARFLAGS/ar_flag have been used because
+ // it dictates the _mode_ ar runs in, which the setter of $ARFLAGS/ar_flag can't
+ // dictate. See https://github.com/rust-lang/cc-rs/pull/763 for further discussion.
run(ar.arg("cq").arg(dst).args(objs), &cmd)?;
}
@@ -2212,7 +2234,7 @@ impl Build {
}
} else if is_sim {
match arch {
- "arm64" | "aarch64" => ArchSpec::Simulator("-arch arm64"),
+ "arm64" | "aarch64" => ArchSpec::Simulator("arm64"),
"x86_64" => ArchSpec::Simulator("-m64"),
_ => {
return Err(Error::new(
@@ -2262,7 +2284,13 @@ impl Build {
format!("{}os", sdk_prefix)
}
ArchSpec::Simulator(arch) => {
- cmd.args.push(arch.into());
+ if arch.starts_with('-') {
+ // -m32 or -m64
+ cmd.args.push(arch.into());
+ } else {
+ cmd.args.push("-arch".into());
+ cmd.args.push(arch.into());
+ }
cmd.args
.push(format!("-m{}simulator-version-min={}", sim_prefix, min_version).into());
format!("{}simulator", sdk_prefix)
@@ -2279,18 +2307,8 @@ impl Build {
cmd.args.push("-isysroot".into());
cmd.args.push(sdk_path);
+ // TODO: Remove this once Apple stops accepting apps built with Xcode 13
cmd.args.push("-fembed-bitcode".into());
- /*
- * TODO we probably ultimately want the -fembed-bitcode-marker flag
- * but can't have it now because of an issue in LLVM:
- * https://github.com/rust-lang/cc-rs/issues/301
- * https://github.com/rust-lang/rust/pull/48896#comment-372192660
- */
- /*
- if self.get_opt_level()? == "0" {
- cmd.args.push("-fembed-bitcode-marker".into());
- }
- */
Ok(())
}
@@ -2643,81 +2661,206 @@ impl Build {
}
}
- fn get_ar(&self) -> Result<(Command, String), Error> {
- if let Some(ref p) = self.archiver {
- let name = p.file_name().and_then(|s| s.to_str()).unwrap_or("ar");
- return Ok((self.cmd(p), name.to_string()));
+ fn get_ar(&self) -> Result<(Command, String, bool), Error> {
+ self.try_get_archiver_and_flags()
+ }
+
+ /// Get the archiver (ar) that's in use for this configuration.
+ ///
+ /// You can use [`Command::get_program`] to get just the path to the command.
+ ///
+ /// This method will take into account all configuration such as debug
+ /// information, optimization level, include directories, defines, etc.
+ /// Additionally, the compiler binary in use follows the standard
+ /// conventions for this path, e.g. looking at the explicitly set compiler,
+ /// environment variables (a number of which are inspected here), and then
+ /// falling back to the default configuration.
+ ///
+ /// # Panics
+ ///
+ /// Panics if an error occurred while determining the architecture.
+ pub fn get_archiver(&self) -> Command {
+ match self.try_get_archiver() {
+ Ok(tool) => tool,
+ Err(e) => fail(&e.message),
+ }
+ }
+
+ /// Get the archiver that's in use for this configuration.
+ ///
+ /// This will return a result instead of panicing;
+ /// see [`get_archiver()`] for the complete description.
+ pub fn try_get_archiver(&self) -> Result<Command, Error> {
+ Ok(self.try_get_archiver_and_flags()?.0)
+ }
+
+ fn try_get_archiver_and_flags(&self) -> Result<(Command, String, bool), Error> {
+ let (mut cmd, name) = self.get_base_archiver()?;
+ let flags = self.envflags("ARFLAGS");
+ let mut any_flags = !flags.is_empty();
+ cmd.args(flags);
+ for flag in &self.ar_flags {
+ any_flags = true;
+ cmd.arg(flag);
}
- if let Ok(p) = self.get_var("AR") {
- return Ok((self.cmd(&p), p));
+ Ok((cmd, name, any_flags))
+ }
+
+ fn get_base_archiver(&self) -> Result<(Command, String), Error> {
+ if let Some(ref a) = self.archiver {
+ return Ok((self.cmd(a), a.to_string_lossy().into_owned()));
}
- let target = self.get_target()?;
- let default_ar = "ar".to_string();
- let program = if target.contains("android") {
- format!("{}-ar", target.replace("armv7", "arm"))
- } else if target.contains("emscripten") {
- // Windows use bat files so we have to be a bit more specific
- if cfg!(windows) {
- let mut cmd = self.cmd("cmd");
- cmd.arg("/c").arg("emar.bat");
- return Ok((cmd, "emar.bat".to_string()));
- }
- "emar".to_string()
- } else if target.contains("msvc") {
- let compiler = self.get_base_compiler()?;
- let mut lib = String::new();
- if compiler.family == (ToolFamily::Msvc { clang_cl: true }) {
- // See if there is 'llvm-lib' next to 'clang-cl'
- // Another possibility could be to see if there is 'clang'
- // next to 'clang-cl' and use 'search_programs()' to locate
- // 'llvm-lib'. This is because 'clang-cl' doesn't support
- // the -print-search-dirs option.
- if let Some(mut cmd) = which(&compiler.path) {
- cmd.pop();
- cmd.push("llvm-lib.exe");
- if let Some(llvm_lib) = which(&cmd) {
- lib = llvm_lib.to_str().unwrap().to_owned();
+ self.get_base_archiver_variant("AR", "ar")
+ }
+
+ /// Get the ranlib that's in use for this configuration.
+ ///
+ /// You can use [`Command::get_program`] to get just the path to the command.
+ ///
+ /// This method will take into account all configuration such as debug
+ /// information, optimization level, include directories, defines, etc.
+ /// Additionally, the compiler binary in use follows the standard
+ /// conventions for this path, e.g. looking at the explicitly set compiler,
+ /// environment variables (a number of which are inspected here), and then
+ /// falling back to the default configuration.
+ ///
+ /// # Panics
+ ///
+ /// Panics if an error occurred while determining the architecture.
+ pub fn get_ranlib(&self) -> Command {
+ match self.try_get_ranlib() {
+ Ok(tool) => tool,
+ Err(e) => fail(&e.message),
+ }
+ }
+
+ /// Get the ranlib that's in use for this configuration.
+ ///
+ /// This will return a result instead of panicing;
+ /// see [`get_ranlib()`] for the complete description.
+ pub fn try_get_ranlib(&self) -> Result<Command, Error> {
+ let mut cmd = self.get_base_ranlib()?;
+ cmd.args(self.envflags("RANLIBFLAGS"));
+ Ok(cmd)
+ }
+
+ fn get_base_ranlib(&self) -> Result<Command, Error> {
+ if let Some(ref r) = self.ranlib {
+ return Ok(self.cmd(r));
+ }
+
+ Ok(self.get_base_archiver_variant("RANLIB", "ranlib")?.0)
+ }
+
+ fn get_base_archiver_variant(&self, env: &str, tool: &str) -> Result<(Command, String), Error> {
+ let target = self.get_target()?;
+ let mut name = String::new();
+ let tool_opt: Option<Command> = self
+ .env_tool(env)
+ .map(|(tool, _wrapper, args)| {
+ let mut cmd = self.cmd(tool);
+ cmd.args(args);
+ cmd
+ })
+ .or_else(|| {
+ if target.contains("emscripten") {
+ // Windows use bat files so we have to be a bit more specific
+ if cfg!(windows) {
+ let mut cmd = self.cmd("cmd");
+ name = format!("em{}.bat", tool);
+ cmd.arg("/c").arg(&name);
+ Some(cmd)
+ } else {
+ name = format!("em{}", tool);
+ Some(self.cmd(&name))
}
+ } else {
+ None
}
- }
- if lib.is_empty() {
- lib = match windows_registry::find(&target, "lib.exe") {
- Some(t) => return Ok((t, "lib.exe".to_string())),
- None => "lib.exe".to_string(),
- }
- }
- lib
- } else if target.contains("illumos") {
- // The default 'ar' on illumos uses a non-standard flags,
- // but the OS comes bundled with a GNU-compatible variant.
- //
- // Use the GNU-variant to match other Unix systems.
- "gar".to_string()
- } else if self.get_host()? != target {
- match self.prefix_for_target(&target) {
- Some(p) => {
- // GCC uses $target-gcc-ar, whereas binutils uses $target-ar -- try both.
- // Prefer -ar if it exists, as builds of `-gcc-ar` have been observed to be
- // outright broken (such as when targetting freebsd with `--disable-lto`
- // toolchain where the archiver attempts to load the LTO plugin anyway but
- // fails to find one).
- let mut ar = default_ar;
- for &infix in &["", "-gcc"] {
- let target_ar = format!("{}{}-ar", p, infix);
- if Command::new(&target_ar).output().is_ok() {
- ar = target_ar;
- break;
+ });
+
+ let default = tool.to_string();
+ let tool = match tool_opt {
+ Some(t) => t,
+ None => {
+ if target.contains("android") {
+ name = format!("{}-{}", target.replace("armv7", "arm"), tool);
+ self.cmd(&name)
+ } else if target.contains("msvc") {
+ // NOTE: There isn't really a ranlib on msvc, so arguably we should return
+ // `None` somehow here. But in general, callers will already have to be aware
+ // of not running ranlib on Windows anyway, so it feels okay to return lib.exe
+ // here.
+
+ let compiler = self.get_base_compiler()?;
+ let mut lib = String::new();
+ if compiler.family == (ToolFamily::Msvc { clang_cl: true }) {
+ // See if there is 'llvm-lib' next to 'clang-cl'
+ // Another possibility could be to see if there is 'clang'
+ // next to 'clang-cl' and use 'search_programs()' to locate
+ // 'llvm-lib'. This is because 'clang-cl' doesn't support
+ // the -print-search-dirs option.
+ if let Some(mut cmd) = which(&compiler.path) {
+ cmd.pop();
+ cmd.push("llvm-lib.exe");
+ if let Some(llvm_lib) = which(&cmd) {
+ lib = llvm_lib.to_str().unwrap().to_owned();
+ }
+ }
+ }
+
+ if lib.is_empty() {
+ name = String::from("lib.exe");
+ match windows_registry::find(&target, "lib.exe") {
+ Some(t) => t,
+ None => self.cmd("lib.exe"),
+ }
+ } else {
+ name = lib;
+ self.cmd(&name)
+ }
+ } else if target.contains("illumos") {
+ // The default 'ar' on illumos uses a non-standard flags,
+ // but the OS comes bundled with a GNU-compatible variant.
+ //
+ // Use the GNU-variant to match other Unix systems.
+ name = format!("g{}", tool);
+ self.cmd(&name)
+ } else if self.get_host()? != target {
+ match self.prefix_for_target(&target) {
+ Some(p) => {
+ // GCC uses $target-gcc-ar, whereas binutils uses $target-ar -- try both.
+ // Prefer -ar if it exists, as builds of `-gcc-ar` have been observed to be
+ // outright broken (such as when targetting freebsd with `--disable-lto`
+ // toolchain where the archiver attempts to load the LTO plugin anyway but
+ // fails to find one).
+ //
+ // The same applies to ranlib.
+ let mut chosen = default;
+ for &infix in &["", "-gcc"] {
+ let target_p = format!("{}{}-{}", p, infix, tool);
+ if Command::new(&target_p).output().is_ok() {
+ chosen = target_p;
+ break;
+ }
+ }
+ name = chosen;
+ self.cmd(&name)
+ }
+ None => {
+ name = default;
+ self.cmd(&name)
}
}
- ar
+ } else {
+ name = default;
+ self.cmd(&name)
}
- None => default_ar,
}
- } else {
- default_ar
};
- Ok((self.cmd(&program), program))
+
+ Ok((tool, name))
}
fn prefix_for_target(&self, target: &str) -> Option<String> {
@@ -2804,6 +2947,7 @@ impl Build {
"riscv64-unknown-elf",
"riscv-none-embed",
]),
+ "riscv32imc-esp-espidf" => Some("riscv32-esp-elf"),
"riscv32imc-unknown-none-elf" => self.find_working_gnu_prefix(&[
"riscv32-unknown-elf",
"riscv64-unknown-elf",
diff --git a/vendor/cc/src/windows_registry.rs b/vendor/cc/src/windows_registry.rs
index 276688b03..b05498c29 100644
--- a/vendor/cc/src/windows_registry.rs
+++ b/vendor/cc/src/windows_registry.rs
@@ -866,7 +866,9 @@ mod impl_ {
// see http://stackoverflow.com/questions/328017/path-to-msbuild
pub fn find_msbuild(target: &str) -> Option<Tool> {
// VS 15 (2017) changed how to locate msbuild
- if let Some(r) = find_msbuild_vs16(target) {
+ if let Some(r) = find_msbuild_vs17(target) {
+ return Some(r);
+ } else if let Some(r) = find_msbuild_vs16(target) {
return Some(r);
} else if let Some(r) = find_msbuild_vs15(target) {
return Some(r);