diff options
| author | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2020-10-31 12:01:54 +0100 |
|---|---|---|
| committer | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2023-04-16 05:50:57 +0200 |
| commit | 64474a40b0273557dbea58ca29af9245cbb4ad87 (patch) | |
| tree | 2be6396311b795b12a8a603ab84b80349c3f91c8 /compiler/rustc_interface/src/util.rs | |
| parent | c6fb7b9815aea87fb5ced1c683212871699c907c (diff) | |
| download | rust-64474a40b0273557dbea58ca29af9245cbb4ad87.tar.gz rust-64474a40b0273557dbea58ca29af9245cbb4ad87.zip | |
Move the WorkerLocal type from the rustc-rayon fork into rustc_data_structures
Diffstat (limited to 'compiler/rustc_interface/src/util.rs')
| -rw-r--r-- | compiler/rustc_interface/src/util.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index 612903810d2..a27a1e2978a 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -4,6 +4,8 @@ use libloading::Library; use rustc_ast as ast; use rustc_codegen_ssa::traits::CodegenBackend; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +#[cfg(parallel_compiler)] +use rustc_data_structures::sync; use rustc_errors::registry::Registry; use rustc_parse::validate_attr; use rustc_session as session; @@ -170,6 +172,7 @@ pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>( use rustc_middle::ty::tls; use rustc_query_impl::{deadlock, QueryContext, QueryCtxt}; + let registry = sync::Registry::new(threads); let mut builder = rayon::ThreadPoolBuilder::new() .thread_name(|_| "rustc".to_string()) .acquire_thread_handler(jobserver::acquire_thread) @@ -200,6 +203,9 @@ pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>( .build_scoped( // Initialize each new worker thread when created. move |thread: rayon::ThreadBuilder| { + // Register the thread for use with the `WorkerLocal` type. + registry.register(); + rustc_span::set_session_globals_then(session_globals, || thread.run()) }, // Run `f` on the first thread in the thread pool. |
