diff mbox

Disable libsanitizer before darwin10

Message ID 419A3F06-344A-467A-9708-343E9E8CC2D2@codesourcery.com
State New
Headers show

Commit Message

Iain Sandoe Feb. 11, 2013, 4:06 p.m. UTC
On 11 Feb 2013, at 15:55, Jack Howarth wrote:

>  Iain Sandoe discovered that on intel darwin9, the asan testsuite suffers hundreds of 
> failures due to the absence of dispatch calls (Grand Central Dispatch) prior to darwin10.
> The attached patch disables building libsanitizer on darwin8 and darwin9 until upstream
> decides to support the earlier darwin releases. Bootstrap and regression tested on
> x86_64-apple-darwin12. Okay for gcc trunk?

note that making Darwin9 work is not that difficult - simply avoid the GCD calls (example hack attached).

However, the question is open as to whether upstream is willing to include code to cater for older Darwin (TBD).  
If such a change would be OK there, then the attached could be cleaned up/amended.

(it reduces the fails on i686-Darwin9 from 'all' asan to ~10 each for C on x86/x86_64 and similar for C++)

Iain
diff mbox

Patch

Index: libsanitizer/asan/dynamic/asan_interceptors_dynamic.cc
===================================================================
--- libsanitizer/asan/dynamic/asan_interceptors_dynamic.cc	(revision 195915)
+++ libsanitizer/asan/dynamic/asan_interceptors_dynamic.cc	(working copy)
@@ -84,6 +84,10 @@ 
   INTERPOSE_FUNCTION(mlockall),
   INTERPOSE_FUNCTION(munlockall),
 #endif
+
+#if defined (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
+    __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060
+
   INTERPOSE_FUNCTION(dispatch_async_f),
   INTERPOSE_FUNCTION(dispatch_sync_f),
   INTERPOSE_FUNCTION(dispatch_after_f),
@@ -96,14 +100,19 @@ 
   INTERPOSE_FUNCTION(dispatch_source_set_event_handler),
   INTERPOSE_FUNCTION(dispatch_source_set_cancel_handler),
 #endif
+#endif
   INTERPOSE_FUNCTION(signal),
   INTERPOSE_FUNCTION(sigaction),
 
   INTERPOSE_FUNCTION(malloc_create_zone),
   INTERPOSE_FUNCTION(malloc_default_zone),
+
+#if defined (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
+    __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060
   INTERPOSE_FUNCTION(malloc_default_purgeable_zone),
   INTERPOSE_FUNCTION(malloc_make_purgeable),
   INTERPOSE_FUNCTION(malloc_make_nonpurgeable),
+#endif
   INTERPOSE_FUNCTION(malloc_set_zone_name),
   INTERPOSE_FUNCTION(malloc),
   INTERPOSE_FUNCTION(free),
@@ -111,7 +120,10 @@ 
   INTERPOSE_FUNCTION(calloc),
   INTERPOSE_FUNCTION(valloc),
   INTERPOSE_FUNCTION(malloc_good_size),
+#if defined (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
+    __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060
   INTERPOSE_FUNCTION(posix_memalign),
+#endif
 };
 
 }  // namespace __asan
Index: libsanitizer/asan/asan_mac.cc
===================================================================
--- libsanitizer/asan/asan_mac.cc	(revision 195915)
+++ libsanitizer/asan/asan_mac.cc	(working copy)
@@ -197,6 +197,8 @@ 
   return err_none;
 }
 
+#if defined (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
+    __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060
 // Support for the following functions from libdispatch on Mac OS:
 //   dispatch_async_f()
 //   dispatch_async()
@@ -285,10 +287,12 @@ 
   context->func(context->block);
   asan_free(context, &stack, FROM_MALLOC);
 }
-
+#endif
 }  // namespace __asan
 
 using namespace __asan;  // NOLINT
+#if defined (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
+    __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060
 
 // Wrap |ctxt| and |func| into an asan_block_context_t.
 // The caller retains control of the allocated context.
@@ -319,6 +323,7 @@ 
                                asan_dispatch_call_block_and_release);         \
   }
 
+
 INTERCEPT_DISPATCH_X_F_3(dispatch_async_f)
 INTERCEPT_DISPATCH_X_F_3(dispatch_sync_f)
 INTERCEPT_DISPATCH_X_F_3(dispatch_barrier_async_f)
@@ -421,5 +426,6 @@ 
 }
 
 }  // namespace __asan
+#endif
 
 #endif  // __APPLE__
Index: libsanitizer/asan/asan_malloc_mac.cc
===================================================================
--- libsanitizer/asan/asan_malloc_mac.cc	(revision 195915)
+++ libsanitizer/asan/asan_malloc_mac.cc	(working copy)
@@ -52,6 +52,9 @@ 
   return &asan_zone;
 }
 
+#if defined (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
+    __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060
+
 INTERCEPTOR(malloc_zone_t *, malloc_default_purgeable_zone, void) {
   // FIXME: ASan should support purgeable allocations.
   // https://code.google.com/p/address-sanitizer/issues/detail?id=139
@@ -73,6 +76,7 @@ 
   // malloc_make_purgeable().
   return 0;
 }
+#endif
 
 INTERCEPTOR(void, malloc_set_zone_name, malloc_zone_t *zone, const char *name) {
   if (!asan_inited) __asan_init();
@@ -126,6 +130,9 @@ 
   return asan_zone.introspect->good_size(&asan_zone, size);
 }
 
+#if defined (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
+    __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060
+
 INTERCEPTOR(int, posix_memalign, void **memptr, size_t alignment, size_t size) {
   if (!asan_inited) __asan_init();
   CHECK(memptr);
@@ -137,7 +144,7 @@ 
   }
   return -1;
 }
-
+#endif
 namespace {
 
 // TODO(glider): the mz_* functions should be united with the Linux wrappers,