Skip to content

Commit ead78fd

Browse files
committed
Remove jobserver from Session
It is effectively a global resource and the jobserver::Client in Session was a clone of GLOBAL_CLIENT anyway.
1 parent 8e37e15 commit ead78fd

File tree

8 files changed

+9
-23
lines changed

8 files changed

+9
-23
lines changed

Cargo.lock

-1
Original file line numberDiff line numberDiff line change
@@ -3507,7 +3507,6 @@ dependencies = [
35073507
"cc",
35083508
"either",
35093509
"itertools",
3510-
"jobserver",
35113510
"libc",
35123511
"object 0.36.5",
35133512
"pathdiff",

compiler/rustc_codegen_cranelift/src/concurrency_limiter.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use std::sync::{Arc, Condvar, Mutex};
22

3-
use jobserver::HelperThread;
3+
use rustc_data_structures::jobserver::{self, HelperThread};
44
use rustc_errors::DiagCtxtHandle;
5-
use rustc_session::Session;
65

76
// FIXME don't panic when a worker thread panics
87

@@ -14,14 +13,13 @@ pub(super) struct ConcurrencyLimiter {
1413
}
1514

1615
impl ConcurrencyLimiter {
17-
pub(super) fn new(sess: &Session, pending_jobs: usize) -> Self {
16+
pub(super) fn new(pending_jobs: usize) -> Self {
1817
let state = Arc::new(Mutex::new(state::ConcurrencyLimiterState::new(pending_jobs)));
1918
let available_token_condvar = Arc::new(Condvar::new());
2019

2120
let state_helper = state.clone();
2221
let available_token_condvar_helper = available_token_condvar.clone();
23-
let helper_thread = sess
24-
.jobserver
22+
let helper_thread = jobserver::client()
2523
.clone()
2624
.into_helper_thread(move |token| {
2725
let mut state = state_helper.lock().unwrap();
@@ -113,7 +111,7 @@ impl Drop for ConcurrencyLimiterToken {
113111
}
114112

115113
mod state {
116-
use jobserver::Acquired;
114+
use rustc_data_structures::jobserver::Acquired;
117115

118116
#[derive(Debug)]
119117
pub(super) struct ConcurrencyLimiterState {

compiler/rustc_codegen_cranelift/src/driver/aot.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ pub(crate) fn run_aot(
679679
metadata_module: None,
680680
metadata,
681681
crate_info: CrateInfo::new(tcx, target_cpu),
682-
concurrency_limiter: ConcurrencyLimiter::new(tcx.sess, 0),
682+
concurrency_limiter: ConcurrencyLimiter::new(0),
683683
});
684684
};
685685

@@ -711,7 +711,7 @@ pub(crate) fn run_aot(
711711
CguReuse::PreLto | CguReuse::PostLto => false,
712712
});
713713

714-
let concurrency_limiter = IntoDynSyncSend(ConcurrencyLimiter::new(tcx.sess, todo_cgus.len()));
714+
let concurrency_limiter = IntoDynSyncSend(ConcurrencyLimiter::new(todo_cgus.len()));
715715

716716
let modules = tcx.sess.time("codegen mono items", || {
717717
let mut modules: Vec<_> = par_map(todo_cgus, |(_, cgu)| {

compiler/rustc_codegen_cranelift/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#![warn(unused_lifetimes)]
1313
// tidy-alphabetical-end
1414

15-
extern crate jobserver;
1615
#[macro_use]
1716
extern crate rustc_middle;
1817
extern crate rustc_abi;

compiler/rustc_codegen_ssa/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ bitflags = "2.4.1"
1111
cc = "1.1.23"
1212
either = "1.5.0"
1313
itertools = "0.12"
14-
jobserver = "0.1.28"
1514
pathdiff = "0.2.0"
1615
regex = "1.4"
1716
rustc_abi = { path = "../rustc_abi" }

compiler/rustc_codegen_ssa/src/back/write.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ use std::sync::Arc;
66
use std::sync::mpsc::{Receiver, Sender, channel};
77
use std::{fs, io, mem, str, thread};
88

9-
use jobserver::{Acquired, Client};
109
use rustc_ast::attr;
1110
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
11+
use rustc_data_structures::jobserver::{self, Acquired};
1212
use rustc_data_structures::memmap::Mmap;
1313
use rustc_data_structures::profiling::{SelfProfilerRef, VerboseTimingGuard};
1414
use rustc_errors::emitter::Emitter;
@@ -456,7 +456,6 @@ pub(crate) fn start_async_codegen<B: ExtraBackendMethods>(
456456
metadata_module: Option<CompiledModule>,
457457
) -> OngoingCodegen<B> {
458458
let (coordinator_send, coordinator_receive) = channel();
459-
let sess = tcx.sess;
460459

461460
let crate_attrs = tcx.hir().attrs(rustc_hir::CRATE_HIR_ID);
462461
let no_builtins = attr::contains_name(crate_attrs, sym::no_builtins);
@@ -477,7 +476,6 @@ pub(crate) fn start_async_codegen<B: ExtraBackendMethods>(
477476
shared_emitter,
478477
codegen_worker_send,
479478
coordinator_receive,
480-
sess.jobserver.clone(),
481479
Arc::new(regular_config),
482480
Arc::new(metadata_config),
483481
Arc::new(allocator_config),
@@ -1093,7 +1091,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
10931091
shared_emitter: SharedEmitter,
10941092
codegen_worker_send: Sender<CguMessage>,
10951093
coordinator_receive: Receiver<Box<dyn Any + Send>>,
1096-
jobserver: Client,
10971094
regular_config: Arc<ModuleConfig>,
10981095
metadata_config: Arc<ModuleConfig>,
10991096
allocator_config: Arc<ModuleConfig>,
@@ -1145,7 +1142,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
11451142
// get tokens on `coordinator_receive` which will
11461143
// get managed in the main loop below.
11471144
let coordinator_send2 = coordinator_send.clone();
1148-
let helper = jobserver
1145+
let helper = jobserver::client()
11491146
.into_helper_thread(move |token| {
11501147
drop(coordinator_send2.send(Box::new(Message::Token::<B>(token))));
11511148
})

compiler/rustc_data_structures/src/jobserver.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::sync::{LazyLock, OnceLock};
22

3-
pub use jobserver_crate::Client;
3+
pub use jobserver_crate::{Acquired, Client, HelperThread};
44
use jobserver_crate::{FromEnv, FromEnvErrorKind};
55

66
// We can only call `from_env_ext` once per process

compiler/rustc_session/src/session.rs

-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use std::{env, fmt, io};
88

99
use rustc_data_structures::flock;
1010
use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
11-
use rustc_data_structures::jobserver::{self, Client};
1211
use rustc_data_structures::profiling::{SelfProfiler, SelfProfilerRef};
1312
use rustc_data_structures::sync::{
1413
DynSend, DynSync, Lock, Lrc, MappedReadGuard, ReadGuard, RwLock,
@@ -154,10 +153,6 @@ pub struct Session {
154153
/// Data about code being compiled, gathered during compilation.
155154
pub code_stats: CodeStats,
156155

157-
/// Loaded up early on in the initialization of this `Session` to avoid
158-
/// false positives about a job server in our environment.
159-
pub jobserver: Client,
160-
161156
/// This only ever stores a `LintStore` but we don't want a dependency on that type here.
162157
pub lint_store: Option<Lrc<dyn LintStoreMarker>>,
163158

@@ -1072,7 +1067,6 @@ pub fn build_session(
10721067
incr_comp_session: RwLock::new(IncrCompSession::NotInitialized),
10731068
prof,
10741069
code_stats: Default::default(),
1075-
jobserver: jobserver::client(),
10761070
lint_store: None,
10771071
registered_lints: false,
10781072
driver_lint_caps,

0 commit comments

Comments
 (0)