0

My question is kinda similar to this one: How to generate an executable from an llvm::Module?. But as the answeres there are from 2012, and I'm not sure if anything has changed.

So I've got an LLVM::Module and want to produce an executable from it. I know that I can build an object file from it and invoke a linker on that .o file to get an executable, but I don't want the I/O overhead of reading and writing a intermediate .o file.

I'm wondering if there is an API in the LLVM project that I can use to generate a exec. from a module. Is the llvm::Linker class maybe a good point to start?

Luke
  • 365
  • 3
  • 10
  • 1
    It can be done, but really, the overhead of reading/writing a single file is negligible. The Linker class operates on IR rather than native code so it won't be right for you. You might want to start either with lld/gold/mold or with the [ORCJIT](https://llvm.org/docs/ORCv2.html) and write code that creates an executable from the in-memory native code that ORCJIT creates. The emacs undump utility might contain code you can use. Frankly, it sounds like a lot of work to save a thousandth of a second. – arnt May 24 '22 at 14:09
  • Thanks a lot for pointing me to orcjit. Although I decided, that (as you said) the additional word is just not worth it, I'll probably still check out orcjit an see what it has to offer. – Luke May 24 '22 at 20:25

0 Answers0