]> granicus.if.org Git - clang/commitdiff
[Driver] [NetBSD] Add -D_REENTRANT when using sanitizers
authorMichal Gorny <mgorny@gentoo.org>
Wed, 19 Dec 2018 17:25:59 +0000 (17:25 +0000)
committerMichal Gorny <mgorny@gentoo.org>
Wed, 19 Dec 2018 17:25:59 +0000 (17:25 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349650 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains/NetBSD.cpp
lib/Driver/ToolChains/NetBSD.h

index 73e230b3ea4b6eb2604a9f63ea66227554107ea1..6dba5b1a59256828b85eacf3790c01cf2875edcb 100644 (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");
+}
index 49e3a58d02c377504b24b83302ca539a5c2d2014..ae0865fd6573dca63dd49e67bd9cf602ac4cf3c5 100644 (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;