[Driver] [NetBSD] Add -D_REENTRANT when using sanitizers

NetBSD intends to support only reentrant interfaces in interceptors.
When -lpthread is used without _REENTRANT defined, things are
not guaranteed to work.

This is especially important for <stdio.h> and sanitization of
interfaces around FILE.  Some APIs have alternative modes depending
on the _REENTRANT definition, and NetBSD intends to support sanitization
of the _REENTRANT ones.

Differential Revision: https://reviews.llvm.org/D55654

llvm-svn: 349650
This commit is contained in:
Michal Gorny 2018-12-19 17:25:59 +00:00
parent 1d43b3210b
commit f647a9f7dd
2 changed files with 12 additions and 0 deletions

View File

@ -457,3 +457,11 @@ SanitizerMask NetBSD::getSupportedSanitizers() const {
}
return Res;
}
void NetBSD::addClangTargetOptions(const ArgList &,
ArgStringList &CC1Args,
Action::OffloadKind) const {
const SanitizerArgs &SanArgs = getSanitizerArgs();
if (SanArgs.hasAnySanitizer())
CC1Args.push_back("-D_REENTRANT");
}

View File

@ -76,6 +76,10 @@ public:
SanitizerMask getSupportedSanitizers() const override;
void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args,
Action::OffloadKind DeviceOffloadKind) const override;
protected:
Tool *buildAssembler() const override;
Tool *buildLinker() const override;