clang-pure icon indicating copy to clipboard operation
clang-pure copied to clipboard

Problems linking against clang-pure with hybrid c/c++ code

Open deliciouslytyped opened this issue 5 years ago • 0 comments

I have problems linking other haskell libraries against clang-pure if I add c++ code using inline-c-cpp, I don't have everything on hand so I need to expand on the issue later.

I haven't been able to diagnose the issue particularly well, but I wanted to at least file it. I'll also put up a minimal repro later. - which is to say I'm not actually sure this is a c/c++ hybridization issue.

I'm using c++ because I'm writing some patches where I want to leverage features more internal to clang than what's exposed by the c interface, and this can by done by linking against clang-cpp.so .

Clang-pure itself compiles fine, the issue happens when I import clang-pure from another downstream library of mine, and then it complains:

> cabal repl --repl-options="-fobject-code" --repl-options="-O0"
[snip]
<command line>: /tmp/tmp.AGPRrbE1Fi/src2/dist-newstyle/build/x86_64-linux/ghc-8.8.3/clang-pure-0.2.0.6/build/libHSclang-pure-0.2.0.6-inplace-ghc8.8.3.so: undefined symbol: _ZTIN5clang12ast_matchers11MatchFinder13MatchCallbackE

_ZTIN5clang12ast_matchers11MatchFinder13MatchCallbackE is a virtual thing at https://clang.llvm.org/doxygen/classclang_1_1ast__matchers_1_1MatchFinder_1_1MatchCallback.html nm shows the symbol as as U which means undefined, but it's not immediately clear from my logs which .so this was on, presumably libHSclang-pure-0.2.0.6-inplace-ghc8.8.3.so.

Here's a partial lddtree:

$ lddtree dist-newstyle/build/x86_64-linux/ghc-8.6.5/clang-pure-0.2.0.6/build/libHSclang-pure-0.2.0.6-inplace-ghc8.6.5.so
dist-newstyle/build/x86_64-linux/ghc-8.6.5/clang-pure-0.2.0.6/build/libHSclang-pure-0.2.0.6-inplace-ghc8.6.5.so (interpreter => None)
    libm.so.6 => /lib64/libm.so.6
        ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2
    libclang-cpp.so.10 => /usr/lib/llvm/10/lib64/libclang-cpp.so.10
        libpthread.so.0 => /lib64/libpthread.so.0
        libLLVM-10.so => /usr/lib/llvm/10/lib64/libLLVM-10.so
            libffi.so.7 => /usr/lib64/libffi.so.7
            libz.so.1 => /lib64/libz.so.1
            libdl.so.2 => /lib64/libdl.so.2
            libtinfo.so.6 => /lib64/libtinfo.so.6

deliciouslytyped avatar May 18 '20 15:05 deliciouslytyped