scruffaluff
scruffaluff

Reputation: 365

Compiling haskell with llvm

I'm starting to learn Haskell and I found out that ghc can compile using LLVM with the -fllvm flag. Whenever I use the flag, I get the error message:

<no location info>: error:
Warning: Couldn't figure out LLVM version!
         Make sure you have installed LLVM 3.7
ghc: could not execute: opt

However, I have opt in my /usr/local/Cellar/llvm/3.9.0/ folder. I'm on a Mac OS X and I've installed the full LLVM with brew install llvm but error persists. Is this a genuine version problem where I have to unistall LLVM and reinstall its 3.7 version? Or is ghc having trouble finding opt and there is some kind of search path I can modify to fix the problem? Thanks for the help and have a great day.

Upvotes: 5

Views: 6161

Answers (1)

Grandpa
Grandpa

Reputation: 3233

The GHC documentation says that it's compatible with llvm-2.8+, but as you've discovered, it actually requires llvm-3.7.

The simplest way to get it is:

brew install [email protected]

This installs llvm binaries in your path with a -3.7 suffix, like clang-3.7. GHC will need the unadorned names, which are in a subdirectory:

export PATH=/usr/local/opt/[email protected]/lib/llvm-3.7/bin:$PATH

Upvotes: 8

Related Questions