[PATCH] D15624: Add iOS/watchOS/tvOS support for ASan (clang part)
Anna Zaks via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 20 13:12:48 PST 2016
zaks.anna updated this revision to Diff 45437.
zaks.anna added a comment.
Refactor the code to address Samsonov's review.
http://reviews.llvm.org/D15624
Files:
lib/Driver/ToolChains.cpp
lib/Driver/ToolChains.h
test/Driver/fsanitize.c
Index: test/Driver/fsanitize.c
===================================================================
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -230,7 +230,7 @@
// CHECK-VPTR-DARWIN-NEW: -fsanitize=alignment,vptr
// RUN: %clang -target armv7-apple-ios7 -miphoneos-version-min=7.0 -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-IOS
-// CHECK-ASAN-IOS: unsupported option '-fsanitize=address' for target 'arm-apple-ios7'
+// CHECK-ASAN-IOS: -fsanitize=address
// RUN: %clang -target i386-pc-openbsd -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-OPENBSD
// CHECK-ASAN-OPENBSD: unsupported option '-fsanitize=address' for target 'i386-pc-openbsd'
Index: lib/Driver/ToolChains.h
===================================================================
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -496,6 +496,8 @@
return TargetVersion < VersionTuple(V0, V1, V2);
}
+ StringRef getOSLibraryNameSuffix() const;
+
public:
/// }
/// @name ToolChain Implementation
Index: lib/Driver/ToolChains.cpp
===================================================================
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -319,6 +319,25 @@
}
}
+StringRef Darwin::getOSLibraryNameSuffix() const {
+ if (isTargetMacOS())
+ return "osx";
+ if (isTargetWatchOSSimulator())
+ return "watchossim";
+ if (isTargetWatchOS())
+ return "watchos";
+ if (isTargetIOSSimulator())
+ return "iossim";
+ if (isTargetIPhoneOS())
+ return "ios";
+ if (isTargetTvOSSimulator())
+ return "tvossim";
+ if (isTargetTvOS())
+ return "tvos";
+
+ llvm_unreachable("Unsuported OS");
+}
+
void Darwin::addProfileRTLibs(const ArgList &Args,
ArgStringList &CmdArgs) const {
if (!needsProfileRT(Args)) return;
@@ -363,12 +382,11 @@
// Sanitizer runtime libraries requires C++.
AddCXXStdlibLibArgs(Args, CmdArgs);
}
- // ASan is not supported on watchOS.
- assert(isTargetMacOS() || isTargetIOSSimulator());
- StringRef OS = isTargetMacOS() ? "osx" : "iossim";
+
AddLinkRuntimeLib(
Args, CmdArgs,
- (Twine("libclang_rt.") + Sanitizer + "_" + OS + "_dynamic.dylib").str(),
+ (Twine("libclang_rt.") + Sanitizer + "_" +
+ getOSLibraryNameSuffix() + "_dynamic.dylib").str(),
/*AlwaysLink*/ true, /*IsEmbedded*/ false,
/*AddRPath*/ true);
@@ -1220,8 +1238,7 @@
SanitizerMask Darwin::getSupportedSanitizers() const {
SanitizerMask Res = ToolChain::getSupportedSanitizers();
- if (isTargetMacOS() || isTargetIOSSimulator())
- Res |= SanitizerKind::Address;
+ Res |= SanitizerKind::Address;
if (isTargetMacOS()) {
if (!isMacosxVersionLT(10, 9))
Res |= SanitizerKind::Vptr;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15624.45437.patch
Type: text/x-patch
Size: 2787 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160120/020f6c79/attachment.bin>
More information about the cfe-commits
mailing list