How can I create an executable from LLVM ir?
Thanks to the comments of @Michael Petch and @Ross Ridge I finally understood why this does not work and found a working alternative.
The cause of the problem
There are different kinds of assembler language, which vary in syntax and are not directly compatible. As nasm is expecting another assembly language than llc is producing, it obviously does not work, which explains the long list of errors.
How to do it instead
Considering that llc has AT&T assembler as output, which was created for the GNU toolchain, the most obvious step would be to use GCC to create the executable after building the code.s
file with llc.
To install GCC I downloaded MinGW, installed it and called
mingw-get install gcc
now I can access GCC which can be used to create code.exe
by calling
gcc code.s -o code.exe
gcc [filename] -o [name of the created executable]
As this solution is probably more complicated than it needs to be I would be glad to see some alternatives/ improvements.