Haskell LLVM 绑定链接器错误
更新:
我现在在 LLVM 2.9 上,绑定 llvm-0.9.1.2 在 ghc 7.0.4 上运行,我只遇到以下错误之一:
/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
我收到 haskell LLVM 绑定的以下链接器错误:
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
对于 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 使用 apt-get 安装到 /usr/lib/llvm。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最初问题的答案是我的 LLVM 版本太旧了。在撰写本文时,您需要 LLVM 2.8 或更高版本。
下一个问题与 llvm 绑定中过时的行有关。这次的解决方案是从 git 存储库编译 llvm 绑定。如果我错了,请纠正我,但我需要
cabal install llvm
下拉的公共 0.9.1.2 版本中的更新版本。请参阅 https://github.com/bos/llvm/issues/2 和 https://github.com/bos/llvm/pull/3
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
也许这个补丁可以让它与 LLVM 2.9 一起运行,并绑定 llvm-0.9.1.2 在 ghc 7.0.4 上运行
maybe this patch can make it run with LLVM 2.9 with binding llvm-0.9.1.2 running on ghc 7.0.4