How to generate llvm-ir code to rlib

Hi all!

I want to compile llvm-ir code(.ll) to .rlib file in compilation of library.

I emit the llvm-ir code during compile time(RUSTFLAGS="--emit=llvm-ir" cargo build) then there are several llvm-ir code including dependency in cargo.toml or library using in project.
Then, i want to analysis in all llvm-ir code related to dependency or library code and compile llvm-ir code to rlib file after the analysis.

However, I have no insight to switch llvm-ir code to rlib file. Is there any solution to generate rlib file?

Have a nice day :slight_smile:

No, that is not possible. Rlibs contain rustc crate metadata, which llvm-ir files don't contain. Maybe you could use the llvm plugin interface instead? I believe you will have to build your own rustc with the option to enable support for this set though.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.