LLVM RUST Library


#1

Hi! I want to write an LLVM pass for RUST that map a variable attribute and something like that. Does rust provide any library with documentation that allows me to write LLVM pass in Rust not in C?


#2

You could use bindgen to create Rust FFI bindings for any random LLVM version. The alternative is writing those bindings by hand, but I don’t recommend that unless you have a couple of weeks to spare.

As an aside: LLVM is written in C++, not C.


#3

llvm-sys are the community maintained straight bindings to LLVM’s C API.


#4

How extensive are those bindings? Enough for codegen from a university-course level compiler? Or are the bindings focused on other things, like calling the optimizer, the backend and so on - instead of codegen?

(In that case, maybe I can make codegen happen on my end, and invoke the optimizer and backend from the bindings :thinking::slightly_smiling_face:)


#5

Regardless of Rust, IMHO LLVM’s C API is awfully incomplete. For any real work sooner or later you’ll end up needing to use the C++ API.