c++ - Missing libclang_rt.san-x86_64.a file for LLVM compiler-rt -


i've built llvm/clang compiler-rt , tried -fsanitize option. strangely link failed since cannot find libclang_rt.san-x86_64.a.

/usr/bin/ld: cannot find /home/hongxu/research/llvm-git/obj/bin/../lib/clang/3.7.0/lib/linux/libclang_rt.san-x86_64.a: no such file or directory clang-3.7: error: linker command failed exit code 1 (use -v see invocation) 

when changed directory /home/hongxu/research/llvm-git/obj/bin/../lib/clang/3.7.0/lib/linux/, found there other library files

# addresssanitizer libclang_rt.asan_cxx-x86_64.a libclang_rt.asan-preinit-x86_64.a libclang_rt.asan-x86_64.a # dataflowsanitizer libclang_rt.dfsan-libc-x86_64.a libclang_rt.dfsan-x86_64.a # leaksanitizer libclang_rt.lsan-x86_64.a # memorysanitizer libclang_rt.msan-x86_64.a # threadsanitizer libclang_rt.tsan-x86_64.a # undefinedbehaviorsanitizer libclang_rt.ubsan_cxx-x86_64.a libclang_rt.ubsan_standalone_cxx-x86_64.a libclang_rt.ubsan_standalone-x86_64.a libclang_rt.ubsan-x86_64.a 

and can guess functionalities name according compiler-rt page.

but libclang_rt.san-x86_64.a? , how can it?

but strangely link failed since cannot find libclang_rt.san-x86_64.a.

yeah, make install not install things needed. other times, installs them in non-standard locations.

other things not install includes asan_symbolize.py, used symbolicate dumps address sanitizer (asan).


but libclang_rt.san-x86_64.a? , how can it?

its 1 of sanitizer libraries. have it, don't realize because in non-standard location. example, on system (where build llvm/clang myself):

$ find /usr -name libclang_rt.san-x86_64.a 2>/dev/null  /usr/local/lib/clang/3.5.0/lib/linux/libclang_rt.san-x86_64.a 

so have use either ld_library_path (linux) or dyld_library_path (os x) ensure compiler driver can find it. should never have manually add various sanitizer libraries - compiler driver should add them you.

for completeness, clang 3.4 installed sanitizers libraries @ /usr/local/lib/clang/3.4/lib/linux/ on linux; , clang 3.3 installed them @ /usr/local/lib/clang/3.3/lib/darwin/ on os x.

you can change search directories in source code , picked automatically compiler driver. think had change actual sources because not find configure option add locations /usr/local/lib/clang/<version>/lib/linux/. take @ tools/clang/lib/frontend/initheadersearch.cpp , friends. that's paths .../include/c++/4.2.1 come from.


by way, here's how use address sanitizer , asan_symbolize.py. first, run 2to3 , asan_symbolize.py fix python folks broke related basic i/o:

$ find clang-3.5/ -name asan_symbolize.py clang-3.5/llvm/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py 2to3 -w clang-3.5/llvm/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py  echo "" | clang-3.5/llvm/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py # fix errors 2to3 missed 

then, copy known location (or put on path):

sudo cp clang-3.5/llvm/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py /usr/local/bin 

then, project:

export cppflags="-fsanitze=undefined -fsanitize=address" export cflags="-fsanitze=undefined -fsanitize=address" export cxxflags="-fsanitze=undefined -fsanitize=address -fno-sanitize=vptr" export cc=/usr/local/bin/clang export cxx=/usr/local/bin/clang++ export ld_library_path=/usr/local/lib/clang/3.5.0/lib/linux  ./configure make make check 2>&1 | asan_symbolize.py 

cppflags quite important autotools project. otherwise, dreaded c compiler cannot create executables error.

when have asan error, see similar to:

make test 2>&1 | asan_symbolize.py ...  /usr/local/bin/clang -fsanitize=address -xlinker -export-dynamic     -o python modules/python.o libpython3.3m.a -ldl -lutil     /usr/local/ssl/lib/libssl.a /usr/local/ssl/lib/libcrypto.a -lm ./python -e -s -m sysconfig --generate-posix-vars ================================================================= ==24064==error: addresssanitizer: heap-buffer-overflow on address 0x619000004020 @ pc 0x4ed4b2 bp 0x7fff80fff010 sp 0x7fff80fff008 read of size 4 @ 0x619000004020 thread t0   #0 0x4ed4b1 in pyobject_free python-3.3.5/./objects/obmalloc.c:987   #1 0x7a2141 in code_dealloc python-3.3.5/./objects/codeobject.c:359   #2 0x620c00 in pyimport_importfrozenmoduleobject        python-3.3.5/./python/import.c:1098   #3 0x620d5c in pyimport_importfrozenmodule        python-3.3.5/./python/import.c:1114   #4 0x63fd07 in import_init python-3.3.5/./python/pythonrun.c:206   #5 0x63f636 in _py_initializeex_private        python-3.3.5/./python/pythonrun.c:369   #6 0x681d77 in py_main python-3.3.5/./modules/main.c:648   #7 0x4e6894 in main python-3.3.5/././modules/python.c:62   #8 0x2abf9a525eac in __libc_start_main        /home/aurel32/eglibc/eglibc-2.13/csu/libc-start.c:244   #9 0x4e664c in _start (python-3.3.5/./python+0x4e664c)  addresssanitizer can not describe address in more detail (wild memory access suspected). summary: addresssanitizer: heap-buffer-overflow   python-3.3.5/./objects/obmalloc.c:987 pyobject_free shadow bytes around buggy address:   0x0c327fff87b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa   0x0c327fff87c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa   0x0c327fff87d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa   0x0c327fff87e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa   0x0c327fff87f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa =>0x0c327fff8800: fa fa fa fa[fa]fa fa fa fa fa fa fa fa fa fa fa   0x0c327fff8810: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa   0x0c327fff8820: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa   0x0c327fff8830: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa   0x0c327fff8840: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa   0x0c327fff8850: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa shadow byte legend (one shadow byte represents 8 application bytes):   addressable:           00   partially addressable: 01 02 03 04 05 06 07   heap left redzone:     fa   heap right redzone:    fb   freed heap region:     fd   stack left redzone:    f1   stack mid redzone:     f2   stack right redzone:   f3   stack partial redzone: f4   stack after return:    f5   stack use after scope: f8   global redzone:        f9   global init order:     f6   poisoned user:      f7   asan internal:         fe ==24064==aborting make: *** [pybuilddir.txt] error 1 

there's more complete writeup of llvm/clang build process , using santizers @ python's dynamic analysis clang. wrote while ago, version , recipe stale. concepts same.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -