about summary refs log tree commit diff
diff options
context:
space:
mode:
authorManuel Drehwald <git@manuel.drehwald.info>2021-06-13 18:23:01 +0200
committerManuel Drehwald <git@manuel.drehwald.info>2021-06-13 18:23:01 +0200
commit4dbdcd1c5cc5f2e61495af95d81b1fc588506aa4 (patch)
tree858b1736a86d1c1ba817d982b2edf133749e07e3
parentfb3ea63d9b4c3e9bb90d4250b870faaffb9c8fd2 (diff)
downloadrust-4dbdcd1c5cc5f2e61495af95d81b1fc588506aa4.tar.gz
rust-4dbdcd1c5cc5f2e61495af95d81b1fc588506aa4.zip
allow loading of llvm plugins on nightly
-rw-r--r--compiler/rustc_codegen_llvm/src/llvm_util.rs10
-rw-r--r--compiler/rustc_interface/src/tests.rs1
-rw-r--r--compiler/rustc_session/src/options.rs2
3 files changed, 13 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs
index 0dd3d2ae15b..a15edaf5138 100644
--- a/compiler/rustc_codegen_llvm/src/llvm_util.rs
+++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs
@@ -129,6 +129,16 @@ unsafe fn configure_llvm(sess: &Session) {
 
     llvm::LLVMInitializePasses();
 
+    for plugin in &sess.opts.debugging_opts.llvm_plugins {
+        let path = CString::new(plugin.as_bytes()).unwrap();
+        let res = libc::dlopen(path.as_ptr(), libc::RTLD_LAZY | libc::RTLD_GLOBAL);
+        if res.is_null() {
+            println!("{}", CStr::from_ptr(libc::dlerror()).to_string_lossy().into_owned());
+        }
+        println!("{:p}", res);
+        println!("{}", plugin);
+    }
+
     rustc_llvm::initialize_available_targets();
 
     llvm::LLVMRustSetLLVMOptions(llvm_args.len() as c_int, llvm_args.as_ptr());
diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs
index 5d8a6084f2e..89adb349190 100644
--- a/compiler/rustc_interface/src/tests.rs
+++ b/compiler/rustc_interface/src/tests.rs
@@ -707,6 +707,7 @@ fn test_debugging_options_tracking_hash() {
     tracked!(instrument_coverage, Some(InstrumentCoverage::All));
     tracked!(instrument_mcount, true);
     tracked!(link_only, true);
+    tracked!(llvm_plugins, vec![String::from("plugin_name")]);
     tracked!(merge_functions, Some(MergeFunctions::Disabled));
     tracked!(mir_emit_retag, true);
     tracked!(mir_opt_level, Some(4));
diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs
index 1946bfd78cc..ca0a4ecd81c 100644
--- a/compiler/rustc_session/src/options.rs
+++ b/compiler/rustc_session/src/options.rs
@@ -1122,6 +1122,8 @@ options! {
         "link native libraries in the linker invocation (default: yes)"),
     link_only: bool = (false, parse_bool, [TRACKED],
         "link the `.rlink` file generated by `-Z no-link` (default: no)"),
+    llvm_plugins: Vec<String> = (Vec::new(), parse_list, [TRACKED],
+        "a list LLVM plugins to enable (space separated)"),
     llvm_time_trace: bool = (false, parse_bool, [UNTRACKED],
         "generate JSON tracing data file from LLVM data (default: no)"),
     ls: bool = (false, parse_bool, [UNTRACKED],