@@ -156,7 +156,7 @@ pub struct Session {
156156
157157 /// Loaded up early on in the initialization of this `Session` to avoid
158158 /// false positives about a job server in our environment.
159- pub jobserver_from_env : Option < Client > ,
159+ pub jobserver : Client ,
160160
161161 /// Metadata about the allocators for the current crate being compiled
162162 pub has_global_allocator : Once < bool > ,
@@ -1128,14 +1128,23 @@ pub fn build_session_(
11281128 // positives, or in other words we try to execute this before we open
11291129 // any file descriptors ourselves.
11301130 //
1131+ // Pick a "reasonable maximum" if we don't otherwise have
1132+ // a jobserver in our environment, capping out at 32 so we
1133+ // don't take everything down by hogging the process run queue.
1134+ // The fixed number is used to have deterministic compilation
1135+ // across machines.
1136+ //
11311137 // Also note that we stick this in a global because there could be
11321138 // multiple `Session` instances in this process, and the jobserver is
11331139 // per-process.
1134- jobserver_from_env : unsafe {
1135- static mut GLOBAL_JOBSERVER : * mut Option < Client > = 0 as * mut _ ;
1140+ jobserver : unsafe {
1141+ static mut GLOBAL_JOBSERVER : * mut Client = 0 as * mut _ ;
11361142 static INIT : std:: sync:: Once = std:: sync:: ONCE_INIT ;
11371143 INIT . call_once ( || {
1138- GLOBAL_JOBSERVER = Box :: into_raw ( Box :: new ( Client :: from_env ( ) ) ) ;
1144+ let client = Client :: from_env ( ) . unwrap_or_else ( || {
1145+ Client :: new ( 32 ) . expect ( "failed to create jobserver" )
1146+ } ) ;
1147+ GLOBAL_JOBSERVER = Box :: into_raw ( Box :: new ( client) ) ;
11391148 } ) ;
11401149 ( * GLOBAL_JOBSERVER ) . clone ( )
11411150 } ,
0 commit comments