Cabal and llvm issue

I am using MacBook and I have installed LLVM@13 using brew install. I have changed .zshrc file also.
export PATH=/opt/homebrew/opt/llvm/bin:/opt/homebrew/bin:$PATH
export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"
export CPPFLAGS="-I/opt/homebrew/opt/llvm/include"

I still get the following error when I run cabal build. Am I still missing something.
: error:
Warning: Couldn’t figure out LLVM version!
Make sure you have installed LLVM between [9 and 13)
ghc: could not execute: opt

Can you run opt --version manually in the terminal?

I get the following
Homebrew LLVM version 13.0.0

The error message says >= 9 && < 13. Not the round parentheses on the right.

Does homebrew really inject their name in there? :man_facepalming: Maybe that’s tripping ghc up as well. The version warning is usually not a hard failure.

I can compile Haskell programs with GHC 8.10.7 and Homebrew LLVM 13.0 on my MacBook Pro 2018 without errors or warnings.

GHC is working fine, it is the issue with cabal. When I try to build with cabal, i get this error.

Compiling with cabal and llvm also works for me. Specifically, creating a new project, adding ghc-options: -fllvm and then running cabal build works for me.

Thank you. ghc-options: -fllvm worked.
I just added this a part of common shared-properties stanza

Interesting… I didn’t know that it is possible to get that error if you did not use -fllvm, I thought that was a requirement for using LLVM with GHC.

For real?? So much for computers adapting to humans so that we didn’t have to adapt to them… I thought it was a typo of some sort.

Anyway, thanks for translating this. Now I’ve learned that Haskell tools will do something like this to me next time I see an error, and hopefully solve my problem sooner

That is actually fairly common mathematical notation. But I agree it’s not that common outside of maths :frowning:

It should be fairly easy to make a patch to ghc to improve the readability. If someone is interested in this, I’m happy to assist.

GHC will default to -fllvm if there is no native code Gen for the target. (AArch64-darwin) only had a NCG from 9.2 onwards. 8.10 will be -fllvm by default.

1 Like

Thanks.

In case it helps others, adding ghc-options: -fllvm to my haskell.cabal did help with my initial issue running cabal v2-run, but did not help with calls such as cabal install ...

To fix that I had to use brew install llvm@12 rather than brew install llvm and update the $PATH as suggested.

Hopefully llvm version 13.x will be supported in the future

1 Like