diff options
| author | SparrowLii <liyuan179@huawei.com> | 2022-06-29 10:02:30 +0800 |
|---|---|---|
| committer | SparrowLii <liyuan179@huawei.com> | 2022-06-29 10:02:30 +0800 |
| commit | fbca21edd27dcd6e49a8020ed77a133ffa357c63 (patch) | |
| tree | 2e95e882f80b978ca28d27324f23eb5b07e0c2d4 /compiler/rustc_interface | |
| parent | 3b0d4813ab461ec81eab8980bb884691c97c5a35 (diff) | |
| download | rust-fbca21edd27dcd6e49a8020ed77a133ffa357c63.tar.gz rust-fbca21edd27dcd6e49a8020ed77a133ffa357c63.zip | |
get rid of `tcx` in deadlock handler when parallel compilation
Diffstat (limited to 'compiler/rustc_interface')
| -rw-r--r-- | compiler/rustc_interface/src/util.rs | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index fb9258eb4a9..8796ad5a33c 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -10,7 +10,7 @@ use rustc_errors::registry::Registry; use rustc_middle::ty::tls; use rustc_parse::validate_attr; #[cfg(parallel_compiler)] -use rustc_query_impl::QueryCtxt; +use rustc_query_impl::{QueryContext, QueryCtxt}; use rustc_session as session; use rustc_session::config::CheckCfg; use rustc_session::config::{self, CrateType}; @@ -166,20 +166,12 @@ pub fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>( unsafe fn handle_deadlock() { let registry = rustc_rayon_core::Registry::current(); - let context = tls::get_tlv(); - assert!(context != 0); - rustc_data_structures::sync::assert_sync::<tls::ImplicitCtxt<'_, '_>>(); - let icx: &tls::ImplicitCtxt<'_, '_> = &*(context as *const tls::ImplicitCtxt<'_, '_>); - - let session_globals = rustc_span::with_session_globals(|sg| sg as *const _); - let session_globals = &*session_globals; - thread::spawn(move || { - tls::enter_context(icx, |_| { - rustc_span::set_session_globals_then(session_globals, || { - tls::with(|tcx| QueryCtxt::from_tcx(tcx).deadlock(®istry)) - }) - }); + let query_map = tls::with(|tcx| { + QueryCtxt::from_tcx(tcx) + .try_collect_active_jobs() + .expect("active jobs shouldn't be locked in deadlock handler") }); + thread::spawn(move || rustc_query_impl::deadlock(query_map, ®istry)); } #[cfg(parallel_compiler)] |
