[cfe-dev] Driver interaction with -fsanitize=memory
Rafael EspĂndola
rafael.espindola at gmail.com
Tue Aug 27 12:22:44 PDT 2013
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
More information about the cfe-dev
mailing list