replace dynamic library module with libloading
This commit is contained in:
parent
0fb1c371d4
commit
923f939791
15 changed files with 91 additions and 313 deletions
|
@ -1,9 +1,9 @@
|
|||
use crate::back::write::create_informational_target_machine;
|
||||
use crate::{llvm, llvm_util};
|
||||
use libc::c_int;
|
||||
use libloading::Library;
|
||||
use rustc_codegen_ssa::target_features::supported_target_features;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_metadata::dynamic_lib::DynamicLibrary;
|
||||
use rustc_middle::bug;
|
||||
use rustc_session::config::PrintRequest;
|
||||
use rustc_session::Session;
|
||||
|
@ -13,7 +13,6 @@ use std::ffi::{CStr, CString};
|
|||
use tracing::debug;
|
||||
|
||||
use std::mem;
|
||||
use std::path::Path;
|
||||
use std::ptr;
|
||||
use std::slice;
|
||||
use std::str;
|
||||
|
@ -120,14 +119,14 @@ unsafe fn configure_llvm(sess: &Session) {
|
|||
|
||||
llvm::LLVMInitializePasses();
|
||||
|
||||
// Register LLVM plugins by loading them into the compiler process.
|
||||
for plugin in &sess.opts.debugging_opts.llvm_plugins {
|
||||
let path = Path::new(plugin);
|
||||
let res = DynamicLibrary::open(path);
|
||||
match res {
|
||||
Ok(_) => debug!("LLVM plugin loaded succesfully {} ({})", path.display(), plugin),
|
||||
Err(e) => bug!("couldn't load plugin: {}", e),
|
||||
}
|
||||
mem::forget(res);
|
||||
let lib = Library::new(plugin).unwrap_or_else(|e| bug!("couldn't load plugin: {}", e));
|
||||
debug!("LLVM plugin loaded successfully {:?} ({})", lib, plugin);
|
||||
|
||||
// Intentionally leak the dynamic library. We can't ever unload it
|
||||
// since the library can make things that will live arbitrarily long.
|
||||
mem::forget(lib);
|
||||
}
|
||||
|
||||
rustc_llvm::initialize_available_targets();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue