FFI for KLLVM#4
Conversation
These strings are malloc'd, and it's on the caller to free them.
|
Can we add a github action that just at least builds the project and calls the fuzzer on a few inputs? just to get the test harness in place and make sure that it's working. |
| pub fn init() { | ||
| unsafe { | ||
| ffi::kllvm_init(); | ||
| } | ||
| } | ||
| pub fn free_all_memory() { | ||
| unsafe { | ||
| ffi::kllvm_free_all_memory(); | ||
| } | ||
| } |
There was a problem hiding this comment.
I wonder if there's a way to safely wrap these based on Rust's ownership / borrowing model. So maybe a struct that calls kllvm_init on instantiation, kllvm_free_all_memory on drop, and owns all the KLLVM objects so that they are only valid in-between.
There was a problem hiding this comment.
I'm not so sure about this. What if the struct is instantiated twice? One goes out of scope, calling kllvm::free_all_memory while the other one persists? How will using the owned Pattern's and Block's work, what does that interface look like?
There are enough design hurdles here that would take time and effort to go through and there's no guarantee that on the other side we would have something any more airtight than a possible missed call to kllvm::init (the call to kllvm::free_all_memory matters less imo, because modern OSes these days clean everything up when the process dies anyway).
Looking at this snippet I realized that there are no docstrings giving context for these functions, I'll write something up.
72d6e86 to
7940449
Compare
Done. |
Creates the
kframework_fficrate with an interface into kllvm's data structures and execution.Notable files:
kframework_ffi/src/kllvm.rs: Has a docstring explaining how to use the FFIexamples/fuzzer/README.md: Explains how to run an example fuzzer for an Imp program