Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

binary generation from LLVM

Tags:

c++

llvm

How does one generate executable binaries from the c++ side of LLVM?

I'm currently writing a toy compiler, and I'm not quite sure how to do the final step of creating an executable from the IR.

The only solution I currently see is to write out the bitcode and then call llc using system or the like. Is there a way to do this from the c++ interface instead?

This seems like it would be a common question, but I can't find anything on it.

like image 991
cobbal Avatar asked Dec 28 '11 03:12

cobbal


1 Answers

LLVM does not ship the linker necessary to perform this task. It can only write out as assembler and then invoke the system linker to deal with it. You can see the source code of llvm-ld to see how it's done.

like image 144
Puppy Avatar answered Sep 23 '22 22:09

Puppy