-
Notifications
You must be signed in to change notification settings - Fork 556
Description
I'm currently working on a project which uses rustc internals to analyse a crate so I can then generate FFI bindings. Kinda like cbindgen, except where they focus on static linking at compile time or dynamically when your program gets loaded into memory, I'm trying to load a dynamic library at runtime using dlopen (*nix) and LoadLibrary (windows).
Seeing as this is a guide on how rustc works under the hood, would it be worth adding a chapter that mentions:
- how people can use
rustcinternals as a library, - how you ask
rustc_driverto run some code after a particular phase, and - how you can extract information from an analysed crate?
My code is on GitLab so people in a similar situation or writing this chapter can use that as a reference.
This is slightly off topic, but I'm really impressed with how easy the compiler internals (especially the HIR and Session) are to work with once you understand how they're designed! It was initially a bit confusing because there are loads of data structures (unfortunately, not many have doc-comments) and lots of complexity, but after an hour or two of jumping around the crate docs I was able to be quite proficient in finding the information I want.