I want to compile haskell using ghc front-end and llvm back-end.
I have following code in my haskell hello.hs file:
main = putStrLn "Hello World!"
I compile hello.hs with ghc using following command
ghc -fllvm -keep-llvm-files -force-recomp -hello.hs
which generate a hello.ll file along with other files. I then try to compile this .ll file into a .bc file.
llvm-as hello.ll -o hello.bc
and then this .bc file to executable file
llc hello.bc -o hello
which generate an executable file. The problem is when I run this file I found the following error
./hello: line 1: .file: command not found
./hello: line 2: .section: command not found
./hello: line 3: .globl: command not found
./hello: line 4: .align: command not found
./hello: line 5: .type: command not found
./hello: line 6: Main_main2_info:: command not found
./hello: line 8: subq: command not found
./hello: line 9: syntax error near unexpected token `('
./hello: line 9: ` movq
%r13, 112(%rsp)'
and when I use lli on .bc file I get
main function not found in module error
I am running ghc and llvm on docker. I have version 3.4 of llvm and version 7.6.3 of ghc.
A "similar" error occur when I try to to do this on mac. I don't know why I am getting this error.