diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 6e0372f009e..84c63a05024 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1067,6 +1067,8 @@ fn parse_optimization_fuel(slot: &mut Option<(String, u64)>, v: Option<&str>) -> "prints the llvm optimization passes being run"), ast_json: bool = (false, parse_bool, [UNTRACKED], "print the AST as JSON and halt"), + query_threads: Option = (None, parse_opt_uint, [UNTRACKED], + "execute queries on a thread pool with N threads"), ast_json_noexpand: bool = (false, parse_bool, [UNTRACKED], "print the pre-expansion AST as JSON and halt"), ls: bool = (false, parse_bool, [UNTRACKED], @@ -1663,6 +1665,10 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches) } } + if debugging_opts.query_threads == Some(0) { + early_error(error_format, "Value for query threads must be a positive nonzero integer"); + } + if codegen_units == Some(0) { early_error(error_format, "Value for codegen units must be a positive nonzero integer"); } diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 60a218500ca..0de1c20dbde 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -725,6 +725,12 @@ pub fn consider_optimizing String>(&self, crate_name: &str, msg: T) - ret } + /// Returns the number of query threads that should be used for this + /// compilation + pub fn query_threads(&self) -> usize { + self.opts.debugging_opts.query_threads.unwrap_or(1) + } + /// Returns the number of codegen units that should be used for this /// compilation pub fn codegen_units(&self) -> usize {