[experimental] Add sanitizer options to LDC.

Add some of the sanitizer passes to LDC. This is not complete (linking must be
done using clang and the right `-fsanitize=` option) and may not be useful at
all.

If it proves to be usefull then a lot of other options (e.g. blacklist) must be
added.
This commit is contained in:
kai 2013-10-22 22:49:54 +02:00
parent 6fe28e1660
commit e6529cfd3d
3 changed files with 91 additions and 0 deletions

View file

@ -137,6 +137,21 @@ static int linkObjToBinaryGcc(bool sharedLib)
// create path to exe
CreateDirectoryOnDisk(gExePath);
#if LDC_LLVM_VER >= 303
// Pass sanitizer arguments to linker. Requires clang.
if (opts::sanitize == opts::AddressSanitizer) {
args.push_back("-fsanitize=address");
}
if (opts::sanitize == opts::MemorySanitizer) {
args.push_back("-fsanitize=memory");
}
if (opts::sanitize == opts::ThreadSanitizer) {
args.push_back("-fsanitize=thread");
}
#endif
// additional linker switches
for (unsigned i = 0; i < global.params.linkswitches->dim; i++)
{