Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Commit

Permalink
[Driver] [NetBSD] Add -D_REENTRANT when using sanitizers
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mgorny committed Dec 19, 2018
1 parent 5b01cba commit c00ce7c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/Driver/ToolChains/NetBSD.cpp
Expand Up @@ -457,3 +457,11 @@ SanitizerMask NetBSD::getSupportedSanitizers() const {
} }
return Res; return Res;
} }

void NetBSD::addClangTargetOptions(const ArgList &,
ArgStringList &CC1Args,
Action::OffloadKind) const {
const SanitizerArgs &SanArgs = getSanitizerArgs();
if (SanArgs.hasAnySanitizer())
CC1Args.push_back("-D_REENTRANT");
}
4 changes: 4 additions & 0 deletions lib/Driver/ToolChains/NetBSD.h
Expand Up @@ -76,6 +76,10 @@ class LLVM_LIBRARY_VISIBILITY NetBSD : public Generic_ELF {


SanitizerMask getSupportedSanitizers() const override; SanitizerMask getSupportedSanitizers() const override;


void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args,
Action::OffloadKind DeviceOffloadKind) const override;

protected: protected:
Tool *buildAssembler() const override; Tool *buildAssembler() const override;
Tool *buildLinker() const override; Tool *buildLinker() const override;
Expand Down

0 comments on commit c00ce7c

Please sign in to comment.