From: Michal Gorny Date: Wed, 19 Dec 2018 17:25:59 +0000 (+0000) Subject: [Driver] [NetBSD] Add -D_REENTRANT when using sanitizers X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c00ce7cec04125051b37d5ee9b9b91090e15da31;p=clang [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 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349650 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains/NetBSD.cpp b/lib/Driver/ToolChains/NetBSD.cpp index 73e230b3ea..6dba5b1a59 100644 --- a/lib/Driver/ToolChains/NetBSD.cpp +++ b/lib/Driver/ToolChains/NetBSD.cpp @@ -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"); +} diff --git a/lib/Driver/ToolChains/NetBSD.h b/lib/Driver/ToolChains/NetBSD.h index 49e3a58d02..ae0865fd65 100644 --- a/lib/Driver/ToolChains/NetBSD.h +++ b/lib/Driver/ToolChains/NetBSD.h @@ -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;