r349650 - [Driver] [NetBSD] Add -D_REENTRANT when using sanitizers
Michal Gorny via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 19 09:25:59 PST 2018
Author: mgorny
Date: Wed Dec 19 09:25:59 2018
New Revision: 349650
URL: http://llvm.org/viewvc/llvm-project?rev=349650&view=rev
Log:
[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
Modified:
cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp
cfe/trunk/lib/Driver/ToolChains/NetBSD.h
Modified: cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp?rev=349650&r1=349649&r2=349650&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp Wed Dec 19 09:25:59 2018
@@ -457,3 +457,11 @@ SanitizerMask NetBSD::getSupportedSaniti
}
return Res;
}
+
+void NetBSD::addClangTargetOptions(const ArgList &,
+ ArgStringList &CC1Args,
+ Action::OffloadKind) const {
+ const SanitizerArgs &SanArgs = getSanitizerArgs();
+ if (SanArgs.hasAnySanitizer())
+ CC1Args.push_back("-D_REENTRANT");
+}
Modified: cfe/trunk/lib/Driver/ToolChains/NetBSD.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/NetBSD.h?rev=349650&r1=349649&r2=349650&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/NetBSD.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/NetBSD.h Wed Dec 19 09:25:59 2018
@@ -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;
More information about the cfe-commits
mailing list