Cargo -> LLVM IR bitcode as library


#1

I haven’t seen anything on this recently. There was this cargo-build build project, looks like it hasn’t been updated (hasn’t needed to be updated?) in a year.

What I need is the ability to create the Apple bitcode library, this I believe lines up with the --emit llvm-bc option from the cargo-build project. This looks like it does the proper thing of producing the IR as I want, but it’s not exposed as an option to Cargo, and I also don’t see a documented way to do it in Cargo.toml. This leads me to believe that I either need to add the option to Cargo as a PR, or build a custom set of Makefiles to use rustc directly.

It looks like there have been a few issues on this option for Cargo, https://github.com/rust-lang/cargo/issues/1204 , but it sounds like they’ve all been rejected. Does anyone know of a currently better option here to produce LLVM-IR or more specifically a bitcode based library?


#2

Hey, I’m not sure if you figured this out or not (since it’s been almost a month), but I think you can do this through cargo rustc, which lets you specify pass arguments directly to the compiler. In the case of outputting a library as a LLVM bitcode file, the command would be cargo rustc --lib -- --emit=llvm-bc. I have no idea about whether the code generated by Rust’s port would be compatible with other LLVM code though.


#3

Thanks for this pointer. The option definitely works, but I haven’t had a chance to see about constructing a proper bit code library that the Apple tools accept. I’m probably doing something wrong, when I have more time I’ll figure it out.