[cfe-users] Address Sanitizer Link Error
Peter Caspers
pcaspers1973 at gmail.com
Wed May 7 11:15:34 PDT 2014
here are the invocations for the linker step, with clang++ and clang.
Indeed, only in the first case -lstdc++, this seems to be derived from
the command name itself. Regarding the address sanitizer it seems that
only libclang_rt.asan-x86_64.a, which seems properly installed in the
correct path. Does anyone spot something suspicious ?
"/usr/bin/ld" -whole-archive
/usr/local/bin/../lib/clang/3.5.0/lib/linux/libclang_rt.asan-x86_64.a
-no-whole-archive -z relro --hash-style=gnu --build-id --eh-frame-hdr
-m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o
AswZSpreads /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o
/usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o
-L/home/peter/boost_1_55_0/stage/lib
-L/home/peter/quantlib/QuantLib/ql/.libs
-L/usr/local/lib/clang/3.5.0/lib/linux/
-L/usr/lib/gcc/x86_64-linux-gnu/4.8
-L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu
-L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu
-L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. -L/usr/local/bin/../lib
-L/lib -L/usr/lib /tmp/AswZSpreads-f59282.o -lQuantLib -lpthread -lrt
-lm -ldl -export-dynamic -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/lib/gcc/x86_64-linux-gnu/4.8/crtend.o
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crtn.o
"/usr/bin/ld" -whole-archive
/usr/local/bin/../lib/clang/3.5.0/lib/linux/libclang_rt.asan-x86_64.a
-no-whole-archive -z relro --hash-style=gnu --build-id --eh-frame-hdr
-m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o
AswZSpreads /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o
/usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o
-L/home/peter/boost_1_55_0/stage/lib
-L/home/peter/quantlib/QuantLib/ql/.libs
-L/usr/local/lib/clang/3.5.0/lib/linux/
-L/usr/lib/gcc/x86_64-linux-gnu/4.8
-L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu
-L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu
-L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. -L/usr/local/bin/../lib
-L/lib -L/usr/lib /tmp/AswZSpreads-606e7c.o -lQuantLib -lpthread -lrt
-lm -ldl -export-dynamic -lgcc --as-needed -lgcc_s --no-as-needed -lc
-lgcc --as-needed -lgcc_s --no-as-needed
/usr/lib/gcc/x86_64-linux-gnu/4.8/crtend.o
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crtn.o
On 7 May 2014 11:11, Peter Caspers <pcaspers1973 at gmail.com> wrote:
> what I observe is that if I use clang (instead of clang++) for the
> link step, I get a different error (undefined reference to symbol
> ___cxa_free_exception@@CXXABI_1.3). I thought, that clang++ is just a
> synonym for clang ? How does that magic happen ?
> Thanks again
> Peter
>
> On 7 May 2014 11:08, Peter Caspers <pcaspers1973 at gmail.com> wrote:
>> I tried the link step from the command line manually, but get the same
>> error messages.
>> In which library is __asan_memcpy expected to reside ?
>> Thanks
>> Peter
>>
>> On 6 May 2014 12:23, Jeffrey Walton <noloader at gmail.com> wrote:
>>> On Tue, May 6, 2014 at 5:36 AM, Peter Caspers <pcaspers1973 at gmail.com> wrote:
>>>> yes, I use clang with the sanitize option to link. I have the
>>>> following libs installed
>>>>
>>>> peter at peter-ThinkPad-W520:/usr/local/lib/clang/3.5.0/lib/linux$ ls
>>>> libclang_rt.asan-x86_64.a libclang_rt.lsan-x86_64.a
>>>> libclang_rt.san-x86_64.a libclang_rt.ubsan-x86_64.a
>>>> libclang_rt.dfsan-x86_64.a libclang_rt.msan-x86_64.a
>>>> libclang_rt.tsan-x86_64.a
>>>> libclang_rt.full-x86_64.a libclang_rt.profile-x86_64.a
>>>> libclang_rt.ubsan_cxx-x86_64.a
>>>>
>>>> You think that should work then ?
>>> How do you invoke Clang? Are the sanitizer flags part of CFLAGS and CXXFLAGS?
>>>
>>> Is this an Autools project? Sometimes you have to be creative with
>>> Autotools projects. For example, you might need to do:
>>>
>>> export CC="clang -fsanitize=undefined -fsanitize=address"
>>> export CXX="clang -fsanitize=undefined -fsanitize=address
>>> -fno-sanitize=vptr"
>>>
>>> That's because there will sometimes be a link line that *omits* CFLAGS
>>> and CXXFLAGS. For example:
>>>
>>> # Link using the compiler...
>>> $(CC) -o $(program_name) $(OBJECTS) $(LDFLAGS) $(LDLIBS)
>>>
>>> On Mac OS X, I also find I need to set DYLD_FALLBACK_LIBRARY_PATH
>>> before executing:
>>>
>>> export DYLD_FALLBACK_LIBRARY_PATH=/usr/local/lib/clang/3.4/lib/darwin/
>>> ./my_program
>>>
>>> I don't recall doing similar on Linux. (But I may have done it and
>>> forgotten about it).
>>>
>>> Jeff
More information about the cfe-users
mailing list