Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The program 'llvm-config' version ==9.0.* is required but it could not be found. #391

Open
wujilingfeng opened this issue Mar 29, 2022 · 4 comments

Comments

@wujilingfeng
Copy link

wujilingfeng commented Mar 29, 2022

Screenshot from 2022-03-29 17-29-41

How to solve this error?
I have installed llvm-6.0 by the command sudo apt install llvm-6.0.I didn't install clang.

@tmcdonell
Copy link
Member

Clang is not required, but the llvm-9 package is. You should be able to get it via https://apt.llvm.org

Note that it should be 9.0. I think there was also a 9.1 or so, but the configure script won't like that.

@vthemelis
Copy link

Hi, I'm having the same issue. I do have llvm-9 installed but the setup script tries to use version 12.

Exact message:

llvm-hs        > setup: The program 'llvm-config' version ==9.0.* is required but the version
llvm-hs        > found at /opt/homebrew/opt/llvm@12/bin/llvm-config is version 12.0.1

Is there a parameter I can pass somewhere to make ghc look at the llvm 9 install location instead?

@RyanBrewer317
Copy link

add /path/to/llvm9/bin to the front of your PATH environment variable so that ghc checks it before that other bin directory

@Memorytaco
Copy link

To use llvm-hs against with a specific release of llvm, you need to provide both llvm-config which is a tool used to provide link flags and LD_LIBRARY_PATH which pointed to llvm library directory.

Let's say we need to use llvm-hs-9, follow these steps:

1. verify llvm-config has exact matched version with llvm-hs

in our case which requires major version number being 9

$ llvm-config --version
9.0.1

2. check whether installed llvm provides dynamic library:

if it does provide dynamic library, then you should receive following outputs:

$ llvm-config --link-shared --libs
-lLLVM-9

or not:

$ llvm-config --link-shared --libs
llvm-config: error: libLLVM-9.so is missing

pass correct cabal flags shared-llvm using stack.yaml or as command line options using stack, or use correct distribution of llvm.

3. setup correct LD_LIBRARY_PATH pointed to llvm

let's say you have installed multiple slots of llvm, like llvm-9, llvm-12 and llvm-15 and they have a common release directory scheme as /usr/lib/llvm/{version}/lib64. LD_LIBRARY_PATH should be pointed to one of these. Entries should be separated with :.

e.g.

$ export LD_LIBRARY_PATH="/usr/lib/llvm/9/lib64:$LD_LIBRARY_PATH"

LD_LIBRARY_PATH is used to guide linker to right object files. llvm-config is always bound to bundled llvm version but default library environment sometimes doesn't point to correct place, thus situations that you are using llvm-9 and linker is trying to link against llvm-15's so file happens, which will cause mysterious error.

4. stack build!

You can always ignore the third step if you have only one version matched host llvm installed and come back later when something going wrong.

toggle off link-shared flag (set it to false) will cause mysterious error message when building your project against llvm-hs. some message like ghc: panic! (the 'impossible' happened) may appear. Weird.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants