diff --git a/driver/main.cpp b/driver/main.cpp index 50c4563fb3..4646d4337b 100644 --- a/driver/main.cpp +++ b/driver/main.cpp @@ -636,6 +636,21 @@ static void registerPredefinedVersions() { registerPredefinedTargetVersions(); +#if LDC_LLVM_VER >= 303 + // Pass sanitizer arguments to linker. Requires clang. + if (opts::sanitize == opts::AddressSanitizer) { + VersionCondition::addPredefinedGlobalIdent("LDC_AddressSanitizer"); + } + + if (opts::sanitize == opts::MemorySanitizer) { + VersionCondition::addPredefinedGlobalIdent("LDC_MemorySanitizer"); + } + + if (opts::sanitize == opts::ThreadSanitizer) { + VersionCondition::addPredefinedGlobalIdent("LDC_ThreadSanitizer"); + } +#endif + // Expose LLVM version to runtime #define STR(x) #x #define XSTR(x) STR(x)