Skip to content

Commit 4dbdcd1

Browse files
committed
allow loading of llvm plugins on nightly
1 parent fb3ea63 commit 4dbdcd1

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

+10
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ unsafe fn configure_llvm(sess: &Session) {
129129

130130
llvm::LLVMInitializePasses();
131131

132+
for plugin in &sess.opts.debugging_opts.llvm_plugins {
133+
let path = CString::new(plugin.as_bytes()).unwrap();
134+
let res = libc::dlopen(path.as_ptr(), libc::RTLD_LAZY | libc::RTLD_GLOBAL);
135+
if res.is_null() {
136+
println!("{}", CStr::from_ptr(libc::dlerror()).to_string_lossy().into_owned());
137+
}
138+
println!("{:p}", res);
139+
println!("{}", plugin);
140+
}
141+
132142
rustc_llvm::initialize_available_targets();
133143

134144
llvm::LLVMRustSetLLVMOptions(llvm_args.len() as c_int, llvm_args.as_ptr());

compiler/rustc_interface/src/tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,7 @@ fn test_debugging_options_tracking_hash() {
707707
tracked!(instrument_coverage, Some(InstrumentCoverage::All));
708708
tracked!(instrument_mcount, true);
709709
tracked!(link_only, true);
710+
tracked!(llvm_plugins, vec![String::from("plugin_name")]);
710711
tracked!(merge_functions, Some(MergeFunctions::Disabled));
711712
tracked!(mir_emit_retag, true);
712713
tracked!(mir_opt_level, Some(4));

compiler/rustc_session/src/options.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,8 @@ options! {
11221122
"link native libraries in the linker invocation (default: yes)"),
11231123
link_only: bool = (false, parse_bool, [TRACKED],
11241124
"link the `.rlink` file generated by `-Z no-link` (default: no)"),
1125+
llvm_plugins: Vec<String> = (Vec::new(), parse_list, [TRACKED],
1126+
"a list LLVM plugins to enable (space separated)"),
11251127
llvm_time_trace: bool = (false, parse_bool, [UNTRACKED],
11261128
"generate JSON tracing data file from LLVM data (default: no)"),
11271129
ls: bool = (false, parse_bool, [UNTRACKED],

0 commit comments

Comments
 (0)