Skip to content

Commit 33fefe5

Browse files
Move jobserver initialization before thread pool creation
1 parent 63f833a commit 33fefe5

File tree

4 files changed

+19
-21
lines changed

4 files changed

+19
-21
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4066,7 +4066,6 @@ dependencies = [
40664066
"rustc_feature",
40674067
"rustc_fs_util",
40684068
"rustc_index",
4069-
"rustc_jobserver",
40704069
"rustc_span",
40714070
"rustc_target",
40724071
"serialize",

src/librustc_interface/interface.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,22 @@ pub fn run_compiler_in_existing_thread_pool<R>(
206206

207207
pub fn run_compiler<R: Send>(mut config: Config, f: impl FnOnce(&Compiler) -> R + Send) -> R {
208208
let stderr = config.stderr.take();
209+
210+
if config.opts.debugging_opts.jobserver_token_requests {
211+
if let config::ErrorOutputType::Json { .. } = config.opts.error_format {
212+
if stderr.is_some() {
213+
panic!("Non-default output not supported with -Zjobserver-token-requests");
214+
}
215+
} else {
216+
panic!(
217+
"-Zjobserver-token-requests can only be specified if using \
218+
JSON error output type"
219+
);
220+
}
221+
}
222+
223+
rustc_jobserver::initialize(config.opts.debugging_opts.jobserver_token_requests);
224+
209225
util::spawn_thread_pool(
210226
config.opts.edition,
211227
config.opts.debugging_opts.threads,
@@ -215,6 +231,9 @@ pub fn run_compiler<R: Send>(mut config: Config, f: impl FnOnce(&Compiler) -> R
215231
}
216232

217233
pub fn default_thread_pool<R: Send>(edition: edition::Edition, f: impl FnOnce() -> R + Send) -> R {
234+
// FIXME: allow for smart jobserver
235+
rustc_jobserver::initialize(false);
236+
218237
// the 1 here is duplicating code in config.opts.debugging_opts.threads
219238
// which also defaults to 1; it ultimately doesn't matter as the default
220239
// isn't threaded, and just ignores this parameter

src/librustc_session/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,3 @@ rustc_index = { path = "../librustc_index" }
2020
rustc_fs_util = { path = "../librustc_fs_util" }
2121
num_cpus = "1.0"
2222
syntax = { path = "../libsyntax" }
23-
rustc_jobserver = { path = "../librustc_jobserver" }

src/librustc_session/session.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ use rustc_span::{MultiSpan, Span};
3030

3131
use rustc_data_structures::flock;
3232
use rustc_data_structures::profiling::{SelfProfiler, SelfProfilerRef};
33-
use rustc_jobserver::{self as jobserver, Client};
3433
use rustc_target::spec::{PanicStrategy, RelroLevel, Target, TargetTriple};
3534

3635
use std::cell::{self, RefCell};
@@ -1032,24 +1031,6 @@ fn build_session_(
10321031
sopts.debugging_opts.time_passes,
10331032
);
10341033

1035-
if sopts.debugging_opts.jobserver_token_requests {
1036-
if let config::ErrorOutputType::Json { .. } = sopts.error_format {
1037-
if is_diagnostic_output_raw {
1038-
panic!("Raw output format not supported with -Zjobserver-token-requests");
1039-
}
1040-
} else {
1041-
parse_sess
1042-
.span_diagnostic
1043-
.fatal(
1044-
"-Zjobserver-token-requests can only be specified if \
1045-
using JSON error output type",
1046-
)
1047-
.raise();
1048-
}
1049-
}
1050-
1051-
rustc_jobserver::initialize(sopts.debugging_opts.jobserver_token_requests);
1052-
10531034
let sess = Session {
10541035
target: target_cfg,
10551036
host,

0 commit comments

Comments
 (0)