[PATCH] D39888: [lsan] Only use VM_MEMORY_OS_ALLOC_ONCE on Darwin versions that support it

Rainer Orth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 15 07:05:31 PST 2017


ro updated this revision to Diff 123023.
ro added a comment.
Herald added a subscriber: srhines.

gcc patch (C only, no build system parts needed) to disable lsan common parts and
disable use of weak definitions before OS X 10.9.  Just for reference.


https://reviews.llvm.org/D39888

Files:
  libsanitizer/lsan/lsan_common.h
  libsanitizer/sanitizer_common/sanitizer_internal_defs.h


Index: libsanitizer/sanitizer_common/sanitizer_internal_defs.h
===================================================================
--- libsanitizer/sanitizer_common/sanitizer_internal_defs.h
+++ libsanitizer/sanitizer_common/sanitizer_internal_defs.h
@@ -63,7 +63,13 @@
 // SANITIZER_SUPPORTS_WEAK_HOOKS means that we support real weak functions that
 // will evaluate to a null pointer when not defined.
 #ifndef SANITIZER_SUPPORTS_WEAK_HOOKS
-#if (SANITIZER_LINUX || SANITIZER_MAC) && !SANITIZER_GO
+#if SANITIZER_LINUX && !SANITIZER_GO
+# define SANITIZER_SUPPORTS_WEAK_HOOKS 1
+// Before Xcode 4.5, the Darwin linker doesn't reliably support undefined
+// weak symbols.  Mac OS X 10.9/Darwin 13 is the first release only supported
+// by Xcode >= 4.5.
+#elif SANITIZER_MAC && \
+    __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1090 && !SANITIZER_GO
 # define SANITIZER_SUPPORTS_WEAK_HOOKS 1
 #else
 # define SANITIZER_SUPPORTS_WEAK_HOOKS 0
Index: libsanitizer/lsan/lsan_common.h
===================================================================
--- libsanitizer/lsan/lsan_common.h
+++ libsanitizer/lsan/lsan_common.h
@@ -28,13 +28,17 @@
 // To enable LeakSanitizer on new architecture, one need to implement
 // internal_clone function as well as (probably) adjust TLS machinery for
 // new architecture inside sanitizer library.
-#if (SANITIZER_LINUX && !SANITIZER_ANDROID || SANITIZER_MAC) && \
+#if (SANITIZER_LINUX && !SANITIZER_ANDROID) && \
     (SANITIZER_WORDSIZE == 64) &&                               \
     (defined(__x86_64__) || defined(__mips64) || defined(__aarch64__) || \
      defined(__powerpc64__))
 #define CAN_SANITIZE_LEAKS 1
 #elif defined(__i386__) && \
-    (SANITIZER_LINUX && !SANITIZER_ANDROID || SANITIZER_MAC)
+    (SANITIZER_LINUX && !SANITIZER_ANDROID)
+#define CAN_SANITIZE_LEAKS 1
+// lsan_common_mac.cc uses VM_MEMORY_OS_ALLOC_ONCE which was only
+// introduced in Mac OS X 10.9/Darwin 13.
+#elif SANITIZER_MAC && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1090
 #define CAN_SANITIZE_LEAKS 1
 #elif defined(__arm__) && \
     SANITIZER_LINUX && !SANITIZER_ANDROID


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39888.123023.patch
Type: text/x-patch
Size: 2118 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171115/cd9afb60/attachment.bin>


More information about the llvm-commits mailing list