I am trying to add my llvm pass into Rustc. Rustc has one compiling option -C passes=val
where we could add extra LLVM passes to run. However, as my try, this option can only accept the pass when the pass code is placed inside the LLVM code tree, but I want to add my pass out-of-tree into Rustc.
When I add my pass via this option:
RUSTFLAGS="-C passes=my-pass" cargo build
Compiler reports errors:
error: failed to run LLVM passes: unknown pass name 'my-pass'
Then I try to load my pass via -C llvm-args=-fpass-plugin=/opt/new-pass/mypass.so -C passes=my-pass
in the clang
way. It reports: rustc -Cllvm-args="..." with: Unknown command line argument '-fpass-plugin=/opt/new-pass/mypass.so'
. Also tried to replace -fpass-plugin
with other options like -load
and -load-pass-plugin
, but they still cannot be recognized by rustc.
How could I add my custom pass into Rustc?