Artur Szostak
2014-Oct-17 14:50 UTC
[LLVMdev] Correctly compiling shared libraries for llvm-gcov on OSX
Hi, I have the following problem. I am trying to compile and link a binary and shared library on OS X 10.9 using the clang compiler on that platform. The binary links against the shared library (libgiraffe.19.dylib). I am using the -coverage flag for compilation and linking. Everything works fine until I get the following run time errors when trying to execute the binary: dyld: lazy symbol binding failed: Symbol not found: _llvm_gcov_init Referenced from: /Users/buildacc/jenkinsBuild/workspace/test-giraf-head-coverage-clone/BUILD_TYPE/debug/label/testnode/giraffe/.libs/libgiraffe.19.dylib Expected in: flat namespace dyld: Symbol not found: _llvm_gcov_init Referenced from: /Users/buildacc/jenkinsBuild/workspace/test-giraf-head-coverage-clone/BUILD_TYPE/debug/label/testnode/giraffe/.libs/libgiraffe.19.dylib Expected in: flat namespace My immediate assumption is that I need to pass an extra library when linking the shared library (libgiraffe.19.dylib), which contains _llvm_gcov_init. However, I could not find a single library on the platform that provides this function. This makes me think that LLVM implicitly adds these functions when linking a binary. Indeed, in the binary I do find a private symbol _llvm_gcov_init. So, can I tell LLVM to export the _llvm_gcov_init symbol in the binary so the shared library gets a chance to resolve it? Or, how could I create a library with the required function like _llvm_gcov_init to link my libraries against? Kind regards. Artur