TheDan64 / inkwell

It's a New Kind of Wrapper for Exposing LLVM (Safely)
https://thedan64.github.io/inkwell/
Apache License 2.0
2.38k stars 229 forks source link

Support for `llvm::orc2::LLJit` #476

Open JCBurnside opened 9 months ago

JCBurnside commented 9 months ago

Is your feature request related to a problem? Please describe. The current ExecutionEngine is using an older engine that has issues with global mappings.

Describe the solution you'd like I would like a jit engine using LLJIT. the needed c-api functions are anything in llvm_sys::orc2::lljit

Describe possible drawbacks to your solution might be more difficult to call functions in an idiomatic way.

Describe alternatives you've considered using the old system and using llvm_sys directly.

Additional context small sample of how to crate an LLJIT instances https://gist.github.com/JCBurnside/e93d6b95d1caa3746b7fe72073094cc2 sample of using LLJIT (line 95 is the part I am having issues translating) https://github.com/llvm/llvm-project/blob/main/llvm/examples/HowToUseLLJIT/HowToUseLLJIT.cpp

JCBurnside commented 9 months ago

turns out it's just a transmute to get the returned address into a usable function. also updated the gist with a fix for a double free. LLVMOrcCreateLLJIT takes ownership of the builder.