]> git.lizzy.rs Git - rust.git/commitdiff
allow loading of llvm plugins on nightly
authorManuel Drehwald <git@manuel.drehwald.info>
Sun, 13 Jun 2021 16:23:01 +0000 (18:23 +0200)
committerManuel Drehwald <git@manuel.drehwald.info>
Sun, 13 Jun 2021 16:23:01 +0000 (18:23 +0200)
compiler/rustc_codegen_llvm/src/llvm_util.rs
compiler/rustc_interface/src/tests.rs
compiler/rustc_session/src/options.rs

index 0dd3d2ae15bcae74a3c9ca974e59d021c0f75d14..a15edaf513858cfe6839ec9b51585602e3b6bd6f 100644 (file)
@@ -129,6 +129,16 @@ fn llvm_arg_to_arg_name(full_arg: &str) -> &str {
 
     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());
index 5d8a6084f2e0b486809c8705314e423618cbeab3..89adb349190579199de873a44d2dc4d95b0aeeda 100644 (file)
@@ -707,6 +707,7 @@ macro_rules! tracked {
     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));
index 1946bfd78cc38ebab2b757616d79c7dacfe1be18..ca0a4ecd81c0f02cfa4d9e19cebbea0c2391777b 100644 (file)
@@ -1122,6 +1122,8 @@ mod parse {
         "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],