diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index afe4442799b2..8b6a8fea4cab 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1859,6 +1859,13 @@ pub fn build_session_options_and_crate_config( ); } + if debugging_opts.query_threads.unwrap_or(1) > 1 && debugging_opts.fuel.is_some() { + early_error( + error_format, + "Optimization fuel is incompatible with multiple query threads", + ); + } + if codegen_units == Some(0) { early_error( error_format, diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index d02c2bbb810e..2f036be011be 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -26,7 +26,7 @@ use util::nodemap::{FxHashMap, FxHashSet}; use util::common::{duration_to_secs_str, ErrorReported}; use util::common::ProfileQueriesMsg; -use rustc_data_structures::sync::{Lrc, Lock, OneThread, Once}; +use rustc_data_structures::sync::{Lrc, Lock, LockCell, OneThread, Once}; use syntax::ast::NodeId; use errors::{self, DiagnosticBuilder, DiagnosticId}; @@ -146,15 +146,15 @@ pub struct Session { /// If -zfuel=crate=n is specified, Some(crate). optimization_fuel_crate: Option, /// If -zfuel=crate=n is specified, initially set to n. Otherwise 0. - optimization_fuel_limit: Cell, + optimization_fuel_limit: LockCell, /// We're rejecting all further optimizations. - out_of_fuel: Cell, + out_of_fuel: LockCell, // The next two are public because the driver needs to read them. /// If -zprint-fuel=crate, Some(crate). pub print_fuel_crate: Option, /// Always set to zero and incremented so that we can print fuel expended by a crate. - pub print_fuel: Cell, + pub print_fuel: LockCell, /// Loaded up early on in the initialization of this `Session` to avoid /// false positives about a job server in our environment. @@ -846,6 +846,7 @@ impl Session { /// We want to know if we're allowed to do an optimization for crate foo from -z fuel=foo=n. /// This expends fuel if applicable, and records fuel if applicable. pub fn consider_optimizing String>(&self, crate_name: &str, msg: T) -> bool { + assert!(self.query_threads() == 1); let mut ret = true; match self.optimization_fuel_crate { Some(ref c) if c == crate_name => { @@ -1075,9 +1076,9 @@ pub fn build_session_( let optimization_fuel_crate = sopts.debugging_opts.fuel.as_ref().map(|i| i.0.clone()); let optimization_fuel_limit = - Cell::new(sopts.debugging_opts.fuel.as_ref().map(|i| i.1).unwrap_or(0)); + LockCell::new(sopts.debugging_opts.fuel.as_ref().map(|i| i.1).unwrap_or(0)); let print_fuel_crate = sopts.debugging_opts.print_fuel.clone(); - let print_fuel = Cell::new(0); + let print_fuel = LockCell::new(0); let working_dir = match env::current_dir() { Ok(dir) => dir, @@ -1132,7 +1133,7 @@ pub fn build_session_( optimization_fuel_limit, print_fuel_crate, print_fuel, - out_of_fuel: Cell::new(false), + out_of_fuel: LockCell::new(false), // Note that this is unsafe because it may misinterpret file descriptors // on Unix as jobserver file descriptors. We hopefully execute this near // the beginning of the process though to ensure we don't get false