Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to emit LLVM-IR from Cargo

How can I get cargo to emit LLVM-IR instead of a binary for my project? I know that you can use the --emit=llvm-ir flag in rustc, but I've read some Github issues that show it's impossible to pass arbitrary compiler flags to cargo.

Is there any way I can get cargo to emit LLVM-IR directly?

like image 270
Ameo Avatar asked Aug 17 '16 19:08

Ameo


People also ask

Does rust use LLVM?

rustc uses LLVM to generate code. LLVM can generate very fast code, but it comes at a cost. LLVM is a very big system. In fact, LLVM code makes up the majority of the Rust codebase.


1 Answers

There is cargo rustc to pass arbitrary compiler flags through Cargo to rustc. So I think:

cargo rustc -- --emit=llvm-ir

is what you want!

like image 124
Jacob Avatar answered Sep 29 '22 18:09

Jacob