0

update:

I'm now on LLVM 2.9 with binding llvm-0.9.1.2 running on ghc 7.0.4 and I'm down to just one of these errors:

/home/jfmiller28/.cabal/lib/llvm-0.9.1.2/ghc-7.0.4/libHSllvm-0.9.1.2.a(Scalar.o): In function `sm03_info':
(.text+0x24d): undefined reference to `LLVMAddLoopIndexSplitPass'
collect2: ld returned 1 exit status

I am getting the following linker error for the haskell LLVM bindings:

Linking llvm ...
/home/jfmiller28/.cabal/lib/llvm-0.9.0.1/ghc-6.12.3/libHSllvm-0.9.0.1.a(Core.o): In function `scZD_info':
(.text+0xf589): undefined reference to `LLVMBuildFNeg'
/home/jfmiller28/.cabal/lib/llvm-0.9.0.1/ghc-6.12.3/libHSllvm-0.9.0.1.a(Core.o): In function `sdRn_info':
(.text+0x114c5): undefined reference to `LLVMAddDestination'
/home/jfmiller28/.cabal/lib/llvm-0.9.0.1/ghc-6.12.3/libHSllvm-0.9.0.1.a(Core.o): In function `sdSb_info':
(.text+0x11545): undefined reference to `LLVMAddGlobalInAddressSpace'
...
collect2: ld returned 1 exit status

For ghc --make hello.hs:

module Main where

import Data.Word

import LLVM.Core
import LLVM.ExecutionEngine

bldGreet :: CodeGenModule (Function (IO ()))
bldGreet = withStringNul "Hello, JIT!" (\greetz -> do
    puts <- newNamedFunction ExternalLinkage "puts" :: TFunction (Ptr Word8 -> IO Word32)
    func <- createFunction ExternalLinkage $ do
      tmp <- getElementPtr0 greetz (0::Word32, ())
      _ <- call puts tmp -- Throw away return value.
      ret ()
    return func)

main :: IO ()
main = do
    initializeNativeTarget
    greet <- simpleFunction bldGreet
    -- greet

    return ()

LLVM was installed with apt-get to /usr/lib/llvm.

2
  • 1
    Are the LLVM headers installed? E.g. /usr/include/llvm/*? What version of LLVM is installed? 2.8? 2.9? Commented Jun 20, 2011 at 1:18
  • headers are installed at that location. LLVM version 2.6.0-ubunbtu1. I think I will try 2.9 compiled form source. Sense I seem to be a few versions behind a very rapidly evolving technology. Commented Jun 20, 2011 at 3:12

2 Answers 2

2

The answer to the original problem was that I have a version of LLVM that was too old. The the time of this writing you need LLVM 2.8 or newer.

The next problem had to do with an outdated line in the llvm bindings. The solution this time was to compile the llvm bindings from the git repository. Correct me if I am wrong, but I needed something newer the the public 0.9.1.2 release that cabal install llvm pulled down.

see https://github.com/bos/llvm/issues/2 and https://github.com/bos/llvm/pull/3

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

1 Comment

Yes, this is correct. LLVM is a swiftly-moving target. I've never been able to build it from Hackage, but the git repo has usually been successful.
1

maybe this patch can make it run with LLVM 2.9 with binding llvm-0.9.1.2 running on ghc 7.0.4

diff -rupN llvm-0.9.1.2/LLVM/FFI/Transforms/Scalar.hsc llvm-0.9.1.2-modified/LLVM/FFI/Transforms/Scalar.hsc
--- llvm-0.9.1.2/LLVM/FFI/Transforms/Scalar.hsc 2011-05-20 02:20:56.000000000 +0800
+++ llvm-0.9.1.2-modified/LLVM/FFI/Transforms/Scalar.hsc    2011-06-20 20:59:27.455828891 +0800
@@ -30,8 +30,6 @@ foreign import ccall unsafe "LLVMAddLICM
     :: PassManagerRef -> IO ()
 foreign import ccall unsafe "LLVMAddLoopDeletionPass" addLoopDeletionPass
     :: PassManagerRef -> IO ()
-foreign import ccall unsafe "LLVMAddLoopIndexSplitPass" addLoopIndexSplitPass
-    :: PassManagerRef -> IO ()
 foreign import ccall unsafe "LLVMAddLoopRotatePass" addLoopRotatePass
     :: PassManagerRef -> IO ()
 foreign import ccall unsafe "LLVMAddLoopUnrollPass" addLoopUnrollPass
diff -rupN llvm-0.9.1.2/llvm.cabal llvm-0.9.1.2-modified/llvm.cabal
--- llvm-0.9.1.2/llvm.cabal 2011-05-20 02:20:56.000000000 +0800
+++ llvm-0.9.1.2-modified/llvm.cabal    2011-06-20 21:03:29.846828930 +0800
@@ -125,7 +125,6 @@ library
       LLVM.Target.MSP430
       LLVM.Target.Mips
       LLVM.Target.Native
-      LLVM.Target.PIC16
       LLVM.Target.PowerPC
       LLVM.Target.Sparc
       LLVM.Target.SystemZ

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.