Skip to content

Commit aa6065b

Browse files
committed
Add a -Z query-threads compiler option
1 parent f7082dc commit aa6065b

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/librustc/session/config.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
10671067
"prints the llvm optimization passes being run"),
10681068
ast_json: bool = (false, parse_bool, [UNTRACKED],
10691069
"print the AST as JSON and halt"),
1070+
query_threads: Option<usize> = (None, parse_opt_uint, [UNTRACKED],
1071+
"execute queries on a thread pool with N threads"),
10701072
ast_json_noexpand: bool = (false, parse_bool, [UNTRACKED],
10711073
"print the pre-expansion AST as JSON and halt"),
10721074
ls: bool = (false, parse_bool, [UNTRACKED],
@@ -1663,6 +1665,10 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
16631665
}
16641666
}
16651667

1668+
if debugging_opts.query_threads == Some(0) {
1669+
early_error(error_format, "Value for query threads must be a positive nonzero integer");
1670+
}
1671+
16661672
if codegen_units == Some(0) {
16671673
early_error(error_format, "Value for codegen units must be a positive nonzero integer");
16681674
}

src/librustc/session/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,12 @@ impl Session {
725725
ret
726726
}
727727

728+
/// Returns the number of query threads that should be used for this
729+
/// compilation
730+
pub fn query_threads(&self) -> usize {
731+
self.opts.debugging_opts.query_threads.unwrap_or(1)
732+
}
733+
728734
/// Returns the number of codegen units that should be used for this
729735
/// compilation
730736
pub fn codegen_units(&self) -> usize {

0 commit comments

Comments
 (0)