File tree 2 files changed +6
-16
lines changed
compiler/rustc_codegen_llvm/src
2 files changed +6
-16
lines changed Original file line number Diff line number Diff line change @@ -1743,7 +1743,7 @@ extern "C" {
1743
1743
1744
1744
pub fn LLVMDisposeMessage ( message : * mut c_char ) ;
1745
1745
1746
- pub fn LLVMStartMultithreaded ( ) -> Bool ;
1746
+ pub fn LLVMIsMultithreaded ( ) -> Bool ;
1747
1747
1748
1748
/// Returns a string describing the last error caused by an LLVMRust* call.
1749
1749
pub fn LLVMRustGetLastError ( ) -> * const c_char ;
Original file line number Diff line number Diff line change @@ -17,35 +17,25 @@ use std::path::Path;
17
17
use std:: ptr;
18
18
use std:: slice;
19
19
use std:: str;
20
- use std:: sync:: atomic:: { AtomicBool , Ordering } ;
21
20
use std:: sync:: Once ;
22
21
23
- static POISONED : AtomicBool = AtomicBool :: new ( false ) ;
24
22
static INIT : Once = Once :: new ( ) ;
25
23
26
24
pub ( crate ) fn init ( sess : & Session ) {
27
25
unsafe {
28
26
// Before we touch LLVM, make sure that multithreading is enabled.
27
+ if llvm:: LLVMIsMultithreaded ( ) != 1 {
28
+ bug ! ( "LLVM compiled without support for threads" ) ;
29
+ }
29
30
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
-
36
31
configure_llvm ( sess) ;
37
32
} ) ;
38
-
39
- if POISONED . load ( Ordering :: SeqCst ) {
40
- bug ! ( "couldn't enable multi-threaded LLVM" ) ;
41
- }
42
33
}
43
34
}
44
35
45
36
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" ) ;
49
39
}
50
40
}
51
41
You can’t perform that action at this time.
0 commit comments