TheDan64 / inkwell

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

Simple Example To Link Executable Using LLD #144

Open Pebaz opened 4 years ago

Pebaz commented 4 years ago

How do I link a simple hello-world LLVM module into an executable using LLD? Per this documentation for LLVM, this is possible from code but I am not sure it is implemented in Inkwell.

TheDan64 commented 4 years ago

Sorry that I missed this question. LLD is a linker separate from LLVM so your question is a bit outside the scope of inkwell.

But you'd want to build some sort of output object file which you can then pass to LLD. I'm not sure if Inkwell has great support for building object files yet, but it might be possible.

tomaka commented 3 years ago

I was trying to figure out how to write an object file and I found this issue. In case someone else is in the same situation: the TargetMachine::write_to_file or TargetMachine::write_to_memory_buffer functions are likely what you're looking for.