File tree Expand file tree Collapse file tree 2 files changed +6
-16
lines changed
compiler/rustc_codegen_llvm/src Expand file tree Collapse file tree 2 files changed +6
-16
lines changed Original file line number Diff line number Diff line change @@ -1743,7 +1743,7 @@ extern "C" {
17431743
17441744 pub fn LLVMDisposeMessage ( message : * mut c_char ) ;
17451745
1746- pub fn LLVMStartMultithreaded ( ) -> Bool ;
1746+ pub fn LLVMIsMultithreaded ( ) -> Bool ;
17471747
17481748 /// Returns a string describing the last error caused by an LLVMRust* call.
17491749 pub fn LLVMRustGetLastError ( ) -> * const c_char ;
Original file line number Diff line number Diff line change @@ -17,35 +17,25 @@ use std::path::Path;
1717use std:: ptr;
1818use std:: slice;
1919use std:: str;
20- use std:: sync:: atomic:: { AtomicBool , Ordering } ;
2120use std:: sync:: Once ;
2221
23- static POISONED : AtomicBool = AtomicBool :: new ( false ) ;
2422static INIT : Once = Once :: new ( ) ;
2523
2624pub ( 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
4536fn 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
You can’t perform that action at this time.
0 commit comments