File tree 1 file changed +6
-4
lines changed
1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -16,23 +16,25 @@ use rustc::session::config::PrintRequest;
16
16
use libc:: { c_int, c_char} ;
17
17
use std:: ffi:: CString ;
18
18
19
+ use std:: sync:: atomic:: { AtomicBool , Ordering } ;
20
+ use std:: sync:: Once ;
21
+
19
22
pub fn init ( sess : & Session ) {
20
23
unsafe {
21
24
// Before we touch LLVM, make sure that multithreading is enabled.
22
- use std :: sync :: Once ;
25
+ static POISONED : AtomicBool = AtomicBool :: new ( false ) ;
23
26
static INIT : Once = Once :: new ( ) ;
24
- static mut POISONED : bool = false ;
25
27
INIT . call_once ( || {
26
28
if llvm:: LLVMStartMultithreaded ( ) != 1 {
27
29
// use an extra bool to make sure that all future usage of LLVM
28
30
// cannot proceed despite the Once not running more than once.
29
- POISONED = true ;
31
+ POISONED . store ( true , Ordering :: SeqCst ) ;
30
32
}
31
33
32
34
configure_llvm ( sess) ;
33
35
} ) ;
34
36
35
- if POISONED {
37
+ if POISONED . load ( Ordering :: SeqCst ) {
36
38
bug ! ( "couldn't enable multi-threaded LLVM" ) ;
37
39
}
38
40
}
You can’t perform that action at this time.
0 commit comments