Skip to content

Commit d7d0ebb

Browse files
committed
Add new version identifiers if a sanitizer is specified.
1 parent 7f01760 commit d7d0ebb

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

driver/main.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,21 @@ static void registerPredefinedVersions() {
636636

637637
registerPredefinedTargetVersions();
638638

639+
#if LDC_LLVM_VER >= 303
640+
// Pass sanitizer arguments to linker. Requires clang.
641+
if (opts::sanitize == opts::AddressSanitizer) {
642+
VersionCondition::addPredefinedGlobalIdent("LDC_AddressSanitizer");
643+
}
644+
645+
if (opts::sanitize == opts::MemorySanitizer) {
646+
VersionCondition::addPredefinedGlobalIdent("LDC_MemorySanitizer");
647+
}
648+
649+
if (opts::sanitize == opts::ThreadSanitizer) {
650+
VersionCondition::addPredefinedGlobalIdent("LDC_ThreadSanitizer");
651+
}
652+
#endif
653+
639654
// Expose LLVM version to runtime
640655
#define STR(x) #x
641656
#define XSTR(x) STR(x)

0 commit comments

Comments
 (0)