I’m a bit lost on how one should install the Clang pre-built binaries available at llvm.org. I basically have the same questions as someone else has asked on Stack Overflow but want to point out the specific complexity of doing something that requires linking (implicitly) to a clang library. using AddressSanitizer in my case.
I’m not totally stuck. I was able to install clang V3.3 using macports. But now I want to get it working on my Ubuntu 12.04 install and am running into the same issue again without macports to rescue me.
On OS X 10.8.3:
I downloaded the pre-built binaries for V3.3 from llvm.org. I don’t see any install instructions for this distribution so placed the directory structure in a separate location of my choosing.
I can compile a simple application with the clang binary. If I compile with -fsanitize=address, still successful. But executing the binary, I got the error:
“dyld: Library not loaded: /Users/macs/Developer/llvm/final/Phase3/Release-64/llvmCore-3.3-final.obj/Release/lib/clang/3.3/lib/darwin/libclang_rt.asan_osx_dynamic.dylib Referenced from: /Users/me/Downloads/./a.out Reason: image not found Trace/BPT trap: 5”.
Ok, so I tried adding the two lib directories to my DYLD_LIBRARY_PATH environment variable:
With that, I could execute my program and got the expected (wonderful) AddressSanitizer report.
Was this the right approach? I’m concerned modifying the DYLD_LIBRARY_PATH is going to cause havoc given two Clang installs (the Apple build and this 3.3 build) For instance, there are many more library files in the lib dir than what AddressSanitizer needed.
Also, the “/Users/macs” path in the error report is not me, but likely the developer who did the build. Seems odd that I see this.
I suspect that the right answer is that clang/llvm must be configured such that their library search path looks in the right place for the internal libraries. I don’t know how to do that, especially after the toolset has been built.
Thanks for any help that can be provided. Best would be to add documentation to address this matter.