]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_back/dynamic_lib.rs
Auto merge of #39021 - alexcrichton:try-debug-travis, r=brson
[rust.git] / src / librustc_back / dynamic_lib.rs
index 2f86262afbe22604acb97fc2d730be2e19a5324a..38e60060925e6f59c4b5df25317b59526e10cbde 100644 (file)
@@ -189,12 +189,16 @@ unsafe fn open_internal() -> *mut u8 {
     pub fn check_for_errors_in<T, F>(f: F) -> Result<T, String> where
         F: FnOnce() -> T,
     {
-        use std::sync::StaticMutex;
-        static LOCK: StaticMutex = StaticMutex::new();
+        use std::sync::{Mutex, Once, ONCE_INIT};
+        static INIT: Once = ONCE_INIT;
+        static mut LOCK: *mut Mutex<()> = 0 as *mut _;
         unsafe {
+            INIT.call_once(|| {
+                LOCK = Box::into_raw(Box::new(Mutex::new(())));
+            });
             // dlerror isn't thread safe, so we need to lock around this entire
             // sequence
-            let _guard = LOCK.lock();
+            let _guard = (*LOCK).lock();
             let _old_error = libc::dlerror();
 
             let result = f();