Skip to content

Revert "remove num_cpus dependency" in rustc and update cargo #97911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
@@ -219,6 +219,7 @@ dependencies = [
"hex 0.4.2",
"ignore",
"libc",
"num_cpus",
"once_cell",
"opener",
"pretty_assertions 0.7.2",
@@ -250,6 +251,7 @@ dependencies = [
"anyhow",
"flate2",
"hex 0.4.2",
"num_cpus",
"rayon",
"serde",
"serde_json",
@@ -349,6 +351,7 @@ dependencies = [
"libgit2-sys",
"log",
"memchr",
"num_cpus",
"opener",
"openssl",
"os_info",
@@ -4419,6 +4422,7 @@ name = "rustc_session"
version = "0.0.0"
dependencies = [
"getopts",
"num_cpus",
"rustc_ast",
"rustc_data_structures",
"rustc_errors",
1 change: 1 addition & 0 deletions compiler/rustc_session/Cargo.toml
Original file line number Diff line number Diff line change
@@ -15,5 +15,6 @@ rustc_serialize = { path = "../rustc_serialize" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_span = { path = "../rustc_span" }
rustc_fs_util = { path = "../rustc_fs_util" }
num_cpus = "1.0"
rustc_ast = { path = "../rustc_ast" }
rustc_lint_defs = { path = "../rustc_lint_defs" }
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
@@ -578,7 +578,7 @@ mod parse {
pub(crate) fn parse_threads(slot: &mut usize, v: Option<&str>) -> bool {
match v.and_then(|s| s.parse().ok()) {
Some(0) => {
*slot = std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get);
*slot = ::num_cpus::get();
true
}
Some(i) => {
1 change: 1 addition & 0 deletions src/bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@ test = false
[dependencies]
cmake = "0.1.38"
filetime = "0.2"
num_cpus = "1.0"
getopts = "0.2.19"
cc = "1.0.69"
libc = "0.2"
2 changes: 1 addition & 1 deletion src/bootstrap/config.rs
Original file line number Diff line number Diff line change
@@ -1418,7 +1418,7 @@ fn set<T>(field: &mut T, val: Option<T>) {

fn threads_from_config(v: u32) -> u32 {
match v {
0 => std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get) as u32,
0 => num_cpus::get() as u32,
n => n,
}
}
2 changes: 1 addition & 1 deletion src/bootstrap/flags.rs
Original file line number Diff line number Diff line change
@@ -210,7 +210,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
let j_msg = format!(
"number of jobs to run in parallel; \
defaults to {} (this host's logical CPU count)",
std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get)
num_cpus::get()
);
opts.optopt("j", "jobs", &j_msg, "JOBS");
opts.optflag("h", "help", "print this help message");
4 changes: 1 addition & 3 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
@@ -1032,9 +1032,7 @@ impl Build {
/// Returns the number of parallel jobs that have been configured for this
/// build.
fn jobs(&self) -> u32 {
self.config.jobs.unwrap_or_else(|| {
std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get) as u32
})
self.config.jobs.unwrap_or_else(|| num_cpus::get() as u32)
}

fn debuginfo_map_to(&self, which: GitRepo) -> Option<String> {
1 change: 1 addition & 0 deletions src/tools/build-manifest/Cargo.toml
Original file line number Diff line number Diff line change
@@ -13,3 +13,4 @@ tar = "0.4.29"
sha2 = "0.10.1"
rayon = "1.5.1"
hex = "0.4.2"
num_cpus = "1.13.0"
2 changes: 1 addition & 1 deletion src/tools/build-manifest/src/main.rs
Original file line number Diff line number Diff line change
@@ -210,7 +210,7 @@ fn main() {
let num_threads = if let Some(num) = env::var_os("BUILD_MANIFEST_NUM_THREADS") {
num.to_str().unwrap().parse().expect("invalid number for BUILD_MANIFEST_NUM_THREADS")
} else {
std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get)
num_cpus::get()
};
rayon::ThreadPoolBuilder::new()
.num_threads(num_threads)
2 changes: 1 addition & 1 deletion src/tools/cargo