Haskell LLVM绑定链接器错误 [英] Haskell LLVM Binding linker error

查看:164
本文介绍了Haskell LLVM绑定链接器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

update:



我现在在LLVM 2.9上,在ghc 7.0.4上运行并绑定了llvm-0.9.1.2,而我只是其中的一个错误:

  /home/jfmiller28/.cabal/lib/llvm-0.9.1.2/ghc-7.0.4/libHSllvm- 0.9.1.2.a(Scalar.o):函数`sm03_info':
(.text + 0x24d):对LLVMAddLoopIndexSplitPass'的未定义引用
collect2:ld返回1退出状态






对于haskell LLVM绑定,我收到以下链接器错误: p>

 链接llvm ... 
/home/jfmiller28/.cabal/lib/llvm-0.9.0.1/ghc-6.12 .3 / libHSllvm-0.9.0.1.a(Core.o):在函数`scZD_info'中:
(.text + 0xf589):未定义对`LLVMBuildFNeg'的引用
/home/jfmiller28/.cabal /lib/llvm-0.9.0.1/ghc-6.12.3/libHSllvm-0.9.0.1.a(Core.o):函数`sdRn_info':
(.text + 0x114c5):对LLVMAddDestination的未定义引用'
/home/jfmiller28/.cabal/lib/llvm-0.9.0.1/ghc-6.12.3/libHSllvm-0.9.0.1.a(Core.o):在函数`sdSb_info'中:
(.text + 0x11545):未定义的对`LLVMAddGlobalInAddressSpace'的引用
...
collect2:ld返回1退出状态
ghc --make hello.hs





 模块Main其中

导入Data.Word

导入LLVM.Core
导入LLVM。 ExecutionEngine

bldGreet :: CodeGenModule(Function(IO()))
bldGreet = withStringNulHello,JIT! (\greetz-> do
puts< - newNamedFunction ExternalLinkageputs:: TFunction(Ptr Word8 - > IO Word32)
func< - createFunction ExternalLinkage $ do
tmp < - getElementPtr0 greetz(0 :: Word32,())
_< - 调用puts tmp - 抛弃返回值
ret()
返回func)

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

return()



LLVM通过apt-get安装到/ usr / lib / llvm中。

解决方案

原始问题的答案是我有一个LLVM的版本太旧了。写这篇文章的时候你需要LLVM 2.8或更新的版本。

下一个问题与llvm绑定中的过期行有关。这次的解决方案是从git仓库编译llvm绑定。纠正我,如果我错了,但我需要一些新的公众0.9.1.2释放 cabal install llvm 拉下来。



请参阅 https://github.com/bos/llvm/issues/2 https://github.com/bos/llvm/pull/3


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.

解决方案

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

这篇关于Haskell LLVM绑定链接器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆