Rollup merge of #94524 - bjorn3:remove_num_cpus, r=Mark-Simulacrum
Remove num_cpus dependency from bootstrap, build-manifest and rustc_s… …ession `std::threads::available_parallelism` was stabilized in rust 1.59. r? ```````````````````````````@Mark-Simulacrum```````````````````````````
This commit is contained in:
commit
5115bdc2e2
@ -221,7 +221,6 @@ dependencies = [
|
|||||||
"getopts",
|
"getopts",
|
||||||
"ignore",
|
"ignore",
|
||||||
"libc",
|
"libc",
|
||||||
"num_cpus",
|
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"opener",
|
"opener",
|
||||||
"pretty_assertions",
|
"pretty_assertions",
|
||||||
@ -249,7 +248,6 @@ dependencies = [
|
|||||||
"anyhow",
|
"anyhow",
|
||||||
"flate2",
|
"flate2",
|
||||||
"hex 0.4.2",
|
"hex 0.4.2",
|
||||||
"num_cpus",
|
|
||||||
"rayon",
|
"rayon",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@ -4242,7 +4240,6 @@ name = "rustc_session"
|
|||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getopts",
|
"getopts",
|
||||||
"num_cpus",
|
|
||||||
"rustc_ast",
|
"rustc_ast",
|
||||||
"rustc_data_structures",
|
"rustc_data_structures",
|
||||||
"rustc_errors",
|
"rustc_errors",
|
||||||
|
@ -15,6 +15,5 @@ rustc_serialize = { path = "../rustc_serialize" }
|
|||||||
rustc_data_structures = { path = "../rustc_data_structures" }
|
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||||
rustc_span = { path = "../rustc_span" }
|
rustc_span = { path = "../rustc_span" }
|
||||||
rustc_fs_util = { path = "../rustc_fs_util" }
|
rustc_fs_util = { path = "../rustc_fs_util" }
|
||||||
num_cpus = "1.0"
|
|
||||||
rustc_ast = { path = "../rustc_ast" }
|
rustc_ast = { path = "../rustc_ast" }
|
||||||
rustc_lint_defs = { path = "../rustc_lint_defs" }
|
rustc_lint_defs = { path = "../rustc_lint_defs" }
|
||||||
|
@ -551,7 +551,7 @@ mod parse {
|
|||||||
crate fn parse_threads(slot: &mut usize, v: Option<&str>) -> bool {
|
crate fn parse_threads(slot: &mut usize, v: Option<&str>) -> bool {
|
||||||
match v.and_then(|s| s.parse().ok()) {
|
match v.and_then(|s| s.parse().ok()) {
|
||||||
Some(0) => {
|
Some(0) => {
|
||||||
*slot = ::num_cpus::get();
|
*slot = std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
Some(i) => {
|
Some(i) => {
|
||||||
|
@ -37,7 +37,6 @@ test = false
|
|||||||
build_helper = { path = "../build_helper" }
|
build_helper = { path = "../build_helper" }
|
||||||
cmake = "0.1.38"
|
cmake = "0.1.38"
|
||||||
filetime = "0.2"
|
filetime = "0.2"
|
||||||
num_cpus = "1.0"
|
|
||||||
getopts = "0.2.19"
|
getopts = "0.2.19"
|
||||||
cc = "1.0.69"
|
cc = "1.0.69"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
|
@ -1187,7 +1187,7 @@ fn set<T>(field: &mut T, val: Option<T>) {
|
|||||||
|
|
||||||
fn threads_from_config(v: u32) -> u32 {
|
fn threads_from_config(v: u32) -> u32 {
|
||||||
match v {
|
match v {
|
||||||
0 => num_cpus::get() as u32,
|
0 => std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get) as u32,
|
||||||
n => n,
|
n => n,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ pub fn parse(args: &[String]) -> Flags {
|
|||||||
let j_msg = format!(
|
let j_msg = format!(
|
||||||
"number of jobs to run in parallel; \
|
"number of jobs to run in parallel; \
|
||||||
defaults to {} (this host's logical CPU count)",
|
defaults to {} (this host's logical CPU count)",
|
||||||
num_cpus::get()
|
std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get)
|
||||||
);
|
);
|
||||||
opts.optopt("j", "jobs", &j_msg, "JOBS");
|
opts.optopt("j", "jobs", &j_msg, "JOBS");
|
||||||
opts.optflag("h", "help", "print this help message");
|
opts.optflag("h", "help", "print this help message");
|
||||||
|
@ -922,7 +922,9 @@ fn info(&self, msg: &str) {
|
|||||||
/// Returns the number of parallel jobs that have been configured for this
|
/// Returns the number of parallel jobs that have been configured for this
|
||||||
/// build.
|
/// build.
|
||||||
fn jobs(&self) -> u32 {
|
fn jobs(&self) -> u32 {
|
||||||
self.config.jobs.unwrap_or_else(|| num_cpus::get() as u32)
|
self.config.jobs.unwrap_or_else(|| {
|
||||||
|
std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get) as u32
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn debuginfo_map_to(&self, which: GitRepo) -> Option<String> {
|
fn debuginfo_map_to(&self, which: GitRepo) -> Option<String> {
|
||||||
|
@ -13,4 +13,3 @@ tar = "0.4.29"
|
|||||||
sha2 = "0.10.1"
|
sha2 = "0.10.1"
|
||||||
rayon = "1.5.1"
|
rayon = "1.5.1"
|
||||||
hex = "0.4.2"
|
hex = "0.4.2"
|
||||||
num_cpus = "1.13.0"
|
|
||||||
|
@ -208,7 +208,7 @@ fn main() {
|
|||||||
let num_threads = if let Some(num) = env::var_os("BUILD_MANIFEST_NUM_THREADS") {
|
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")
|
num.to_str().unwrap().parse().expect("invalid number for BUILD_MANIFEST_NUM_THREADS")
|
||||||
} else {
|
} else {
|
||||||
num_cpus::get()
|
std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get)
|
||||||
};
|
};
|
||||||
rayon::ThreadPoolBuilder::new()
|
rayon::ThreadPoolBuilder::new()
|
||||||
.num_threads(num_threads)
|
.num_threads(num_threads)
|
||||||
|
Loading…
Reference in New Issue
Block a user