mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 22:41:50 +00:00
1b3a5f29dd
Allow loading LLVM plugins with both legacy and new pass manager Opening a draft PR to get feedback and start discussion on this feature. There is already a codegen option `passes` which allow giving a list of LLVM pass names, however we currently can't use a LLVM pass plugin (as described here : https://llvm.org/docs/WritingAnLLVMPass.html), the only available passes are the LLVM built-in ones. The proposed modification would be to add another codegen option `pass-plugins`, which can be set with a list of paths to shared library files. These libraries are loaded using the LLVM function `PassPlugin::Load`, which calls the expected symbol `lvmGetPassPluginInfo`, and register the pipeline parsing and optimization callbacks. An example usage with a single plugin and 3 passes would look like this in the `.cargo/config`: ```toml rustflags = [ "-C", "pass-plugins=/tmp/libLLVMPassPlugin", "-C", "passes=pass1 pass2 pass3", ] ``` This would give the same functionality as the opt LLVM tool directly integrated in rust build system. Additionally, we can also not specify the `passes` option, and use a plugin which inserts passes in the optimization pipeline, as one could do using clang. |
||
---|---|---|
.. | ||
src | ||
Cargo.toml | ||
README.md |
Please read the rustc-dev-guide chapter on Backend Agnostic Codegen.