5

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.

1
  • 6
    IIRC GHC is (or at least used to be) pretty touchy about the version of LLVM used, so you may need to install 3.7. The problem is that LLVM has a pretty frequent release cycle with breaking features. Keeping GHC working with these versions is a pain. See this page for more details. Commented Dec 11, 2016 at 5:47

1 Answer 1

8

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.