about summary refs log tree commit diff
path: root/compiler/rustc_driver_impl
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-05-13 13:47:53 +0000
committerbors <bors@rust-lang.org>2023-05-13 13:47:53 +0000
commitdd8ec9c88d4d87986cbf2083c398ab6c52dc3f80 (patch)
tree22ad92e8e8006bb13148563bd267e6a09b552a88 /compiler/rustc_driver_impl
parentebf2b375e16b3b1422d48892d235d83a1b451802 (diff)
parentd7e3e5bede187d113fa01c4d8b8c16a2bd4f721c (diff)
downloadrust-dd8ec9c88d4d87986cbf2083c398ab6c52dc3f80.tar.gz
rust-dd8ec9c88d4d87986cbf2083c398ab6c52dc3f80.zip
Auto merge of #107586 - SparrowLii:parallel-query, r=cjgillot
Introduce `DynSend` and `DynSync` auto trait for parallel compiler

part of parallel-rustc #101566

This PR introduces `DynSend / DynSync` trait and `FromDyn / IntoDyn` structure in rustc_data_structure::marker. `FromDyn` can dynamically check data structures for thread safety when switching to parallel environments (such as calling `par_for_each_in`). This happens only when `-Z threads > 1` so it doesn't affect single-threaded mode's compile efficiency.

r? `@cjgillot`
Diffstat (limited to 'compiler/rustc_driver_impl')
-rw-r--r--compiler/rustc_driver_impl/src/lib.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs
index 9b16f246193..80a9dfd251a 100644
--- a/compiler/rustc_driver_impl/src/lib.rs
+++ b/compiler/rustc_driver_impl/src/lib.rs
@@ -256,6 +256,9 @@ fn run_compiler(
 
     let sopts = config::build_session_options(&matches);
 
+    // Set parallel mode before thread pool creation, which will create `Lock`s.
+    interface::set_thread_safe_mode(&sopts.unstable_opts);
+
     if let Some(ref code) = matches.opt_str("explain") {
         handle_explain(diagnostics_registry(), code, sopts.error_format);
         return Ok(());