I have a Rust crate A
that depends on another Rust crate B
; both of them are STD-clean (i.e. both use #![no_std]
) and there are no other dependencies. I would like to get my hands on the LLVM IR of all the code needed to statically link it together with lld
.
To get the LLVM IR from just A
, I am currently passing --emit=llvm-ir
to cargo rustc
. This results in target/debug/deps/A-someKindOfHash.ll
which I can then consume -- in my case, by using Clang to link it with some C code that calls (non-mangled) Rust functions.
However, that .ll
file doesn't contain all transitive dependencies, so as soon as A
actually starts using functions from B
, this breaks down.
How do I tell Cargo to create LLVM IR from all dependencies and put them somewhere under target/
?