]> git.lizzy.rs Git - rust.git/commitdiff
Add a -Z query-threads compiler option
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>
Sun, 3 Dec 2017 13:16:19 +0000 (14:16 +0100)
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>
Thu, 21 Dec 2017 18:21:40 +0000 (19:21 +0100)
src/librustc/session/config.rs
src/librustc/session/mod.rs

index 6e0372f009ecefc17af6d0e4ab37cb1e42565469..84c63a05024a45d49393e2dbf69d82e730cb5707 100644 (file)
@@ -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<usize> = (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");
     }
index 60a218500ca78b15761b7a448dc22b602c4e37b0..0de1c20dbde1e02e588d8cfc7beed9d50c2a1e2b 100644 (file)
@@ -725,6 +725,12 @@ pub fn consider_optimizing<T: Fn() -> 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 {