I have created a toy language that generates IR code and writes that code to a binary file with WriteBitcodeToFile (the C API). The result is a my-file.bc file.
In this file I have defined a main() function that takes no arguments and returns an int64 (should I change return type to byte maybe). How do I make this .bc file an executable. I'm running Linux.
Fredrik
It is possible to execute a bc-file with lli command. However that doesn't create a stand alone executable product. Show activity on this post. There's always the option of using llc to compile to assembly from which you can generate an executable.
Overview. What is commonly known as the LLVM bitcode file format (also, sometimes anachronistically known as bytecode) is actually two things: a bitstream container format and an encoding of LLVM IR into the container format.
Only the C and C++ languages are needed so there's no need to build the other languages for LLVM's purposes. See below for specific version info. Only needed if you want to run the automated test suite in the llvm/test directory.
You can generate an object file with llc and then use GCC to create an executable:
llc -filetype=obj my-file.bc
gcc my-file.o
./a.out
You can read more about llc on http://llvm.org/docs/CommandGuide/llc.html.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With