简体   繁体   中英

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.

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 llvm@3.7

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/llvm@3.7/lib/llvm-3.7/bin:$PATH

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM