Haskell libclang 绑定中缺少符号:clang_toggleCrashRecovery
libClang 有一个错误,然后我在最后用 cabal 安装它,我得到:
[13 of 13] Compiling Clang ( src/Clang.hs, dist/build/Clang.o )
In file included from ./src/Clang/FFI_stub_ffi.h:6,
from src/Clang/FFI_stub_ffi.c:4:0:
/usr/local/lib/ghc-7.0.3/include/HsFFI.h:29:0:
warning: "__STDC_LIMIT_MACROS" redefined
<command-line>:0:0:
note: this is the location of the previous definition
src/Clang/FFI_stub_ffi.c: In function ‘prim_getCString’:
src/Clang/FFI_stub_ffi.c:33:0:
warning: assignment discards qualifiers from pointer target type
src/Clang/FFI_stub_ffi.c: In function ‘prim_toggleCrashRecovery’:
src/Clang/FFI_stub_ffi.c:2181:0:
warning: implicit declaration of function ‘clang_toggleCrashRecovery’
Registering LibClang-0.0.9...
当我现在想用 ghc 编译一个使用 Clang 的脚本时,我得到:
ghc --make test.hs -L.
[1 of 1] Compiling Main ( test.hs, test.o )
Linking test ...
/home/foo/.cabal/lib/LibClang-0.0.9/ghc-7.0.3/libHSLibClang-0.0.9.a(FFI_stub_ffi.o): In function `prim_toggleCrashRecovery':
FFI_stub_ffi.c:(.text+0x1577): undefined reference to `clang_toggleCrashRecovery'
collect2: ld returned 1 exit status
有人知道该怎么做吗?
have a bug with libClang, then i install it with cabal at the end i get:
[13 of 13] Compiling Clang ( src/Clang.hs, dist/build/Clang.o )
In file included from ./src/Clang/FFI_stub_ffi.h:6,
from src/Clang/FFI_stub_ffi.c:4:0:
/usr/local/lib/ghc-7.0.3/include/HsFFI.h:29:0:
warning: "__STDC_LIMIT_MACROS" redefined
<command-line>:0:0:
note: this is the location of the previous definition
src/Clang/FFI_stub_ffi.c: In function ‘prim_getCString’:
src/Clang/FFI_stub_ffi.c:33:0:
warning: assignment discards qualifiers from pointer target type
src/Clang/FFI_stub_ffi.c: In function ‘prim_toggleCrashRecovery’:
src/Clang/FFI_stub_ffi.c:2181:0:
warning: implicit declaration of function ‘clang_toggleCrashRecovery’
Registering LibClang-0.0.9...
when i now want to compile a script with ghc that uses Clang i get:
ghc --make test.hs -L.
[1 of 1] Compiling Main ( test.hs, test.o )
Linking test ...
/home/foo/.cabal/lib/LibClang-0.0.9/ghc-7.0.3/libHSLibClang-0.0.9.a(FFI_stub_ffi.o): In function `prim_toggleCrashRecovery':
FFI_stub_ffi.c:(.text+0x1577): undefined reference to `clang_toggleCrashRecovery'
collect2: ld returned 1 exit status
someone a idea what to do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我可以在 Arch Linux / x86_64 上重现此内容:我的 libclang 版本发出关于缺少符号的警告,
并链接测试程序:
失败并显示:
解决此类链接器错误的过程是确定该符号位于哪个 C 库存档中。在我的 libclang 安装中搜索,我找不到此符号:
这可能是一个线索仅在不同版本的 libclang 中可用的东西。我使用的是 clang/llvm 2.9,它没有有这个符号,而 google 确实发现了一些包含它的旧标头。所以我最好的猜测是这个符号在 LLVM 中不再可用,因此当前的 haskell/libclang 包依赖于 LLVM/Clang 2.8。
解决方案:
下载 libclang 源代码,
并对其进行修补以删除对
toggle*
函数的引用。修补版本位于:http://www.galois。 com/~dons/tmp/LibClang-0.0.10.tar.gz
我也将此信息转发给了作者。
I can reproduce this on Arch Linux / x86_64: my libclang build emits a warning about the missing symbol,
and linking a test program:
fails with:
The process of solving these kind of linker errors is to identify which C library archive that symbol lives in. Searching in my libclang install, I can't find this symbol:
which is a clue that it might be something only available in a different version of libclang. I'm using clang/llvm 2.9, which does not have this symbol, while google does turn up some older headers that do include it. So my best guess is that this symbol is no longer available in LLVM, and thus the current haskell/libclang package depends on LLVM/Clang 2.8.
Solution:
Download the libclang source,
and patch it to remove references to the
toggle*
functions.A patched version is here: http://www.galois.com/~dons/tmp/LibClang-0.0.10.tar.gz
I've also forwarded this info to the author.
感谢唐的快速修复。
Hackage 的最新版本已修复此问题:
http://hackage.haskell.org/package/LibClang-0.1.0
请“cabal update”,你就可以开始了。
或者,您可以从 https://github.com/chetant/LibClang 获取源代码
Thanks Don for the quick fix.
This issue is fixed with the latest version on Hackage:
http://hackage.haskell.org/package/LibClang-0.1.0
Please "cabal update" and you should be good to go.
Alternatively, you could get the source from https://github.com/chetant/LibClang