Index: lib/Driver/ToolChains/NetBSD.h =================================================================== --- lib/Driver/ToolChains/NetBSD.h +++ lib/Driver/ToolChains/NetBSD.h @@ -76,6 +76,10 @@ 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; Index: lib/Driver/ToolChains/NetBSD.cpp =================================================================== --- lib/Driver/ToolChains/NetBSD.cpp +++ lib/Driver/ToolChains/NetBSD.cpp @@ -457,3 +457,18 @@ } return Res; } + +void NetBSD::addClangTargetOptions(const ArgList &, + ArgStringList &CC1Args, + Action::OffloadKind) const { + const SanitizerArgs &SanArgs = getSanitizerArgs(); + if (SanArgs.needsAsanRt() || SanArgs.needsHwasanRt() || + SanArgs.needsDfsanRt() || SanArgs.needsLsanRt() || + SanArgs.needsMsanRt() || SanArgs.needsTsanRt() || + SanArgs.needsUbsanRt() || SanArgs.needsSafeStackRt() || + SanArgs.needsCfiRt() || SanArgs.needsCfiDiagRt() || + SanArgs.needsStatsRt() || SanArgs.needsEsanRt() || + SanArgs.needsScudoRt()) { + CC1Args.push_back("-D_REENTRANT"); + } +}