Skip to content

LLVM plugin support in Rust #419

Closed
Closed
@wsmoses

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    T-compilerAdd this label so rfcbot knows to poll the compiler teammajor-changeA proposal to make a major change to rustc

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions