This commit is contained in:
bjorn3 2020-09-29 15:28:48 +02:00
parent 17a54ad62e
commit b8b5a824a6

View File

@ -11,21 +11,23 @@ use crate::prelude::*;
pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! {
use cranelift_simplejit::{SimpleJITBackend, SimpleJITBuilder}; use cranelift_simplejit::{SimpleJITBackend, SimpleJITBuilder};
// Rustc opens us without the RTLD_GLOBAL flag, so __cg_clif_global_atomic_mutex will not be #[cfg(unix)]
// exported. We fix this by opening ourself again as global. unsafe {
// FIXME remove once atomic_shim is gone // When not using our custom driver rustc will open us without the RTLD_GLOBAL flag, so
let cg_dylib = std::ffi::OsString::from( // __cg_clif_global_atomic_mutex will not be exported. We fix this by opening ourself again
&tcx.sess // as global.
.opts // FIXME remove once atomic_shim is gone
.debugging_opts
.codegen_backend let mut dl_info: libc::Dl_info = std::mem::zeroed();
.as_ref() assert_ne!(
.unwrap(), libc::dladdr(run_jit as *const libc::c_void, &mut dl_info),
); 0
std::mem::forget( );
libloading::os::unix::Library::open(Some(cg_dylib), libc::RTLD_NOW | libc::RTLD_GLOBAL) assert_ne!(
.unwrap(), libc::dlopen(dl_info.dli_fname, libc::RTLD_NOW | libc::RTLD_GLOBAL),
); std::ptr::null_mut(),
);
}
let imported_symbols = load_imported_symbols_for_jit(tcx); let imported_symbols = load_imported_symbols_for_jit(tcx);