[clang] Enable -fsanitize=thread on Fuchsia.

This CL modifies clang enabling using -fsanitize=thread on fuchsia. The
change doesn't build the runtime for fuchsia, it just enables the
instrumentation to be used.

pair-programmed-with: mdempsky@google.com
Change-Id: I816c4d240d1f15e9eae2803fb8ba3a7bf667ed51

Reviewed By: mcgrathr, phosek

Differential Revision: https://reviews.llvm.org/D86822
This commit is contained in:
Marco Vanotti 2020-08-28 15:42:09 -07:00
parent 0f661418aa
commit 2e800495a7
2 changed files with 7 additions and 1 deletions

View File

@ -703,6 +703,8 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
else
SharedRuntimes.push_back("scudo");
}
if (SanArgs.needsTsanRt() && SanArgs.linkRuntimes())
SharedRuntimes.push_back("tsan");
if (SanArgs.needsHwasanRt() && SanArgs.linkRuntimes())
SharedRuntimes.push_back("hwasan");
}
@ -747,7 +749,8 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
if (SanArgs.linkCXXRuntimes())
StaticRuntimes.push_back("msan_cxx");
}
if (SanArgs.needsTsanRt() && SanArgs.linkRuntimes()) {
if (!SanArgs.needsSharedRt() && SanArgs.needsTsanRt() &&
SanArgs.linkRuntimes()) {
StaticRuntimes.push_back("tsan");
if (SanArgs.linkCXXRuntimes())
StaticRuntimes.push_back("tsan_cxx");

View File

@ -95,6 +95,8 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const JobAction &JA,
std::string Dyld = D.DyldPrefix;
if (SanArgs.needsAsanRt() && SanArgs.needsSharedRt())
Dyld += "asan/";
if (SanArgs.needsTsanRt() && SanArgs.needsSharedRt())
Dyld += "tsan/";
Dyld += "ld.so.1";
CmdArgs.push_back("-dynamic-linker");
CmdArgs.push_back(Args.MakeArgString(Dyld));
@ -349,6 +351,7 @@ SanitizerMask Fuchsia::getSupportedSanitizers() const {
Res |= SanitizerKind::Leak;
Res |= SanitizerKind::SafeStack;
Res |= SanitizerKind::Scudo;
Res |= SanitizerKind::Thread;
return Res;
}