diff --git a/CHANGELOG.md b/CHANGELOG.md index 915aaded..4741c253 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.2.18](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.17...cc-v1.2.18) - 2025-04-04 + +### Other + +- Regenerate target info ([#1450](https://github.com/rust-lang/cc-rs/pull/1450)) +- Use `std::thread::available_parallelism` for determining the default number of jobs ([#1447](https://github.com/rust-lang/cc-rs/pull/1447)) +- Fix mips64-openwrt-linux-musl parsing ([#1449](https://github.com/rust-lang/cc-rs/pull/1449)) +- Use compiler prefix `x86_64-linux-musl` ([#1443](https://github.com/rust-lang/cc-rs/pull/1443)) + ## [1.2.17](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.16...cc-v1.2.17) - 2025-03-21 ### Other diff --git a/Cargo.toml b/Cargo.toml index abbd3152..3346661f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cc" -version = "1.2.17" +version = "1.2.18" authors = ["Alex Crichton "] license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/cc-rs" diff --git a/src/command_helpers.rs b/src/command_helpers.rs index a34067f4..89dc1a33 100644 --- a/src/command_helpers.rs +++ b/src/command_helpers.rs @@ -46,7 +46,7 @@ impl CargoOutput { warnings: true, output: OutputKind::Forward, debug: match std::env::var_os("CC_ENABLE_DEBUG_OUTPUT") { - Some(v) => v != "0" && v != "false" && v != "", + Some(v) => v != "0" && v != "false" && !v.is_empty(), None => false, }, checked_dbg_var: Arc::new(AtomicBool::new(false)), diff --git a/src/flags.rs b/src/flags.rs index ed552e6e..91e9470a 100644 --- a/src/flags.rs +++ b/src/flags.rs @@ -185,7 +185,7 @@ impl<'this> RustcCodegenFlags<'this> { }; let clang_or_gnu = - matches!(family, ToolFamily::Clang { .. }) || matches!(family, ToolFamily::Gnu { .. }); + matches!(family, ToolFamily::Clang { .. }) || matches!(family, ToolFamily::Gnu); // Flags shared between clang and gnu if clang_or_gnu { @@ -315,7 +315,7 @@ impl<'this> RustcCodegenFlags<'this> { } } } - ToolFamily::Gnu { .. } => {} + ToolFamily::Gnu => {} ToolFamily::Msvc { .. } => { // https://learn.microsoft.com/en-us/cpp/build/reference/guard-enable-control-flow-guard if let Some(value) = self.control_flow_guard { diff --git a/src/lib.rs b/src/lib.rs index c259a073..85f15745 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3510,7 +3510,7 @@ impl Build { "x86_64-unknown-linux-gnu" => self.find_working_gnu_prefix(&[ "x86_64-linux-gnu", // rustfmt wrap ]), // explicit None if not found, so caller knows to fall back - "x86_64-unknown-linux-musl" => Some("musl"), + "x86_64-unknown-linux-musl" => Some("x86_64-linux-musl"), "x86_64-unknown-netbsd" => Some("x86_64--netbsd"), _ => None, } diff --git a/src/parallel/job_token.rs b/src/parallel/job_token.rs index 5528e1f8..c07fd94b 100644 --- a/src/parallel/job_token.rs +++ b/src/parallel/job_token.rs @@ -80,7 +80,7 @@ mod inherited_jobserver { pub(super) struct JobServer { /// Implicit token for this process which is obtained and will be - /// released in parent. Since JobTokens only give back what they got, + /// released in parent. Since `JobTokens` only give back what they got, /// there should be at most one global implicit token in the wild. /// /// Since Rust does not execute any `Drop` for global variables, @@ -164,7 +164,7 @@ mod inherited_jobserver { helper_thread: Option, } - impl<'a> ActiveJobServer<'a> { + impl ActiveJobServer<'_> { pub(super) async fn acquire(&mut self) -> Result { let mut has_requested_token = false; @@ -233,19 +233,14 @@ mod inprocess_jobserver { impl JobServer { pub(super) fn new() -> Self { // Use `NUM_JOBS` if set (it's configured by Cargo) and otherwise - // just fall back to a semi-reasonable number. - // - // Note that we could use `num_cpus` here but it's an extra - // dependency that will almost never be used, so - // it's generally not too worth it. - let mut parallelism = 4; - // TODO: Use std::thread::available_parallelism as an upper bound - // when MSRV is bumped. - if let Ok(amt) = var("NUM_JOBS") { - if let Ok(amt) = amt.parse() { - parallelism = amt; - } - } + // just fall back to the number of cores on the local machine, or a reasonable + // default if that cannot be determined. + + let parallelism = var("NUM_JOBS") + .ok() + .and_then(|j| j.parse::().ok()) + .or_else(|| Some(std::thread::available_parallelism().ok()?.get() as u32)) + .unwrap_or(4); Self(AtomicU32::new(parallelism)) } diff --git a/src/parallel/stderr.rs b/src/parallel/stderr.rs index 70186860..2e5b0544 100644 --- a/src/parallel/stderr.rs +++ b/src/parallel/stderr.rs @@ -1,5 +1,5 @@ #![cfg_attr(target_family = "wasm", allow(unused))] -/// Helpers functions for [ChildStderr]. +/// Helpers functions for [`ChildStderr`]. use std::{convert::TryInto, process::ChildStderr}; use crate::{Error, ErrorKind}; diff --git a/src/target/generated.rs b/src/target/generated.rs index 1449646e..aebeb88f 100644 --- a/src/target/generated.rs +++ b/src/target/generated.rs @@ -65,14 +65,14 @@ pub(crate) const LLVM_TARGETS: &[(&str, &str)] = &[ ("armv5te-none-eabi", "armv5te-none-eabi"), ("armv5te-unknown-linux-gnueabi", "armv5te-unknown-linux-gnueabi"), ("armv5te-unknown-linux-musleabi", "armv5te-unknown-linux-musleabi"), - ("armv5te-unknown-linux-uclibceabi", "armv5te-unknown-linux-uclibcgnueabi"), + ("armv5te-unknown-linux-uclibceabi", "armv5te-unknown-linux-gnueabi"), ("armv6-unknown-freebsd", "armv6-unknown-freebsd-gnueabihf"), ("armv6-unknown-netbsd-eabihf", "armv6-unknown-netbsdelf-eabihf"), ("armv6k-nintendo-3ds", "armv6k-none-eabihf"), ("armv7-apple-ios", "armv7-apple-ios7.0.0"), ("armv7-linux-androideabi", "armv7-none-linux-android"), ("armv7-rtems-eabihf", "armv7-unknown-none-eabihf"), - ("armv7-sony-vita-newlibeabihf", "thumbv7a-vita-eabihf"), + ("armv7-sony-vita-newlibeabihf", "thumbv7a-sony-vita-eabihf"), ("armv7-unknown-freebsd", "armv7-unknown-freebsd-gnueabihf"), ("armv7-unknown-linux-gnueabi", "armv7-unknown-linux-gnueabi"), ("armv7-unknown-linux-gnueabihf", "armv7-unknown-linux-gnueabihf"), @@ -139,7 +139,7 @@ pub(crate) const LLVM_TARGETS: &[(&str, &str)] = &[ ("mips-mti-none-elf", "mips"), ("mips-unknown-linux-gnu", "mips-unknown-linux-gnu"), ("mips-unknown-linux-musl", "mips-unknown-linux-musl"), - ("mips-unknown-linux-uclibc", "mips-unknown-linux-uclibc"), + ("mips-unknown-linux-uclibc", "mips-unknown-linux-gnu"), ("mips64-openwrt-linux-musl", "mips64-unknown-linux-musl"), ("mips64-unknown-linux-gnuabi64", "mips64-unknown-linux-gnuabi64"), ("mips64-unknown-linux-muslabi64", "mips64-unknown-linux-musl"), @@ -150,7 +150,7 @@ pub(crate) const LLVM_TARGETS: &[(&str, &str)] = &[ ("mipsel-sony-psx", "mipsel-sony-psx"), ("mipsel-unknown-linux-gnu", "mipsel-unknown-linux-gnu"), ("mipsel-unknown-linux-musl", "mipsel-unknown-linux-musl"), - ("mipsel-unknown-linux-uclibc", "mipsel-unknown-linux-uclibc"), + ("mipsel-unknown-linux-uclibc", "mipsel-unknown-linux-gnu"), ("mipsel-unknown-netbsd", "mipsel-unknown-netbsd"), ("mipsel-unknown-none", "mipsel-unknown-none"), ("mipsisa32r6-unknown-linux-gnu", "mipsisa32r6-unknown-linux-gnu"), @@ -275,7 +275,7 @@ pub(crate) const LLVM_TARGETS: &[(&str, &str)] = &[ ("x86_64-unknown-hermit", "x86_64-unknown-hermit"), ("x86_64-unknown-hurd-gnu", "x86_64-unknown-hurd-gnu"), ("x86_64-unknown-illumos", "x86_64-pc-solaris"), - ("x86_64-unknown-l4re-uclibc", "x86_64-unknown-l4re-uclibc"), + ("x86_64-unknown-l4re-uclibc", "x86_64-unknown-l4re-gnu"), ("x86_64-unknown-linux-gnu", "x86_64-unknown-linux-gnu"), ("x86_64-unknown-linux-gnux32", "x86_64-unknown-linux-gnux32"), ("x86_64-unknown-linux-musl", "x86_64-unknown-linux-musl"), diff --git a/src/target/parser.rs b/src/target/parser.rs index 931ad03e..a04aaf51 100644 --- a/src/target/parser.rs +++ b/src/target/parser.rs @@ -381,8 +381,6 @@ impl<'a> TargetInfo<'a> { let vendor = match vendor { // esp, esp32, esp32s2 etc. vendor if vendor.starts_with("esp") => "espressif", - // FIXME(madsmtm): https://github.com/rust-lang/rust/issues/131165 - "openwrt" => "unknown", // FIXME(madsmtm): Badly named targets `*-linux-android*`, // "linux" makes no sense as the vendor name. "linux" if os == "android" || os == "androideabi" => "unknown", @@ -477,13 +475,13 @@ mod tests { let (full_arch, _rest) = target.split_once('-').expect("target to have arch"); let mut target = TargetInfo { - full_arch: full_arch.into(), - arch: "invalid-none-set".into(), - vendor: "invalid-none-set".into(), - os: "invalid-none-set".into(), - env: "invalid-none-set".into(), + full_arch, + arch: "invalid-none-set", + vendor: "invalid-none-set", + os: "invalid-none-set", + env: "invalid-none-set", // Not set in older Rust versions - abi: "".into(), + abi: "", }; for cfg in cfgs.lines() { diff --git a/tests/cc_env.rs b/tests/cc_env.rs index 7eed9542..65015f78 100644 --- a/tests/cc_env.rs +++ b/tests/cc_env.rs @@ -117,7 +117,7 @@ fn clang_cl() { for exe_suffix in ["", ".exe"] { let test = Test::clang(); let bin = format!("clang{exe_suffix}"); - env::set_var("CC", &format!("{bin} --driver-mode=cl")); + env::set_var("CC", format!("{bin} --driver-mode=cl")); let test_compiler = |build: cc::Build| { let compiler = build.get_compiler(); assert_eq!(compiler.path(), Path::new(&*bin)); diff --git a/tests/test.rs b/tests/test.rs index d1c11e93..bcac1002 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -532,8 +532,8 @@ fn gnu_apple_sysroot() { test.shim("fake-gcc") .gcc() .compiler("fake-gcc") - .target(&target) - .host(&target) + .target(target) + .host(target) .file("foo.c") .compile("foo");