@@ -1294,7 +1294,7 @@ impl Build {
1294
1294
1295
1295
#[ cfg( feature = "parallel" ) ]
1296
1296
fn compile_objects ( & self , objs : & [ Object ] , print : & PrintThread ) -> Result < ( ) , Error > {
1297
- use std:: sync:: { mpsc, Once } ;
1297
+ use std:: sync:: mpsc;
1298
1298
1299
1299
if objs. len ( ) <= 1 {
1300
1300
for obj in objs {
@@ -1306,7 +1306,7 @@ impl Build {
1306
1306
}
1307
1307
1308
1308
// Limit our parallelism globally with a jobserver.
1309
- let server = jobserver ( ) ;
1309
+ let server = job_token :: jobserver ( ) ;
1310
1310
// Reacquire our process's token on drop
1311
1311
1312
1312
// When compiling objects in parallel we do a few dirty tricks to speed
@@ -1440,51 +1440,6 @@ impl Build {
1440
1440
1441
1441
return wait_thread. join ( ) . expect ( "wait_thread panics" ) ;
1442
1442
1443
- /// Returns a suitable `jobserver::Client` used to coordinate
1444
- /// parallelism between build scripts.
1445
- fn jobserver ( ) -> jobserver:: Client {
1446
- static INIT : Once = Once :: new ( ) ;
1447
- static mut JOBSERVER : Option < jobserver:: Client > = None ;
1448
-
1449
- fn _assert_sync < T : Sync > ( ) { }
1450
- _assert_sync :: < jobserver:: Client > ( ) ;
1451
-
1452
- unsafe {
1453
- INIT . call_once ( || {
1454
- let server = default_jobserver ( ) ;
1455
- JOBSERVER = Some ( server) ;
1456
- } ) ;
1457
- JOBSERVER . clone ( ) . unwrap ( )
1458
- }
1459
- }
1460
-
1461
- unsafe fn default_jobserver ( ) -> jobserver:: Client {
1462
- // Try to use the environmental jobserver which Cargo typically
1463
- // initializes for us...
1464
- if let Some ( client) = jobserver:: Client :: from_env ( ) {
1465
- return client;
1466
- }
1467
-
1468
- // ... but if that fails for whatever reason select something
1469
- // reasonable and crate a new jobserver. Use `NUM_JOBS` if set (it's
1470
- // configured by Cargo) and otherwise just fall back to a
1471
- // semi-reasonable number. Note that we could use `num_cpus` here
1472
- // but it's an extra dependency that will almost never be used, so
1473
- // it's generally not too worth it.
1474
- let mut parallelism = 4 ;
1475
- if let Ok ( amt) = env:: var ( "NUM_JOBS" ) {
1476
- if let Ok ( amt) = amt. parse ( ) {
1477
- parallelism = amt;
1478
- }
1479
- }
1480
-
1481
- // If we create our own jobserver then be sure to reserve one token
1482
- // for ourselves.
1483
- let client = jobserver:: Client :: new ( parallelism) . expect ( "failed to create jobserver" ) ;
1484
- client. acquire_raw ( ) . expect ( "failed to acquire initial" ) ;
1485
- return client;
1486
- }
1487
-
1488
1443
struct KillOnDrop ( Child ) ;
1489
1444
1490
1445
impl Drop for KillOnDrop {
0 commit comments