meldo
meldo

Reputation: 301

How to compile *.hs to llvm ir (*.ll) using GHC compiler?

I tried

ghc -fllvm -pgmlo -pgmlc -ddump-llvm src.hs

and

ghc -fllvm -pgmlo -pgmlc -keep-llvm-files src.hs

opt and llc (3.5.1 version) are in PATH

But I haven't found any llvm ir after I executed commands.

Upvotes: 4

Views: 1515

Answers (2)

Reid Barton
Reid Barton

Reputation: 14999

Probably GHC didn't recompile your program since the program hadn't changed since you last ran GHC. This seems likely since -pgmlo -pgmlc means "use -pgmlc as the LLVM optimizer" which is not going to work. Just run

ghc -fllvm -keep-llvm-files -fforce-recomp src.hs

(or manually modify src.hs and recompile it).

Upvotes: 8

user1010424
user1010424

Reputation:

1) -pgm[letter] - use this command if you only compiling into C code(in your case if you compiling without -fllvm flag)

2) -keep-llvm-files - find .ll files in current directory, otherwise try to find them in /tmp directory(i saw this bug somewhere)

3) ghc works only with llvm 3.5

Upvotes: 2

Related Questions