about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndreas Jonson <andjo403@users.noreply.github.com>2018-04-23 17:00:08 +0200
committerAndreas Jonson <andjo403@users.noreply.github.com>2018-04-23 17:02:01 +0200
commited318dd991cb5356fe299aa8fc8c3078dcc614d3 (patch)
treedd080b03357e93ce6d20381019c67b8da1fcaff4
parentb78853b6fd9597dc42ccf044fed805851d0a6f91 (diff)
downloadrust-ed318dd991cb5356fe299aa8fc8c3078dcc614d3.tar.gz
rust-ed318dd991cb5356fe299aa8fc8c3078dcc614d3.zip
make rustdoc test follow the jobserver limit of threadsfix that to many threads is executing at the same timewhen rustdoc test is executed.
-rw-r--r--src/librustc/session/mod.rs17
-rw-r--r--src/librustc_trans/back/write.rs9
2 files changed, 14 insertions, 12 deletions
diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs
index 2993234f266..e2be51b552a 100644
--- a/src/librustc/session/mod.rs
+++ b/src/librustc/session/mod.rs
@@ -156,7 +156,7 @@ pub struct Session {
 
     /// Loaded up early on in the initialization of this `Session` to avoid
     /// false positives about a job server in our environment.
-    pub jobserver_from_env: Option<Client>,
+    pub jobserver: Client,
 
     /// Metadata about the allocators for the current crate being compiled
     pub has_global_allocator: Once<bool>,
@@ -1128,14 +1128,23 @@ pub fn build_session_(
         // positives, or in other words we try to execute this before we open
         // any file descriptors ourselves.
         //
+        // Pick a "reasonable maximum" if we don't otherwise have
+        // a jobserver in our environment, capping out at 32 so we
+        // don't take everything down by hogging the process run queue.
+        // The fixed number is used to have deterministic compilation
+        // across machines.
+        //
         // Also note that we stick this in a global because there could be
         // multiple `Session` instances in this process, and the jobserver is
         // per-process.
-        jobserver_from_env: unsafe {
-            static mut GLOBAL_JOBSERVER: *mut Option<Client> = 0 as *mut _;
+        jobserver: unsafe {
+            static mut GLOBAL_JOBSERVER: *mut Client = 0 as *mut _;
             static INIT: std::sync::Once = std::sync::ONCE_INIT;
             INIT.call_once(|| {
-                GLOBAL_JOBSERVER = Box::into_raw(Box::new(Client::from_env()));
+                let client = Client::from_env().unwrap_or_else(|| {
+                    Client::new(32).expect("failed to create jobserver")
+                });
+                GLOBAL_JOBSERVER = Box::into_raw(Box::new(client));
             });
             (*GLOBAL_JOBSERVER).clone()
         },
diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs
index f501b1739eb..613a07cd269 100644
--- a/src/librustc_trans/back/write.rs
+++ b/src/librustc_trans/back/write.rs
@@ -1007,13 +1007,6 @@ pub fn start_async_translation(tcx: TyCtxt,
     metadata_config.time_passes = false;
     allocator_config.time_passes = false;
 
-    let client = sess.jobserver_from_env.clone().unwrap_or_else(|| {
-        // Pick a "reasonable maximum" if we don't otherwise have a jobserver in
-        // our environment, capping out at 32 so we don't take everything down
-        // by hogging the process run queue.
-        Client::new(32).expect("failed to create jobserver")
-    });
-
     let (shared_emitter, shared_emitter_main) = SharedEmitter::new();
     let (trans_worker_send, trans_worker_receive) = channel();
 
@@ -1023,7 +1016,7 @@ pub fn start_async_translation(tcx: TyCtxt,
                                                   trans_worker_send,
                                                   coordinator_receive,
                                                   total_cgus,
-                                                  client,
+                                                  sess.jobserver.clone(),
                                                   time_graph.clone(),
                                                   Arc::new(modules_config),
                                                   Arc::new(metadata_config),