Package: clang Version: 1:3.6-33 Severity: normal Dear Maintainer,
With the latest available versions of clang-3.{5..9} ( 1:3.5.2-3 1:3.6.2-3 1:3.7.1-2 1:3.8-2 1:3.9~svn262954-1 ) it is impossible to build and run programs using the shared version of libasan. For 3.5 through 3.7, the error is at link time: /usr/bin/x86_64-linux-gnu-ld.bfd.real: cannot find /usr/lib/llvm-3.5/bin/../lib/clang/3.5.2/lib/linux/libclang_rt.asan-preinit-x86_64.a: No such file or directory /usr/bin/x86_64-linux-gnu-ld.bfd.real: cannot find /usr/lib/llvm-3.5/bin/../lib/clang/3.5.2/lib/linux/libclang_rt.asan-x86_64.so: No such file or directory The debian packaging appears to simply not include the shared versions of the files. Since these are older versions, it may not be worth fixing. For 3.8 and 3.9, the error is at load time: libclang_rt.asan-x86_64.so => not found exporting LD_LIBRARY_PATH works, but is not . Among other things, this makes it impossible to use ASAN with shared libraries, though there are reasons to want shared ASAN for binaries too. Additionally, `-print-file-name=libasan.so` should do the right thing like it does for GCC, to avoid both clang-specific behavior *and* trying to guess the right architecture for the current set of CC and CFLAGS. Particularly, for shared libraries, it is expected that you can do: LD_PRELOAD=$(${CC} ${CFLAGS} -print-file-name=libasan.so):$LD_PRELOAD # BEGIN TEST SCRIPT #!/bin/bash # ASAN is available since CLANG 3.1 and since GCC 4.8 # To test with a single version, do something like: # LD_LIBRARY_PATH=/usr/lib/llvm-3.8/lib/clang/3.8.0/lib/linux/ CC=clang-3.8 ./test.sh ALL_VERSIONS=$(echo gcc-4.{8..9} gcc-{5..6} clang-3.{1..9}) for CC in ${CC:-${ALL_VERSIONS}} do CFLAGS=-fsanitize=address if [ "${CC}" != "${CC#clang}" ] then CFLAGS="$CFLAGS -shared-libasan" fi if ! ${CC} --version &> /dev/null then echo ${CC} is not installed. continue fi if ! echo 'int main(){}' | ${CC} ${CFLAGS} -x c - &> /dev/null then echo ${CC} failed to compile/link the program. continue fi if ldd a.out | grep -q 'not found' then echo ${CC} failed to create a loadable binary. continue fi ACTUAL_ASAN=$(ldd a.out | grep asan | sed 's/.*=> *//;s/ *(.*) *//') if ! DECLARED_ASAN=$(${CC} ${CFLAGS} -print-file-name=libasan.so 2>/dev/null) then echo ${CC} failed to print filename. continue fi if [ "$(realpath ${ACTUAL_ASAN})" != "$(realpath ${DECLARED_ASAN})" ] then echo ${CC} printed a different version than it actually used. continue fi echo ${CC} is okay! done # END TEST SCRIPT -- System Information: Debian Release: stretch/sid APT prefers testing APT policy: (600, 'testing'), (500, 'unstable-debug'), (500, 'unstable'), (1, 'experimental') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 4.3.0-1-amd64 (SMP w/4 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages clang depends on: ii clang-3.6 1:3.6.2-3 clang recommends no packages. clang suggests no packages. -- no debconf information