0
votes

Recently I was trying to install llvm-general-3.5.1.0 package.. for about a week. Basically I am getting this error: link. My situation is identical. Windows 10, ghc 7.10.2, cabal 1.22.4.0. I installed llvm 3.5.2 from sources with cmake and everything went fine. In llvm/lib directory I have *.lib files (eg. LLVMAnalysis.lib).

But somehow cabal can't see those libraries and gives this frustrating error:

Configuring llvm-general-3.5.1.0... setup.exe: Missing dependencies on foreign libraries: * Missing C libraries: LLVMLTO, LLVMObjCARCOpts, LLVMLinker, LLVMipo, LLVMVectorize, LLVMBitWriter, LLVMCppBackendCodeGen, LLVMCppBackendInfo, LLVMTableGen, LLVMDebugInfo, LLVMOption, LLVMX86Disassembler, LLVMX86AsmParser, LLVMX86CodeGen, LLVMSelectionDAG, LLVMAsmPrinter, LLVMX86Desc, LLVMX86Info, LLVMX86AsmPrinter, LLVMX86Utils, LLVMJIT, LLVMIRReader, LLVMAsmParser, LLVMLineEditor, LLVMMCAnalysis, LLVMMCDisassembler, LLVMInstrumentation, LLVMInterpreter, LLVMCodeGen, LLVMScalarOpts, LLVMInstCombine, LLVMTransformUtils, LLVMipa, LLVMAnalysis, LLVMProfileData, LLVMMCJIT, LLVMTarget, LLVMRuntimeDyld, LLVMObject, LLVMMCParser, LLVMBitReader, LLVMExecutionEngine, LLVMMC, LLVMCore, LLVMSupport This problem can usually be solved by installing the system packages that provide these libraries (you may need the "-dev" versions). If the libraries are already installed but in a non-standard location then you can use the flags --extra-include-dirs= and --extra-lib-dirs= to specify where they are.

I really want to use this package on my Windows, but nothing seems to work (I tried everything like --extra-lib-dirs and compiled also with MinGW and VS - the same problem).

I can't accept the fact that it won't install. I mean, there must be some way to fix Setup.hs from this cabal package or something. Does anyone have an idea what can be wrong with cabal in this case and how can I try to workaround this? I don't know how exactly cabal works, maybe someone with this knowledge will have an idea? Or maybe there is a way to do this without cabal?

1
Did you read the entire issue? It's a cabal bug.Zeta
@Zeta, I didn't think it is considered a bug officially. There is no single reply in that thread. Are you saying that nothing can be done until this bug is fixed by cabal authors, and I can't install this package?xan
Since you're able to reproduce the error, a reply on the thread would raise some awareness. That being said, I don't know how many cabal devs use Windows 10. I'm currently on Linux, but I'll try to reproduce it on Win8 later.Zeta
Thank you @Zeta, that would be awesome.xan
Sorry, I had several problems with LLVM yesterday and wasn't able to get things working. Apparently, LLVM doesn't like my MinGW configuration.Zeta

1 Answers

6
votes

Ok, i've managed to build it and, i think, found the root of the issue.

First, steps to build:

  1. Get the MinGW. My installation of MinGW has gcc 4.8.

  2. Get 32-bit MinGHC.

  3. Compile LLVM 3.5 with MinGW's gcc and install it somewhere.

  4. Copy contents of MinGW installation directory into MinGHC Install Dir\ghc-7.10.2\mingw, replacing conflict files.

  5. In the command line set your PATH so it has haskell toolset from MinGHC (i recommend using switch .bat scripts) and llvm-config.exe.

  6. Get the llvm-general package source either using cabal fetch or downloading via browser from hackage.

  7. Replace cc-options: -std=c++11 line of llvm-general.cabal with cc-options: -std=gnu++11.

  8. Finally, cabal configure and cabal build should work.

I have been changing my build environment many times, so if this doesn't work for you let me know, i probably forgot something.


Now let's go into details.

What we thought is a bug of cabal is not, actually. The problem is that both stack and MinGHC (and Haskell Platform, i guess) use quite old gcc - 4.6. This gcc has even two defects:

  • It doesn't support -std=c++11 and LLVM 3.5 can't be built using it. As a consequence, this gcc can't be used by ghc when compiling llvm-general, because it can't parse LLVM headers properly.
  • Even if it could, its linker can't link against LLVM libs compiled by MinGW using gcc 4.8. This is why cabal was telling you it couldn't find LLVM libs. I've hacked Setup.hs so that it wouldn't look for these libs, but pass -lLLVMSomething to linker via -pgml ghc option. This lead to clear error message:

    ld.exe: ignoring libLLVMSupport.a ...
    ld.exe: can't find -lLLVMSupport
    

So, the cabal was actually finding these libs, but was dropping them because they couldn't be linked to.

Ideally, the solution would be to update mingw distribution used by stack/MinGHC. But as a workaround you can just replace old gcc with new one.

Finally, -std=gnu++11 is used because current MinGW release is affected by this bug, which prevents compilation of c++ bits of the package. Whew, that was a long way.