summaryrefslogtreecommitdiffstats
path: root/vendor/cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:25 +0000
commit5363f350887b1e5b5dd21a86f88c8af9d7fea6da (patch)
tree35ca005eb6e0e9a1ba3bb5dbc033209ad445dc17 /vendor/cc
parentAdding debian version 1.66.0+dfsg1-1. (diff)
downloadrustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.tar.xz
rustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.zip
Merging upstream version 1.67.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.lock18
-rw-r--r--vendor/cc/Cargo.toml18
-rw-r--r--vendor/cc/README.md6
-rw-r--r--vendor/cc/src/com.rs4
-rw-r--r--vendor/cc/src/lib.rs217
-rw-r--r--vendor/cc/src/registry.rs53
-rw-r--r--vendor/cc/src/setup_config.rs4
-rw-r--r--vendor/cc/src/winapi.rs4
-rw-r--r--vendor/cc/src/windows_registry.rs14
-rw-r--r--vendor/cc/tests/test.rs16
11 files changed, 277 insertions, 79 deletions
diff --git a/vendor/cc/.cargo-checksum.json b/vendor/cc/.cargo-checksum.json
index a7f8f2fe7..fb36f0442 100644
--- a/vendor/cc/.cargo-checksum.json
+++ b/vendor/cc/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.lock":"739aae86d1e7096fc84b9a6273cc49635503a4ee87b3a4b6601f569880866b29","Cargo.toml":"ccfa92dd53511178ef95aa87b2dcbdd45e23f9f8a8454e455d7da8e08feab4b5","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"1fd66e1fe6d618030b9452c667e89d7a31b27331ad831d83b41f9762fd6858d4","src/bin/gcc-shim.rs":"b77907875029494b6288841c3aed2e4939ed40708c7f597fca5c9e2570490ca6","src/com.rs":"bcdaf1c28b71e6ef889c6b08d1ce9d7c0761344a677f523bc4c3cd297957f804","src/lib.rs":"38970d678de0efb4b5e2978265daa8a613a1db35fc42e669621b03fc56d5b138","src/registry.rs":"3cc1b5a50879fa751572878ae1d0afbfc960c11665258492754b2c8bccb0ff5d","src/setup_config.rs":"7014103587d3382eac599cb76f016e2609b8140970861b2237982d1db24af265","src/vs_instances.rs":"2d3f8278a803b0e7052f4eeb1979b29f963dd0143f4458e2cb5f33c4e5f0963b","src/winapi.rs":"ea8b7edbb9ff87957254f465c2334e714c5d6b3b19a8d757c48ea7ca0881c50c","src/windows_registry.rs":"4645453198766c7486fc9b8782b06cfd0f94cbbcb3482413173e73234a447518","tests/cc_env.rs":"e02b3b0824ad039b47e4462c5ef6dbe6c824c28e7953af94a0f28f7b5158042e","tests/cflags.rs":"57f06eb5ce1557e5b4a032d0c4673e18fbe6f8d26c1deb153126e368b96b41b3","tests/cxxflags.rs":"c2c6c6d8a0d7146616fa1caed26876ee7bc9fcfffd525eb4743593cade5f3371","tests/support/mod.rs":"a3c8d116973bb16066bf6ec4de5143183f97de7aad085d85f8118a2eaac3e1e0","tests/test.rs":"65c073e0e2cf4aa0433066102788e9f57442719e6f32f5ad5248aa7132bb4597"},"package":"2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"} \ No newline at end of file
+{"files":{"Cargo.lock":"6ff475c12a6d2bbc578d694793d0590a2c5132e46f511eb8896532ff22b570c3","Cargo.toml":"94b3fa599de37079bddec0afce9a86ec285ebf1eca8ef4134597bc8f840ea37e","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"58af5106352aafa62175a90f8a5f25fa114028bf909220dc0735d79745999ec1","src/bin/gcc-shim.rs":"b77907875029494b6288841c3aed2e4939ed40708c7f597fca5c9e2570490ca6","src/com.rs":"29d0dee08a656ab1a4cc3e5fe24542e0fab5c1373cbc9b05059f7572cf9b8313","src/lib.rs":"209c8351f1db1e3ce2fdd2ac487dbe7849f5d3a7bfade054877270b6f4782232","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":"3e91f8de57aeae2c74bbb35fc14df8323220cdcbd0da3bde80274519c8779216"},"package":"76a284da2e6fe2092f2353e51713435363112dfd60030e22add80be333fb928f"} \ No newline at end of file
diff --git a/vendor/cc/Cargo.lock b/vendor/cc/Cargo.lock
index 524a6cd61..fc1a6596d 100644
--- a/vendor/cc/Cargo.lock
+++ b/vendor/cc/Cargo.lock
@@ -10,7 +10,7 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "cc"
-version = "1.0.73"
+version = "1.0.76"
dependencies = [
"jobserver",
"tempfile",
@@ -24,9 +24,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "fastrand"
-version = "1.7.0"
+version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf"
+checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499"
dependencies = [
"instant",
]
@@ -42,24 +42,24 @@ dependencies = [
[[package]]
name = "jobserver"
-version = "0.1.24"
+version = "0.1.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa"
+checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b"
dependencies = [
"libc",
]
[[package]]
name = "libc"
-version = "0.2.118"
+version = "0.2.137"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "06e509672465a0504304aa87f9f176f2b2b716ed8fb105ebe5c02dc6dce96a94"
+checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89"
[[package]]
name = "redox_syscall"
-version = "0.2.10"
+version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff"
+checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
dependencies = [
"bitflags",
]
diff --git a/vendor/cc/Cargo.toml b/vendor/cc/Cargo.toml
index ad0ec2138..7be741e1e 100644
--- a/vendor/cc/Cargo.toml
+++ b/vendor/cc/Cargo.toml
@@ -12,20 +12,26 @@
[package]
edition = "2018"
name = "cc"
-version = "1.0.73"
+version = "1.0.76"
authors = ["Alex Crichton <alex@alexcrichton.com>"]
-exclude = ["/.github", "/.travis.yml", "/appveyor.yml"]
-description = "A build-time dependency for Cargo build scripts to assist in invoking the native\nC compiler to compile native C code into a static archive to be linked into Rust\ncode.\n"
-homepage = "https://github.com/alexcrichton/cc-rs"
+exclude = ["/.github"]
+description = """
+A build-time dependency for Cargo build scripts to assist in invoking the native
+C compiler to compile native C code into a static archive to be linked into Rust
+code.
+"""
+homepage = "https://github.com/rust-lang/cc-rs"
documentation = "https://docs.rs/cc"
readme = "README.md"
keywords = ["build-dependencies"]
categories = ["development-tools::build-utils"]
-license = "MIT/Apache-2.0"
-repository = "https://github.com/alexcrichton/cc-rs"
+license = "MIT OR Apache-2.0"
+repository = "https://github.com/rust-lang/cc-rs"
+
[dependencies.jobserver]
version = "0.1.16"
optional = true
+
[dev-dependencies.tempfile]
version = "3"
diff --git a/vendor/cc/README.md b/vendor/cc/README.md
index b52e095b9..863540d2d 100644
--- a/vendor/cc/README.md
+++ b/vendor/cc/README.md
@@ -135,12 +135,12 @@ required varies per platform, but there are three broad categories:
the appropriate developer tools shell.
* Windows platforms targeting MinGW (e.g. your target triple ends in `-gnu`)
require `cc` to be available in `PATH`. We recommend the
- [MinGW-w64](http://mingw-w64.org) distribution, which is using the
- [Win-builds](http://win-builds.org) installation system.
+ [MinGW-w64](https://www.mingw-w64.org/) distribution, which is using the
+ [Win-builds](http://win-builds.org/) installation system.
You may also acquire it via
[MSYS2](https://www.msys2.org/), as explained [here][msys2-help]. Make sure
to install the appropriate architecture corresponding to your installation of
- rustc. GCC from older [MinGW](http://www.mingw.org) project is compatible
+ rustc. GCC from older [MinGW](http://www.mingw.org/) project is compatible
only with 32-bit rust compiler.
[msys2-help]: https://github.com/rust-lang/rust#building-on-windows
diff --git a/vendor/cc/src/com.rs b/vendor/cc/src/com.rs
index a5f2afedf..843247e58 100644
--- a/vendor/cc/src/com.rs
+++ b/vendor/cc/src/com.rs
@@ -1,7 +1,7 @@
// Copyright © 2017 winapi-rs developers
// Licensed under the Apache License, Version 2.0
-// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
+// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
// All files in the project carrying such notice may not be copied, modified, or distributed
// except according to those terms.
diff --git a/vendor/cc/src/lib.rs b/vendor/cc/src/lib.rs
index e3a2b98b0..a89e35318 100644
--- a/vendor/cc/src/lib.rs
+++ b/vendor/cc/src/lib.rs
@@ -59,7 +59,7 @@
use std::collections::HashMap;
use std::env;
use std::ffi::{OsStr, OsString};
-use std::fmt::{self, Display};
+use std::fmt::{self, Display, Formatter};
use std::fs;
use std::io::{self, BufRead, BufReader, Read, Write};
use std::path::{Component, Path, PathBuf};
@@ -114,6 +114,7 @@ pub struct Build {
compiler: Option<PathBuf>,
archiver: Option<PathBuf>,
cargo_metadata: bool,
+ link_lib_modifiers: Vec<String>,
pic: Option<bool>,
use_plt: Option<bool>,
static_crt: Option<bool>,
@@ -124,6 +125,7 @@ pub struct Build {
extra_warnings: Option<bool>,
env_cache: Arc<Mutex<HashMap<String, Option<String>>>>,
apple_sdk_root_cache: Arc<Mutex<HashMap<String, OsString>>>,
+ emit_rerun_if_env_changed: bool,
}
/// Represents the types of errors that may occur while using cc-rs.
@@ -168,7 +170,7 @@ impl From<io::Error> for Error {
}
impl Display for Error {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}: {}", self.kind, self.message)
}
}
@@ -312,6 +314,7 @@ impl Build {
compiler: None,
archiver: None,
cargo_metadata: true,
+ link_lib_modifiers: Vec::new(),
pic: None,
use_plt: None,
static_crt: None,
@@ -320,6 +323,7 @@ impl Build {
warnings_into_errors: false,
env_cache: Arc::new(Mutex::new(HashMap::new())),
apple_sdk_root_cache: Arc::new(Mutex::new(HashMap::new())),
+ emit_rerun_if_env_changed: true,
}
}
@@ -475,6 +479,9 @@ impl Build {
.debug(false)
.cpp(self.cpp)
.cuda(self.cuda);
+ if let Some(ref c) = self.compiler {
+ cfg.compiler(c.clone());
+ }
let mut compiler = cfg.try_get_compiler()?;
// Clang uses stderr for verbose output, which yields a false positive
@@ -892,12 +899,23 @@ impl Build {
/// - `rustc-link-search=native=`*target folder*
/// - When target is MSVC, the ATL-MFC libs are added via `rustc-link-search=native=`
/// - When C++ is enabled, the C++ stdlib is added via `rustc-link-lib`
+ /// - If `emit_rerun_if_env_changed` is not `false`, `rerun-if-env-changed=`*env*
///
pub fn cargo_metadata(&mut self, cargo_metadata: bool) -> &mut Build {
self.cargo_metadata = cargo_metadata;
self
}
+ /// Adds a native library modifier that will be added to the
+ /// `rustc-link-lib=static:MODIFIERS=LIBRARY_NAME` metadata line
+ /// emitted for cargo if `cargo_metadata` is enabled.
+ /// See https://doc.rust-lang.org/rustc/command-line-arguments.html#-l-link-the-generated-crate-to-a-native-library
+ /// for the list of modifiers accepted by rustc.
+ pub fn link_lib_modifier(&mut self, link_lib_modifier: &str) -> &mut Build {
+ self.link_lib_modifiers.push(link_lib_modifier.to_string());
+ self
+ }
+
/// Configures whether the compiler will emit position independent code.
///
/// This option defaults to `false` for `windows-gnu` and bare metal targets and
@@ -922,6 +940,17 @@ impl Build {
self
}
+ /// Define whether metadata should be emitted for cargo to detect environment
+ /// changes that should trigger a rebuild.
+ ///
+ /// This has no effect if the `cargo_metadata` option is `false`.
+ ///
+ /// This option defaults to `true`.
+ pub fn emit_rerun_if_env_changed(&mut self, emit_rerun_if_env_changed: bool) -> &mut Build {
+ self.emit_rerun_if_env_changed = emit_rerun_if_env_changed;
+ self
+ }
+
/// Configures whether the /MT flag or the /MD flag will be passed to msvc build tools.
///
/// This option defaults to `false`, and affect only msvc targets.
@@ -1014,7 +1043,12 @@ impl Build {
}
}
- self.print(&format!("cargo:rustc-link-lib=static={}", lib_name));
+ if self.link_lib_modifiers.is_empty() {
+ self.print(&format!("cargo:rustc-link-lib=static={}", lib_name));
+ } else {
+ let m = self.link_lib_modifiers.join(",");
+ self.print(&format!("cargo:rustc-link-lib=static:{}={}", m, lib_name));
+ }
self.print(&format!("cargo:rustc-link-search=native={}", dst.display()));
// Add specific C++ libraries, if enabled.
@@ -1311,6 +1345,13 @@ impl Build {
if self.cuda && self.files.len() > 1 {
cmd.arg("--device-c");
}
+ if compiler.family == (ToolFamily::Msvc { clang_cl: true }) && !is_asm {
+ // #513: For `clang-cl`, separate flags/options from the input file.
+ // When cross-compiling macOS -> Windows, this avoids interpreting
+ // common `/Users/...` paths as the `/U` flag and triggering
+ // `-Wslash-u-filename` warning.
+ cmd.arg("--");
+ }
cmd.arg(&obj.src);
if cfg!(target_os = "macos") {
self.fix_env_for_apple_os(&mut cmd)?;
@@ -1522,7 +1563,7 @@ impl Build {
cmd.push_opt_unless_duplicate("-DANDROID".into());
}
- if !target.contains("apple-ios") {
+ if !target.contains("apple-ios") && !target.contains("apple-watchos") {
cmd.push_cc_arg("-ffunction-sections".into());
cmd.push_cc_arg("-fdata-sections".into());
}
@@ -1574,7 +1615,7 @@ impl Build {
map_darwin_target_from_rust_to_compiler_architecture(target)
{
cmd.args
- .push(format!("--target={}-apple-ios13.0-macabi", arch).into());
+ .push(format!("--target={}-apple-ios-macabi", arch).into());
}
} else if target.contains("ios-sim") {
if let Some(arch) =
@@ -1590,6 +1631,20 @@ impl Build {
.into(),
);
}
+ } else if target.contains("watchos-sim") {
+ if let Some(arch) =
+ map_darwin_target_from_rust_to_compiler_architecture(target)
+ {
+ let deployment_target = env::var("WATCHOS_DEPLOYMENT_TARGET")
+ .unwrap_or_else(|_| "5.0".into());
+ cmd.args.push(
+ format!(
+ "--target={}-apple-watchos{}-simulator",
+ arch, deployment_target
+ )
+ .into(),
+ );
+ }
} else if target.starts_with("riscv64gc-") {
cmd.args.push(
format!("--target={}", target.replace("riscv64gc", "riscv64")).into(),
@@ -1849,8 +1904,8 @@ impl Build {
}
}
- if target.contains("apple-ios") {
- self.ios_flags(cmd)?;
+ if target.contains("apple-ios") || target.contains("apple-watchos") {
+ self.ios_watchos_flags(cmd)?;
}
if self.static_flag.unwrap_or(false) {
@@ -1906,8 +1961,16 @@ impl Build {
cmd.arg("-I").arg(directory);
}
if target.contains("aarch64") || target.contains("arm") {
+ if self.get_debug() {
+ cmd.arg("-g");
+ }
+
println!("cargo:warning=The MSVC ARM assemblers do not support -D flags");
} else {
+ if self.get_debug() {
+ cmd.arg("-Zi");
+ }
+
for &(ref key, ref value) in self.definitions.iter() {
if let Some(ref value) = *value {
cmd.arg(&format!("-D{}={}", key, value));
@@ -2043,18 +2106,37 @@ impl Build {
Ok(())
}
- fn ios_flags(&self, cmd: &mut Tool) -> Result<(), Error> {
+ fn ios_watchos_flags(&self, cmd: &mut Tool) -> Result<(), Error> {
enum ArchSpec {
Device(&'static str),
Simulator(&'static str),
Catalyst(&'static str),
}
+ enum Os {
+ Ios,
+ WatchOs,
+ }
+ impl Display for Os {
+ fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
+ match self {
+ Os::Ios => f.write_str("iOS"),
+ Os::WatchOs => f.write_str("WatchOS"),
+ }
+ }
+ }
+
let target = self.get_target()?;
+ let os = if target.contains("-watchos") {
+ Os::WatchOs
+ } else {
+ Os::Ios
+ };
+
let arch = target.split('-').nth(0).ok_or_else(|| {
Error::new(
ErrorKind::ArchitectureInvalid,
- "Unknown architecture for iOS target.",
+ format!("Unknown architecture for {} target.", os).as_str(),
)
})?;
@@ -2083,6 +2165,7 @@ impl Build {
} else if is_sim {
match arch {
"arm64" | "aarch64" => ArchSpec::Simulator("-arch arm64"),
+ "x86_64" => ArchSpec::Simulator("-m64"),
_ => {
return Err(Error::new(
ErrorKind::ArchitectureInvalid,
@@ -2093,49 +2176,66 @@ impl Build {
} else {
match arch {
"arm" | "armv7" | "thumbv7" => ArchSpec::Device("armv7"),
+ "armv7k" => ArchSpec::Device("armv7k"),
"armv7s" | "thumbv7s" => ArchSpec::Device("armv7s"),
"arm64e" => ArchSpec::Device("arm64e"),
"arm64" | "aarch64" => ArchSpec::Device("arm64"),
+ "arm64_32" => ArchSpec::Device("arm64_32"),
"i386" | "i686" => ArchSpec::Simulator("-m32"),
"x86_64" => ArchSpec::Simulator("-m64"),
_ => {
return Err(Error::new(
ErrorKind::ArchitectureInvalid,
- "Unknown architecture for iOS target.",
+ format!("Unknown architecture for {} target.", os).as_str(),
));
}
}
};
- let min_version =
- std::env::var("IPHONEOS_DEPLOYMENT_TARGET").unwrap_or_else(|_| "7.0".into());
+ let (sdk_prefix, sim_prefix, min_version) = match os {
+ Os::Ios => (
+ "iphone",
+ "ios-",
+ std::env::var("IPHONEOS_DEPLOYMENT_TARGET").unwrap_or_else(|_| "7.0".into()),
+ ),
+ Os::WatchOs => (
+ "watch",
+ "watch",
+ std::env::var("WATCHOS_DEPLOYMENT_TARGET").unwrap_or_else(|_| "2.0".into()),
+ ),
+ };
let sdk = match arch {
ArchSpec::Device(arch) => {
cmd.args.push("-arch".into());
cmd.args.push(arch.into());
cmd.args
- .push(format!("-miphoneos-version-min={}", min_version).into());
- "iphoneos"
+ .push(format!("-m{}os-version-min={}", sdk_prefix, min_version).into());
+ format!("{}os", sdk_prefix)
}
ArchSpec::Simulator(arch) => {
cmd.args.push(arch.into());
cmd.args
- .push(format!("-mios-simulator-version-min={}", min_version).into());
- "iphonesimulator"
+ .push(format!("-m{}simulator-version-min={}", sim_prefix, min_version).into());
+ format!("{}simulator", sdk_prefix)
}
- ArchSpec::Catalyst(_) => "macosx",
+ ArchSpec::Catalyst(_) => "macosx".to_owned(),
+ };
+
+ self.print(&format!("Detecting {} SDK path for {}", os, sdk));
+ let sdk_path = if let Some(sdkroot) = env::var_os("SDKROOT") {
+ sdkroot
+ } else {
+ self.apple_sdk_root(sdk.as_str())?
};
- self.print(&format!("Detecting iOS SDK path for {}", sdk));
- let sdk_path = self.apple_sdk_root(sdk)?;
cmd.args.push("-isysroot".into());
cmd.args.push(sdk_path);
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/alexcrichton/cc-rs/issues/301
+ * https://github.com/rust-lang/cc-rs/issues/301
* https://github.com/rust-lang/rust/pull/48896#comment-372192660
*/
/*
@@ -2226,10 +2326,13 @@ impl Build {
if target.contains("msvc") {
msvc.to_string()
} else {
- format!("{}.exe", gnu)
+ let cc = if target.contains("llvm") { clang } else { gnu };
+ format!("{}.exe", cc)
}
} else if target.contains("apple-ios") {
clang.to_string()
+ } else if target.contains("apple-watchos") {
+ clang.to_string()
} else if target.contains("android") {
autodetect_android_compiler(&target, &host, gnu, clang)
} else if target.contains("cloudabi") {
@@ -2252,7 +2355,10 @@ impl Build {
} else if self.get_host()? != target {
let prefix = self.prefix_for_target(&target);
match prefix {
- Some(prefix) => format!("{}-{}", prefix, gnu),
+ Some(prefix) => {
+ let cc = if target.contains("llvm") { clang } else { gnu };
+ format!("{}-{}", prefix, cc)
+ }
None => default.to_string(),
}
} else {
@@ -2524,12 +2630,20 @@ impl Build {
} else if self.get_host()? != target {
match self.prefix_for_target(&target) {
Some(p) => {
- let target_ar = format!("{}-ar", p);
- if Command::new(&target_ar).output().is_ok() {
- target_ar
- } else {
- default_ar
+ // 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;
+ }
}
+ ar
}
None => default_ar,
}
@@ -2540,13 +2654,25 @@ impl Build {
}
fn prefix_for_target(&self, target: &str) -> Option<String> {
+ // Put aside RUSTC_LINKER's prefix to be used as last resort
+ let rustc_linker = self.getenv("RUSTC_LINKER").unwrap_or("".to_string());
+ // let linker_prefix = rustc_linker.strip_suffix("-gcc"); // >=1.45.0
+ let linker_prefix = if rustc_linker.len() > 4 {
+ let (prefix, suffix) = rustc_linker.split_at(rustc_linker.len() - 4);
+ if suffix == "-gcc" {
+ Some(prefix)
+ } else {
+ None
+ }
+ } else {
+ None
+ };
// CROSS_COMPILE is of the form: "arm-linux-gnueabi-"
let cc_env = self.getenv("CROSS_COMPILE");
- let cross_compile = cc_env
- .as_ref()
- .map(|s| s.trim_right_matches('-').to_owned());
+ let cross_compile = cc_env.as_ref().map(|s| s.trim_end_matches('-').to_owned());
cross_compile.or(match &target[..] {
- "aarch64-pc-windows-gnu" => Some("aarch64-w64-mingw32"),
+ // Note: there is no `aarch64-pc-windows-gnu` target, only `-gnullvm`
+ "aarch64-pc-windows-gnullvm" => Some("aarch64-w64-mingw32"),
"aarch64-uwp-windows-gnu" => Some("aarch64-w64-mingw32"),
"aarch64-unknown-linux-gnu" => Some("aarch64-linux-gnu"),
"aarch64-unknown-linux-musl" => Some("aarch64-linux-musl"),
@@ -2606,6 +2732,11 @@ impl Build {
"riscv64-unknown-elf",
"riscv-none-embed",
]),
+ "riscv32imac-unknown-xous-elf" => self.find_working_gnu_prefix(&[
+ "riscv32-unknown-elf",
+ "riscv64-unknown-elf",
+ "riscv-none-embed",
+ ]),
"riscv32imc-unknown-none-elf" => self.find_working_gnu_prefix(&[
"riscv32-unknown-elf",
"riscv64-unknown-elf",
@@ -2644,6 +2775,7 @@ impl Build {
"thumbv8m.main-none-eabi" => Some("arm-none-eabi"),
"thumbv8m.main-none-eabihf" => Some("arm-none-eabi"),
"x86_64-pc-windows-gnu" => Some("x86_64-w64-mingw32"),
+ "x86_64-pc-windows-gnullvm" => Some("x86_64-w64-mingw32"),
"x86_64-uwp-windows-gnu" => Some("x86_64-w64-mingw32"),
"x86_64-rumprun-netbsd" => Some("x86_64-rumprun-netbsd"),
"x86_64-unknown-linux-gnu" => self.find_working_gnu_prefix(&[
@@ -2651,7 +2783,7 @@ impl Build {
]), // explicit None if not found, so caller knows to fall back
"x86_64-unknown-linux-musl" => Some("musl"),
"x86_64-unknown-netbsd" => Some("x86_64--netbsd"),
- _ => None,
+ _ => linker_prefix,
}
.map(|x| x.to_owned()))
}
@@ -2733,10 +2865,27 @@ impl Build {
}
fn getenv(&self, v: &str) -> Option<String> {
+ // Returns true for environment variables cargo sets for build scripts:
+ // https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts
+ //
+ // This handles more of the vars than we actually use (it tries to check
+ // complete-ish set), just to avoid needing maintenance if/when new
+ // calls to `getenv`/`getenv_unwrap` are added.
+ fn provided_by_cargo(envvar: &str) -> bool {
+ match envvar {
+ v if v.starts_with("CARGO") || v.starts_with("RUSTC") => true,
+ "HOST" | "TARGET" | "RUSTDOC" | "OUT_DIR" | "OPT_LEVEL" | "DEBUG" | "PROFILE"
+ | "NUM_JOBS" | "RUSTFLAGS" => true,
+ _ => false,
+ }
+ }
let mut cache = self.env_cache.lock().unwrap();
if let Some(val) = cache.get(v) {
return val.clone();
}
+ if self.emit_rerun_if_env_changed && !provided_by_cargo(v) {
+ self.print(&format!("cargo:rerun-if-env-changed={}", v));
+ }
let r = env::var(v).ok();
self.print(&format!("{} = {:?}", v, r));
cache.insert(v.to_string(), r.clone());
@@ -2806,7 +2955,7 @@ impl Build {
Err(_) => {
return Err(Error::new(
ErrorKind::IOError,
- "Unable to determine iOS SDK path.",
+ "Unable to determine Apple SDK path.",
));
}
};
@@ -3123,7 +3272,7 @@ fn spawn(cmd: &mut Command, program: &str) -> Result<(Child, JoinHandle<()>), Er
}
Err(ref e) if e.kind() == io::ErrorKind::NotFound => {
let extra = if cfg!(windows) {
- " (see https://github.com/alexcrichton/cc-rs#compile-time-requirements \
+ " (see https://github.com/rust-lang/cc-rs#compile-time-requirements \
for help)"
} else {
""
diff --git a/vendor/cc/src/registry.rs b/vendor/cc/src/registry.rs
index 2ac2fa63b..cae32219c 100644
--- a/vendor/cc/src/registry.rs
+++ b/vendor/cc/src/registry.rs
@@ -3,8 +3,8 @@
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
@@ -14,7 +14,8 @@ use std::ops::RangeFrom;
use std::os::raw;
use std::os::windows::prelude::*;
-pub struct RegistryKey(Repr);
+/// Must never be `HKEY_PERFORMANCE_DATA`.
+pub(crate) struct RegistryKey(Repr);
type HKEY = *mut u8;
type DWORD = u32;
@@ -29,7 +30,8 @@ type REGSAM = u32;
const ERROR_SUCCESS: DWORD = 0;
const ERROR_NO_MORE_ITEMS: DWORD = 259;
-const HKEY_LOCAL_MACHINE: HKEY = 0x80000002 as HKEY;
+// Sign-extend into 64 bits if needed.
+const HKEY_LOCAL_MACHINE: HKEY = 0x80000002u32 as i32 as isize as HKEY;
const REG_SZ: DWORD = 1;
const KEY_READ: DWORD = 0x20019;
const KEY_WOW64_32KEY: DWORD = 0x200;
@@ -66,8 +68,11 @@ extern "system" {
struct OwnedKey(HKEY);
+/// Note: must not encode `HKEY_PERFORMANCE_DATA` or one of its subkeys.
enum Repr {
- Const(HKEY),
+ /// `HKEY_LOCAL_MACHINE`.
+ LocalMachine,
+ /// A subkey of `HKEY_LOCAL_MACHINE`.
Owned(OwnedKey),
}
@@ -79,16 +84,17 @@ pub struct Iter<'a> {
unsafe impl Sync for Repr {}
unsafe impl Send for Repr {}
-pub static LOCAL_MACHINE: RegistryKey = RegistryKey(Repr::Const(HKEY_LOCAL_MACHINE));
+pub(crate) const LOCAL_MACHINE: RegistryKey = RegistryKey(Repr::LocalMachine);
impl RegistryKey {
fn raw(&self) -> HKEY {
match self.0 {
- Repr::Const(val) => val,
+ Repr::LocalMachine => HKEY_LOCAL_MACHINE,
Repr::Owned(ref val) => val.0,
}
}
+ /// Open a sub-key of `self`.
pub fn open(&self, key: &OsStr) -> io::Result<RegistryKey> {
let key = key.encode_wide().chain(Some(0)).collect::<Vec<_>>();
let mut ret = 0 as *mut _;
@@ -140,9 +146,13 @@ impl RegistryKey {
}
// The length here is the length in bytes, but we're using wide
- // characters so we need to be sure to halve it for the capacity
+ // characters so we need to be sure to halve it for the length
// passed in.
- let mut v = Vec::with_capacity(len as usize / 2);
+ assert!(len % 2 == 0, "impossible wide string size: {} bytes", len);
+ let vlen = len as usize / 2;
+ // Defensively initialized, see comment about
+ // `HKEY_PERFORMANCE_DATA` below.
+ let mut v = vec![0u16; vlen];
let err = RegQueryValueExW(
self.raw(),
name.as_ptr(),
@@ -151,17 +161,34 @@ impl RegistryKey {
v.as_mut_ptr() as *mut _,
&mut len,
);
+ // We don't check for `ERROR_MORE_DATA` (which would if the value
+ // grew between the first and second call to `RegQueryValueExW`),
+ // both because it's extremely unlikely, and this is a bit more
+ // defensive more defensive against weird types of registry keys.
if err != ERROR_SUCCESS as LONG {
return Err(io::Error::from_raw_os_error(err as i32));
}
- v.set_len(len as usize / 2);
-
+ // The length is allowed to change, but should still be even, as
+ // well as smaller.
+ assert!(len % 2 == 0, "impossible wide string size: {} bytes", len);
+ // If the length grew but returned a success code, it *probably*
+ // indicates we're `HKEY_PERFORMANCE_DATA` or a subkey(?). We
+ // consider this UB, since those keys write "undefined" or
+ // "unpredictable" values to len, and need to use a completely
+ // different loop structure. This should be impossible (and enforce
+ // it in the API to the best of our ability), but to mitigate the
+ // damage we do some smoke-checks on the len, and ensure `v` has
+ // been fully initialized (rather than trusting the result of
+ // `RegQueryValueExW`).
+ let actual_len = len as usize / 2;
+ assert!(actual_len <= v.len());
+ v.truncate(actual_len);
// Some registry keys may have a terminating nul character, but
// we're not interested in that, so chop it off if it's there.
- if v[v.len() - 1] == 0 {
+ if !v.is_empty() && v[v.len() - 1] == 0 {
v.pop();
}
- Ok(OsString::from_wide(&v))
+ return Ok(OsString::from_wide(&v));
}
}
}
diff --git a/vendor/cc/src/setup_config.rs b/vendor/cc/src/setup_config.rs
index bc2b1c2d3..030051ca6 100644
--- a/vendor/cc/src/setup_config.rs
+++ b/vendor/cc/src/setup_config.rs
@@ -1,7 +1,7 @@
// Copyright © 2017 winapi-rs developers
// Licensed under the Apache License, Version 2.0
-// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
+// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
// All files in the project carrying such notice may not be copied, modified, or distributed
// except according to those terms.
diff --git a/vendor/cc/src/winapi.rs b/vendor/cc/src/winapi.rs
index c416325b5..8e04ce9cb 100644
--- a/vendor/cc/src/winapi.rs
+++ b/vendor/cc/src/winapi.rs
@@ -1,7 +1,7 @@
// Copyright © 2015-2017 winapi-rs developers
// Licensed under the Apache License, Version 2.0
-// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
+// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
// All files in the project carrying such notice may not be copied, modified, or distributed
// except according to those terms.
diff --git a/vendor/cc/src/windows_registry.rs b/vendor/cc/src/windows_registry.rs
index 549082b30..276688b03 100644
--- a/vendor/cc/src/windows_registry.rs
+++ b/vendor/cc/src/windows_registry.rs
@@ -3,8 +3,8 @@
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
@@ -393,7 +393,7 @@ mod impl_ {
// according to Microsoft. To help head off potential regressions though,
// we keep the registry method as a fallback option.
//
- // [more reliable]: https://github.com/alexcrichton/cc-rs/pull/331
+ // [more reliable]: https://github.com/rust-lang/cc-rs/pull/331
fn find_tool_in_vs15_path(tool: &str, target: &str) -> Option<Tool> {
let mut path = match vs15plus_instances(target) {
Some(instances) => instances
@@ -431,7 +431,7 @@ mod impl_ {
target: &str,
instance_path: &PathBuf,
) -> Option<Tool> {
- let (bin_path, host_dylib_path, lib_path, include_path) =
+ let (root_path, bin_path, host_dylib_path, lib_path, include_path) =
vs15plus_vc_paths(target, instance_path)?;
let tool_path = bin_path.join(tool);
if !tool_path.exists() {
@@ -444,7 +444,7 @@ mod impl_ {
tool.libs.push(lib_path);
tool.include.push(include_path);
- if let Some((atl_lib_path, atl_include_path)) = atl_paths(target, &bin_path) {
+ if let Some((atl_lib_path, atl_include_path)) = atl_paths(target, &root_path) {
tool.libs.push(atl_lib_path);
tool.include.push(atl_include_path);
}
@@ -457,7 +457,7 @@ mod impl_ {
fn vs15plus_vc_paths(
target: &str,
instance_path: &PathBuf,
- ) -> Option<(PathBuf, PathBuf, PathBuf, PathBuf)> {
+ ) -> Option<(PathBuf, PathBuf, PathBuf, PathBuf, PathBuf)> {
let version_path =
instance_path.join(r"VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt");
let mut version_file = File::open(version_path).ok()?;
@@ -490,7 +490,7 @@ mod impl_ {
.join(&host.to_lowercase());
let lib_path = path.join("lib").join(&target);
let include_path = path.join("include");
- Some((bin_path, host_dylib_path, lib_path, include_path))
+ Some((path, bin_path, host_dylib_path, lib_path, include_path))
}
fn atl_paths(target: &str, path: &Path) -> Option<(PathBuf, PathBuf)> {
diff --git a/vendor/cc/tests/test.rs b/vendor/cc/tests/test.rs
index 3c9b4dc49..35ef87577 100644
--- a/vendor/cc/tests/test.rs
+++ b/vendor/cc/tests/test.rs
@@ -344,6 +344,14 @@ fn gnu_static() {
}
#[test]
+fn gnu_no_dash_dash() {
+ let test = Test::gnu();
+ test.gcc().file("foo.c").compile("foo");
+
+ test.cmd(0).must_not_have("--");
+}
+
+#[test]
fn msvc_smoke() {
reset_env();
@@ -411,3 +419,11 @@ fn msvc_no_static_crt() {
test.cmd(0).must_have("-MD");
}
+
+#[test]
+fn msvc_no_dash_dash() {
+ let test = Test::msvc();
+ test.gcc().file("foo.c").compile("foo");
+
+ test.cmd(0).must_not_have("--");
+}