@@ -156,7 +156,7 @@ pub struct Session {
156
156
157
157
/// Loaded up early on in the initialization of this `Session` to avoid
158
158
/// false positives about a job server in our environment.
159
- pub jobserver_from_env : Option < Client > ,
159
+ pub jobserver : Client ,
160
160
161
161
/// Metadata about the allocators for the current crate being compiled
162
162
pub has_global_allocator : Once < bool > ,
@@ -1128,14 +1128,23 @@ pub fn build_session_(
1128
1128
// positives, or in other words we try to execute this before we open
1129
1129
// any file descriptors ourselves.
1130
1130
//
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
+ //
1131
1137
// Also note that we stick this in a global because there could be
1132
1138
// multiple `Session` instances in this process, and the jobserver is
1133
1139
// 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 _ ;
1136
1142
static INIT : std:: sync:: Once = std:: sync:: ONCE_INIT ;
1137
1143
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) ) ;
1139
1148
} ) ;
1140
1149
( * GLOBAL_JOBSERVER ) . clone ( )
1141
1150
} ,
0 commit comments