Skip to content

Commit 56694b0

Browse files
committed
Auto merge of #89808 - tmiasko:llvm-multithreaded, r=nagisa
Cleanup LLVM multi-threading checks The support for runtime multi-threading was removed from LLVM. Calls to `LLVMStartMultithreaded` became no-ops equivalent to checking if LLVM was compiled with support for threads http://reviews.llvm.org/D4216.
2 parents 28d0e75 + aa3bf01 commit 56694b0

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1770,7 +1770,7 @@ extern "C" {
17701770

17711771
pub fn LLVMDisposeMessage(message: *mut c_char);
17721772

1773-
pub fn LLVMStartMultithreaded() -> Bool;
1773+
pub fn LLVMIsMultithreaded() -> Bool;
17741774

17751775
/// Returns a string describing the last error caused by an LLVMRust* call.
17761776
pub fn LLVMRustGetLastError() -> *const c_char;

compiler/rustc_codegen_llvm/src/llvm_util.rs

+5-15
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,25 @@ use std::path::Path;
1717
use std::ptr;
1818
use std::slice;
1919
use std::str;
20-
use std::sync::atomic::{AtomicBool, Ordering};
2120
use std::sync::Once;
2221

23-
static POISONED: AtomicBool = AtomicBool::new(false);
2422
static INIT: Once = Once::new();
2523

2624
pub(crate) fn init(sess: &Session) {
2725
unsafe {
2826
// Before we touch LLVM, make sure that multithreading is enabled.
27+
if llvm::LLVMIsMultithreaded() != 1 {
28+
bug!("LLVM compiled without support for threads");
29+
}
2930
INIT.call_once(|| {
30-
if llvm::LLVMStartMultithreaded() != 1 {
31-
// use an extra bool to make sure that all future usage of LLVM
32-
// cannot proceed despite the Once not running more than once.
33-
POISONED.store(true, Ordering::SeqCst);
34-
}
35-
3631
configure_llvm(sess);
3732
});
38-
39-
if POISONED.load(Ordering::SeqCst) {
40-
bug!("couldn't enable multi-threaded LLVM");
41-
}
4233
}
4334
}
4435

4536
fn require_inited() {
46-
INIT.call_once(|| bug!("llvm is not initialized"));
47-
if POISONED.load(Ordering::SeqCst) {
48-
bug!("couldn't enable multi-threaded LLVM");
37+
if !INIT.is_completed() {
38+
bug!("LLVM is not initialized");
4939
}
5040
}
5141

0 commit comments

Comments
 (0)