[cfe-dev] Driver interaction with -fsanitize=memory

Evgeniy Stepanov eugeni.stepanov at gmail.com
Wed Aug 28 01:42:29 PDT 2013


Another option we've been using is placing libc++/libstdc++ at a
standard library path + a suffix, like /usr/lib/msan. Driver could add
an -L for that path before /usr/lib. Other msan-instrumented system
libraries could be placed at that path, too, and they will be
automagically picked up when building with msan.

I like the idea of installing libc++ alongside clang. Could we have
that as default (with either -msan name suffix, or /msan/ path suffix,
not sure which is better), but overrideable with something like
--libc++-path?


On Tue, Aug 27, 2013 at 11:22 PM, Rafael EspĂ­ndola
<rafael.espindola at gmail.com> wrote:
> The memory sanitizer requires that the entire program (minus libc) be
> built with it. When building a program that uses external libraries,
> that means building them first and passing -L so that they are found.
> For regular libraries I think this is fine, as it is no different from
> having newer versions of libraries installed somewhere in $HOME for
> example.
>
> For the c++ library the situation is a bit different. The driver
> normally handles it, so using a libc++ built with msan currently
> requires something like "-nostdinc++ -I$INST/include/ -L$INST/lib
> -lc++".
>
> Adding a --libc-prefix option (similar to --gcc-toolchain) would help,
> but we would still need to use
>
> * clang -fsanitize=memory -stdlib=libc++ --libc-prefix=prefix1
> * clang -fsanitize=memory -fsanitize-memory-track-origins
> -stdlib=libc++ --libc-prefix=prefix2
>
> Maybe a better option is
>
> * Support libc++ installed alongside clang, as we do with libstdc++
> * Look for the library with a suffix. That would allow multiple
> versions installed together:
>   * clang++  -fsanitize=memory: look for libstdc++-msan.so
>   * clang++  -fsanitize=memory -stdlib=libc++: look for libc++-msan.so
>   * clang++  -fsanitize=memory -stdlib=libc++
> -fsanitize-memory-track-origins: look for libc++-msan-track.so
>
>
> Any preferences?
>
> Cheers,
> Rafael
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list