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.
This commit is contained in:
parent
ffdf18d144
commit
aa3bf01889
2 changed files with 6 additions and 16 deletions
|
@ -1743,7 +1743,7 @@ extern "C" {
|
||||||
|
|
||||||
pub fn LLVMDisposeMessage(message: *mut c_char);
|
pub fn LLVMDisposeMessage(message: *mut c_char);
|
||||||
|
|
||||||
pub fn LLVMStartMultithreaded() -> Bool;
|
pub fn LLVMIsMultithreaded() -> Bool;
|
||||||
|
|
||||||
/// Returns a string describing the last error caused by an LLVMRust* call.
|
/// Returns a string describing the last error caused by an LLVMRust* call.
|
||||||
pub fn LLVMRustGetLastError() -> *const c_char;
|
pub fn LLVMRustGetLastError() -> *const c_char;
|
||||||
|
|
|
@ -17,35 +17,25 @@ use std::path::Path;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
use std::str;
|
use std::str;
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
|
||||||
use std::sync::Once;
|
use std::sync::Once;
|
||||||
|
|
||||||
static POISONED: AtomicBool = AtomicBool::new(false);
|
|
||||||
static INIT: Once = Once::new();
|
static INIT: Once = Once::new();
|
||||||
|
|
||||||
pub(crate) fn init(sess: &Session) {
|
pub(crate) fn init(sess: &Session) {
|
||||||
unsafe {
|
unsafe {
|
||||||
// Before we touch LLVM, make sure that multithreading is enabled.
|
// Before we touch LLVM, make sure that multithreading is enabled.
|
||||||
INIT.call_once(|| {
|
if llvm::LLVMIsMultithreaded() != 1 {
|
||||||
if llvm::LLVMStartMultithreaded() != 1 {
|
bug!("LLVM compiled without support for threads");
|
||||||
// use an extra bool to make sure that all future usage of LLVM
|
|
||||||
// cannot proceed despite the Once not running more than once.
|
|
||||||
POISONED.store(true, Ordering::SeqCst);
|
|
||||||
}
|
}
|
||||||
|
INIT.call_once(|| {
|
||||||
configure_llvm(sess);
|
configure_llvm(sess);
|
||||||
});
|
});
|
||||||
|
|
||||||
if POISONED.load(Ordering::SeqCst) {
|
|
||||||
bug!("couldn't enable multi-threaded LLVM");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn require_inited() {
|
fn require_inited() {
|
||||||
INIT.call_once(|| bug!("llvm is not initialized"));
|
if !INIT.is_completed() {
|
||||||
if POISONED.load(Ordering::SeqCst) {
|
bug!("LLVM is not initialized");
|
||||||
bug!("couldn't enable multi-threaded LLVM");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue