Is Inkwell complete enough?

Currently I am writing front-end for a small statically typed language having standard constructs like variable declaration, assignments, if-elif-else, for-while loop, function, closure, struct, lambda type, interface, generics etc. I am moving towards wiring up the backend which is really confusing. I want to use LLVM IR but not sure is there a good support for LLVM API bindings in rust.
Wanted to know is llvm-sys crate or Inkwell crates are complete enough to implement above constructs ?
Or is there any other alternative better than this?

I would recommend Inkwell, it's been around for quite a while (I think I first used it 2 or 3 years ago?) and the crate covers all the LLVM API that you need for writing a language backend. Reading through Publish inkwell to crates.io · Issue #154 · TheDan64/inkwell · GitHub, it seems like they haven't published to crates.io because the way they manage LLVM versioning is incompatible with the way cargo expects versions and feature flags to be used, not because the crate is unstable.

Directly using the llvm-sys crate will require you to write a lot of unsafe code which you will almost certainly mess up unless you've used the LLVM C API from other languages. I wouldn't recommend it unless you've got some obscure requirements.

4 Likes

thanks @Michael-F-Bryan for the suggestion. I will dig deeper into the usage of the crate.