Re: How to use gcc with sanitizers in Void Linux?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Kewen,

Thanks very much for your quick response!

Yes, after adding "-static-libasan", the compilation is successful!

But I checked the output of "gcc -v", there is no "--disable-libsanitizer":

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/9.2.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /builddir/gcc-9.2.0/configure
--build=x86_64-unknown-linux-gnu --enable-fast-character
--enable-vtable-verify --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --libexecdir=/usr/lib --libdir=/usr/lib
--enable-threads=posix --enable-__cxa_atexit --disable-multilib
--with-system-zlib --enable-shared --enable-lto --enable-plugins
--enable-linker-build-id --disable-werror --disable-nls
--enable-default-pie --enable-default-ssp --enable-checking=release
--disable-libstdcxx-pch --with-isl --with-linker-hash-style=gnu
--disable-libunwind-exceptions --disable-target-libiberty
--enable-serial-configure
--enable-languages=c,c++,objc,obj-c++,fortran,lto,go,ada
Thread model: posix
gcc version 9.2.0 (GCC)

Thanks!

Best Regards
Nan Xiao

On Thu, Dec 26, 2019 at 6:01 PM Kewen.Lin <linkw@xxxxxxxxxxxxx> wrote:
>
> Hi Nan,
>
> on 2019/12/26 下午4:48, Nan Xiao wrote:
> > Hi gcc community,
> >
> > Greetings from me!
> >
> > I am using Void Linux, and want to use sanitizers. Using clang to
> > compile code, it is OK:
> >
> > $ clang -std=c11 -fsanitize=address test.c
> > $
> >
> > While gcc reports following errors:
> >
> > $ gcc -std=c11 -fsanitize=address test.c
> > /usr/bin/ld: cannot find libasan_preinit.o: No such file or directory
> > /usr/bin/ld: cannot find -lasan
> > collect2: error: ld returned 1 exit status
> >
>
> May I suggest you checking your gcc whether disabled libsanitizer support?
> GCC configuration allows you to build one gcc without libsanitizer support
> with --disable-libsanitizer.  "gcc -v" can show the configuration options.
>
>
> > I check the program compiled with clang:
> >
> > $ ldd a.out
> > linux-vdso.so.1 (0x00007fffd858a000)
> > libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007fc1659b8000)
> > librt.so.1 => /usr/lib/librt.so.1 (0x00007fc1659ad000)
> > libm.so.6 => /usr/lib/libm.so.6 (0x00007fc165868000)
> > libdl.so.2 => /usr/lib/libdl.so.2 (0x00007fc165863000)
> > libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007fc165849000)
> > libc.so.6 => /usr/lib/libc.so.6 (0x00007fc165686000)
> > /lib64/ld-linux-x86-64.so.2 => /lib/ld-linux-x86-64.so.2 (0x00007fc1659e0000)
> >
>
> See https://github.com/google/sanitizers/wiki/AddressSanitizerAsDso
> I guess your clang was configured as static asan library by default.
> So it's linked with static library, you can't find libasan.so with ldd.
>
> > No asan library is required.
> >
>
> It requires static library. By the way, for gcc you can link with static library
> via gcc option -static-libasan.
>
>
> BR,
> Kewen
>




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux