
On Fri, 14 Jan 2011, Henning Thielemann wrote:
I want to trace calls from a Haskell program to LLVM. I tried ltrace and latrace. latrace didn't trace anything useful and ltrace shows at least the call to one function (LLVMBuildRetVoid), but not the other ones. I'm quite confident that I linked to LLVM dynamically, since the executable is small (35 KB, not 60 MB as when linking statically). Do GHC-generated programs call a foreign library in a way that bypasses ltrace?
I found the answer myself: 'ltrace' only observes calls into shared libraries, but not from shared libraries to other shared libraries and not to statically linked libraries. I must not compile with 'ghc -dynamic' since then the Haskell llvm bindings would be called as shared library and the calls from there to LLVM are not traced by ltrace. But I must link with the shared version of LLVM (option -lLLVM-2.8rc) in order to get dynamic calls from Haskell to LLVM. It seems that LLVMBuildRetVoid was a function call that was inlined, and thus it was called directly from Main and not from the Haskell llvm bindings.