diff options
| author | Axel Cohen <axel.cohen@eshard.com> | 2021-11-24 11:43:40 +0100 |
|---|---|---|
| committer | Axel Cohen <axel.cohen@eshard.com> | 2021-12-13 10:41:43 +0100 |
| commit | c4f29fa0ed738b52e7d8ef372c2d09300755dfef (patch) | |
| tree | 70209b622c152b56c44064255abe29d85a46c2cd /compiler/rustc_codegen_llvm/src/llvm_util.rs | |
| parent | 97cf461b8f4c0ed0de8fdc1c441b904ddb8b3194 (diff) | |
| download | rust-c4f29fa0ed738b52e7d8ef372c2d09300755dfef.tar.gz rust-c4f29fa0ed738b52e7d8ef372c2d09300755dfef.zip | |
Use the existing llvm-plugins option for both legacy and new pm registration
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/llvm_util.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/llvm_util.rs | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 79a261244d3..af53b35d815 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -119,14 +119,20 @@ 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 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); + let use_new_llvm_pm_plugin_register = + sess.opts.debugging_opts.new_llvm_pass_manager.unwrap_or(false); + + // Use the legacy pm registration if the new_llvm_pass_manager option isn't explicitly enabled + if use_new_llvm_pm_plugin_register { + // Register LLVM plugins by loading them into the compiler process. + for plugin in &sess.opts.debugging_opts.llvm_plugins { + 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(); |
