[haskell-llvm] Towards 0.10
Mark Wright
markwright at internode.on.net
Sat Jul 16 16:48:18 BST 2011
On Sat, 16 Jul 2011 16:13:12 +0200 (CEST), Henning Thielemann <lemming at henning-thielemann.de> wrote:
>
> On Sat, 16 Jul 2011, Mark Wright wrote:
>
> > I can not reproduce it (since I do not have the source code to Array.hs).
>
> https://github.com/bos/llvm/blob/master/examples/Array.hs
Thanks.
> The particular example is not important, it is not possible to call
> anything from a module that imports 'llvm' in GHCi.
>
> > The symbol is:
> >
> > % echo '_Z8do_printIP15LLVMOpaqueValueN4llvm5ValueEEPcT_' |c++filt
> > char* do_print<LLVMOpaqueValue*, llvm::Value>(LLVMOpaqueValue*)
> > %
>
> Cool trick, didn't know of c++filt before!
>
> > Which is in:
> >
> > llvm/cbits/extra.cpp
> >
> > Which means is should be possible to fix that particular missing symbol.
>
> Ah, I see LLVMOpaqueValue is a synonym for LLVMValueRef.
> llvm-c/Core.h:typedef struct LLVMOpaqueValue *LLVMValueRef;
>
>
> llvm$ nm dist/build/libHSllvm-0.10.0.0-ghc6.12.3.so | fgrep do_print
> 002c3920 W _Z8do_printIP14LLVMOpaqueTypeN4llvm4TypeEEPcT_
> 002c3a60 W _Z8do_printIP15LLVMOpaqueValueN4llvm5ValueEEPcT_
> 00c733a0 r _ZZ8do_printIP14LLVMOpaqueTypeN4llvm4TypeEEPcT_E19__PRETTY_FUNCTION__
> 00c73360 r _ZZ8do_printIP15LLVMOpaqueValueN4llvm5ValueEEPcT_E19__PRETTY_FUNCTION__
>
> So, some problem with weak symbols?
It seems that way.
Fortunately though you do actually need these do_print<W, UW>
template instantiations to have symbols associated with them.
They are only used in the extra.cpp file. So maybe it might help
you to make them inline, like:
diff --git a/cbits/extra.cpp b/cbits/extra.cpp
index 68a39e3..a42b962 100644
--- a/cbits/extra.cpp
+++ b/cbits/extra.cpp
@@ -88,7 +88,7 @@
/* Helper method for LLVMDumpXXXToString() methods. */
template <typename W, typename UW>
-char *do_print(W obj)
+inline char *do_print(W obj)
{
std::string s;
llvm::raw_string_ostream buf(s);
lines 1-13/13 (END)
with the idea that this removes the do_print() symbols
altogether, hence hoping ghci will cease complaining
about them then.
More information about the Haskell-llvm
mailing list