Clang 3.3 and libclang_rt.asan_osx_dynamic.dylib not found?

Hi All,

My program is failing to link with -fsantize=address:

$ make CXX=/usr/local/bin/clang++
...
/usr/local/bin/clang++ -DNDEBUG -g -O2 -DCRYPTOPP_DISABLE_ASM -pipe
-Wno-unused-value -Wno-tautological-compare -fsanitize=address -c
dlltest.cpp
/usr/local/bin/clang++ -o cryptest.exe -DNDEBUG -g -O2
-DCRYPTOPP_DISABLE_ASM -pipe -Wno-unused-value
-Wno-tautological-compare -fsanitize=address bench.o bench2.o test.o
validat1.o validat2.o validat3.o adhoc.o datatest.o regtest.o
fipsalgt.o dlltest.o ./libcryptopp.a
ld: file not found:
/usr/local/bin/../lib/clang/3.3/lib/darwin/libclang_rt.asan_osx_dynamic.dylib

Clang version:

$ /usr/local/bin/clang++ -v
clang version 3.3 (tags/RELEASE_33/final)
Target: x86_64-apple-darwin12.4.0
Thread model: posix

Library:

$ find /usr/local/ -iname libclang_rt.asan_osx_dynamic.dylib
$

Below is how I built and installed the tools.

Any ideas where to find libclang_rt.asan_osx_dynamic.dylib?

Jeff

wget http://llvm.org/releases/3.3/llvm-3.3.src.tar.gz
wget http://llvm.org/releases/3.3/cfe-3.3.src.tar.gz
tar xvf llvm-3.3.src.tar.gz
cd llvm-3.3.src/tools
tar xvf ../../cfe-3.3.src.tar.gz
mv cfe-3.3.src clang
cd ..
./configure --enable-optimized --prefix=/usr/local
make -j4
sudo make install

Jeffrey Walton <noloader@gmail.com> writes:

My program is failing to link with -fsantize=address:

...

Any ideas where to find libclang_rt.asan_osx_dynamic.dylib?

You'll need to build compiler-rt for the sanitizers to work. Grab it and
put it under projects/compiler-rt before the configure/make step

Thanks Justin.

I unpacked compiler-rt-3.3.src.tar.gz into projects and re-ran
configure/make, but that library is still missing:

$ find /usr/local/ -iname libclang_rt.asan_osx_dynamic.dylib
$

Does the makefile do the right thing? Or do I need to take more
special steps (does compiler-rt-3.3.src need to be renamed)?

$ pwd
/Users/jwalton/clang-llvm/llvm-3.3.src
$ ls projects/
CMakeLists.txt Makefile sample
LLVMBuild.txt compiler-rt-3.3.src

Jeff

wget http://llvm.org/releases/3.3/llvm-3.3.src.tar.gz
wget http://llvm.org/releases/3.3/cfe-3.3.src.tar.gz
wget http://llvm.org/releases/3.3/compiler-rt-3.3.src.tar.gz
tar xvf llvm-3.3.src.tar.gz
cd llvm-3.3.src/tools
tar xvf ../../cfe-3.3.src.tar.gz
mv cfe-3.3.src clang
cd ..
cd projects
tar xvf ../../compiler-rt-3.3.src.tar.gz
cd ..
./configure --enable-optimized --prefix=/usr/local
make -j4
sudo make install

Yes, it needs renaming. Then it works like a charm. Thanks.

Recipe for those who are interested:

wget http://llvm.org/releases/3.3/llvm-3.3.src.tar.gz
wget http://llvm.org/releases/3.3/cfe-3.3.src.tar.gz
wget http://llvm.org/releases/3.3/compiler-rt-3.3.src.tar.gz
tar xvf llvm-3.3.src.tar.gz
cd llvm-3.3.src/tools
tar xvf ../../cfe-3.3.src.tar.gz
mv cfe-3.3.src clang
cd ..
cd projects
tar xvf ../../compiler-rt-3.3.src.tar.gz
mv compiler-rt-3.3.src/ compiler-rt
cd ..
./configure --enable-optimized --prefix=/usr/local
make -j4
sudo make install