Skip to content

Commit f406198

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 4ea610e commit f406198

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
@@ -41,7 +41,6 @@ use syntax::attr;
4141

4242
use std::any::Any;
4343
use std::fs;
44-
use std::io;
4544
use std::mem;
4645
use std::path::{Path, PathBuf};
4746
use std::str;
@@ -905,7 +904,7 @@ fn execute_lto_work_item<B: ExtraBackendMethods>(
905904
}
906905

907906
pub enum Message<B: WriteBackendMethods> {
908-
Token(io::Result<Acquired>),
907+
Token(Acquired),
909908
NeedsFatLTO {
910909
result: FatLTOInput<B>,
911910
worker_id: usize,
@@ -999,6 +998,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
999998
let coordinator_send2 = coordinator_send.clone();
1000999
let helper = jobserver
10011000
.into_helper_thread(move |token| {
1001+
let token = token.expect("acquired token successfully");
10021002
drop(coordinator_send2.send(Box::new(Message::Token::<B>(token))));
10031003
})
10041004
.expect("failed to spawn helper thread");
@@ -1390,25 +1390,15 @@ fn start_executing_work<B: ExtraBackendMethods>(
13901390
// this to spawn a new unit of work, or it may get dropped
13911391
// immediately if we have no more work to spawn.
13921392
Message::Token(token) => {
1393-
match token {
1394-
Ok(token) => {
1395-
tokens.push(token);
1396-
1397-
if main_thread_worker_state == MainThreadWorkerState::LLVMing {
1398-
// If the main thread token is used for LLVM work
1399-
// at the moment, we turn that thread into a regular
1400-
// LLVM worker thread, so the main thread is free
1401-
// to react to codegen demand.
1402-
main_thread_worker_state = MainThreadWorkerState::Idle;
1403-
running += 1;
1404-
}
1405-
}
1406-
Err(e) => {
1407-
let msg = &format!("failed to acquire jobserver token: {}", e);
1408-
shared_emitter.fatal(msg);
1409-
// Exit the coordinator thread
1410-
panic!("{}", msg)
1411-
}
1393+
tokens.push(token);
1394+
1395+
if main_thread_worker_state == MainThreadWorkerState::LLVMing {
1396+
// If the main thread token is used for LLVM work
1397+
// at the moment, we turn that thread into a regular
1398+
// LLVM worker thread, so the main thread is free
1399+
// to react to codegen demand.
1400+
main_thread_worker_state = MainThreadWorkerState::Idle;
1401+
running += 1;
14121402
}
14131403
}
14141404

0 commit comments

Comments
 (0)