File tree 1 file changed +17
-15
lines changed
1 file changed +17
-15
lines changed Original file line number Diff line number Diff line change @@ -11,21 +11,23 @@ use crate::prelude::*;
11
11
pub ( super ) fn run_jit ( tcx : TyCtxt < ' _ > ) -> ! {
12
12
use cranelift_simplejit:: { SimpleJITBackend , SimpleJITBuilder } ;
13
13
14
- // Rustc opens us without the RTLD_GLOBAL flag, so __cg_clif_global_atomic_mutex will not be
15
- // exported. We fix this by opening ourself again as global.
16
- // FIXME remove once atomic_shim is gone
17
- let cg_dylib = std:: ffi:: OsString :: from (
18
- & tcx. sess
19
- . opts
20
- . debugging_opts
21
- . codegen_backend
22
- . as_ref ( )
23
- . unwrap ( ) ,
24
- ) ;
25
- std:: mem:: forget (
26
- libloading:: os:: unix:: Library :: open ( Some ( cg_dylib) , libc:: RTLD_NOW | libc:: RTLD_GLOBAL )
27
- . unwrap ( ) ,
28
- ) ;
14
+ #[ cfg( unix) ]
15
+ unsafe {
16
+ // When not using our custom driver rustc will open us without the RTLD_GLOBAL flag, so
17
+ // __cg_clif_global_atomic_mutex will not be exported. We fix this by opening ourself again
18
+ // as global.
19
+ // FIXME remove once atomic_shim is gone
20
+
21
+ let mut dl_info: libc:: Dl_info = std:: mem:: zeroed ( ) ;
22
+ assert_ne ! (
23
+ libc:: dladdr( run_jit as * const libc:: c_void, & mut dl_info) ,
24
+ 0
25
+ ) ;
26
+ assert_ne ! (
27
+ libc:: dlopen( dl_info. dli_fname, libc:: RTLD_NOW | libc:: RTLD_GLOBAL ) ,
28
+ std:: ptr:: null_mut( ) ,
29
+ ) ;
30
+ }
29
31
30
32
let imported_symbols = load_imported_symbols_for_jit ( tcx) ;
31
33
You can’t perform that action at this time.
0 commit comments