Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ORC support #449

Closed
bfbachmann opened this issue Nov 14, 2023 · 1 comment
Closed

ORC support #449

bfbachmann opened this issue Nov 14, 2023 · 1 comment

Comments

@bfbachmann
Copy link

bfbachmann commented Nov 14, 2023

Is your feature request related to a problem? Please describe.
Thanks so much for this fantastic library! I apologize if this a silly question as I am somewhat new to Inkwell and LLVM.

From what I've read, it seems like many if not all people using Inkwell or similar projects are compiling their LLVM module and then simply dumping it as LLVM IR or bitcode to a file to later be compiled and linked to an executable using some external compiler like Clang. Either that, or they're just JIT-executing functions from their module directly inside their compiler.

I'm confused as to why nobody seems to be using the intermediate approach - one where you compile and link the LLVM module to an executable immediately (skipping the extra step of dumping IR/bitcode to a file). In the general case, the actual executable is all I want. I don't want to have to write out some intermediate representation and then do a separate compile step to generate an executable. I feel like this should be possible given that it is almost certainly required in order to make JIT execution work. I also know that LLVM has this functionality (I think it's ORC/ORC2), and I see that you've done some experimental work with it, so my questions are:

  1. Is it possible to create an executable for some target machine using Inkwell as it currently exists without using an external compiler/linker?
  2. If not, can I use something like llvm-sys to do this using the module I've created with Inkwell?
  3. Are there any plans to support this kind of thing in Inkwell in the future?

Describe the solution you'd like
I understand there is likely a lot of complexity hidden under the hood with respect to LLVM compilation and linking, but being able to do something like the following would be ideal.

module.create_executable(whatever_is_needed);

Describe possible drawbacks to your solution
I'm sure there is a lot of extra stuff that we'd need to add to Inkwell to make this work.

Describe alternatives you've considered
Use something like llvm-sys or vendor in components from some other toolchain like Clang to do this.

Additional context
Add any other context or screenshots about the feature request here.

@bfbachmann
Copy link
Author

Ah! This is pretty close to what I need: https://github.dev/TheDan64/inkwell/blob/7a09ad8a5f3b1fc416f95b5e1c97d33df0ab3f06/src/execution_engine.rs#L675.

It doesn't do the linking step, but it's definitely creating an object file for the target system, so that answers most of my questions. It seems like Orc is a work-in-progress, so I'll close this issue.

Thanks again for the great library!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant