Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLVM plugin support in Rust #419

Closed
1 of 3 tasks
wsmoses opened this issue Mar 17, 2021 · 2 comments
Closed
1 of 3 tasks

LLVM plugin support in Rust #419

wsmoses opened this issue Mar 17, 2021 · 2 comments
Labels
major-change A proposal to make a major change to rustc T-compiler Add this label so rfcbot knows to poll the compiler team

Comments

@wsmoses
Copy link

wsmoses commented Mar 17, 2021

Proposal

It is desirable for a number of projects (automatic differentiation via Enzyme for RustML, formal verification, binary checking, annobin, and others) to be able to load LLVM plugins.

There's been a couple of discussions on the topic (https://internals.rust-lang.org/t/should-rustc-support-custom-llvm-plugin/13807) (rust-lang/rust#82734) that appear favorable to potential inclusion, with questions about how this should be safely integrated.

Integration is fairly simple and could be done by simply including the relevant header file

#include "llvm/Support/PluginLoader.h"

This would allow the traditional LLVM plugin loader flags -load=/path/to/plugin.so to succeed, shown below for Enzyme as an example:

-C llvm-args="-load=`pwd`/../Enzyme/enzyme/buildrs/Enzyme/LLVMEnzyme-11.so" -C passes="enzyme"

Alternatively, we could make a custom unstable flag that explicitly loads plugins in a similar manner:

This requires duplicating a little bit of the dlopen functionality for loading plugins in LLVM, except now in Rust (wsmoses/rust@0149bc4).

The one thing of note is that LLVM plugins most likely will require access to LLVM functions that may not otherwise be available in Rust. Practically, building Rust with a dynamically linked LLVM solves this. There may be other options here as well.

Mentors or Reviewers

Unsure who would be relevant to review (new to rust community. I'd be happy to mentor and also happy to push this myself.

Process

The main points of the Major Change Process are as follows:

  • File an issue describing the proposal.
  • A compiler team member or contributor who is knowledgeable in the area can second by writing @rustbot second.
    • Finding a "second" suffices for internal changes. If however, you are proposing a new public-facing feature, such as a -C flag, then full team check-off is required.
    • Compiler team members can initiate a check-off via @rfcbot fcp merge on either the MCP or the PR.
  • Once an MCP is seconded, the Final Comment Period begins. If no objections are raised after 10 days, the MCP is considered approved.

You can read more about Major Change Proposals on forge.

Comments

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

@wsmoses wsmoses added T-compiler Add this label so rfcbot knows to poll the compiler team major-change A proposal to make a major change to rustc labels Mar 17, 2021
@rustbot
Copy link
Collaborator

rustbot commented Mar 17, 2021

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

cc @rust-lang/compiler @rust-lang/compiler-contributors

@rustbot rustbot added the to-announce Announce this issue on triage meeting label Mar 17, 2021
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Mar 18, 2021
@nagisa
Copy link
Member

nagisa commented Jul 8, 2021

Closing as rust-lang/rust#86267 has landed as an alternative implementation.

@nagisa nagisa closed this as completed Jul 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major-change A proposal to make a major change to rustc T-compiler Add this label so rfcbot knows to poll the compiler team
Projects
None yet
Development

No branches or pull requests

4 participants