Skip to content

Commit 8d9ba0e

Browse files
Send raw tokens through the LLVM coordination channel
Sending an io::Result of the acquired token is a bit odd as the receiver can't productively do anything on error (other than panic) and largely if we've encountered an error when reading from the pipe it's not something that we expect to happen (i.e., likely indicates something has gone wrong outside our control or is a rustc programmer error) so a panic is appropriate.
1 parent aa37823 commit 8d9ba0e

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

src/librustc_codegen_ssa/back/write.rs

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ use rustc_jobserver::{Client, Acquired};
3434

3535
use std::any::Any;
3636
use std::fs;
37-
use std::io;
3837
use std::mem;
3938
use std::path::{Path, PathBuf};
4039
use std::str;
@@ -890,7 +889,7 @@ fn execute_lto_work_item<B: ExtraBackendMethods>(
890889
}
891890

892891
pub enum Message<B: WriteBackendMethods> {
893-
Token(io::Result<Acquired>),
892+
Token(Acquired),
894893
NeedsFatLTO {
895894
result: FatLTOInput<B>,
896895
worker_id: usize,
@@ -982,6 +981,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
982981
// get managed in the main loop below.
983982
let coordinator_send2 = coordinator_send.clone();
984983
let helper = jobserver.into_helper_thread(move |token| {
984+
let token = token.expect("acquired token successfully");
985985
drop(coordinator_send2.send(Box::new(Message::Token::<B>(token))));
986986
}).expect("failed to spawn helper thread");
987987

@@ -1374,25 +1374,15 @@ fn start_executing_work<B: ExtraBackendMethods>(
13741374
// this to spawn a new unit of work, or it may get dropped
13751375
// immediately if we have no more work to spawn.
13761376
Message::Token(token) => {
1377-
match token {
1378-
Ok(token) => {
1379-
tokens.push(token);
1380-
1381-
if main_thread_worker_state == MainThreadWorkerState::LLVMing {
1382-
// If the main thread token is used for LLVM work
1383-
// at the moment, we turn that thread into a regular
1384-
// LLVM worker thread, so the main thread is free
1385-
// to react to codegen demand.
1386-
main_thread_worker_state = MainThreadWorkerState::Idle;
1387-
running += 1;
1388-
}
1389-
}
1390-
Err(e) => {
1391-
let msg = &format!("failed to acquire jobserver token: {}", e);
1392-
shared_emitter.fatal(msg);
1393-
// Exit the coordinator thread
1394-
panic!("{}", msg)
1395-
}
1377+
tokens.push(token);
1378+
1379+
if main_thread_worker_state == MainThreadWorkerState::LLVMing {
1380+
// If the main thread token is used for LLVM work
1381+
// at the moment, we turn that thread into a regular
1382+
// LLVM worker thread, so the main thread is free
1383+
// to react to codegen demand.
1384+
main_thread_worker_state = MainThreadWorkerState::Idle;
1385+
running += 1;
13961386
}
13971387
}
13981388

0 commit comments

Comments
 (0)