Fix libsanitizer build on OS X 10.1[01], macOS 10.12 (PR sanitizer/78267)
authorRainer Orth <ro@gcc.gnu.org>
Sun, 20 Nov 2016 10:49:47 +0000 (10:49 +0000)
committerRainer Orth <ro@gcc.gnu.org>
Sun, 20 Nov 2016 10:49:47 +0000 (10:49 +0000)
fixincludes:
PR sanitizer/78267
* inclhack.def (darwin_availabilityinternal, darwin_os_trace_1)
(darwin_os_trace_2, darwin_os_trace_3): New fixes.
(hpux_stdint_least_fast): Remove spurious _EOFix_.
* fixincl.x: Regenerate.
* tests/bases/AvailabilityInternal.h: New file.
* tests/bases/os/trace.h: New file.

2016-11-20  Jack Howarth  <howarth.at.gcc@gmail.com>

libsanitizer:
PR sanitizer/78267
* sanitizer_common/sanitizer_mac.cc: Include <os/trace.h> only if
compiler supports blocks extension.

From-SVN: r242633

fixincludes/ChangeLog
fixincludes/fixincl.x
fixincludes/inclhack.def
fixincludes/tests/base/AvailabilityInternal.h [new file with mode: 0644]
fixincludes/tests/base/os/trace.h [new file with mode: 0644]
libsanitizer/ChangeLog
libsanitizer/sanitizer_common/sanitizer_mac.cc

index 1d55b657d8c9eb7f2fa57eb8a13a530877d1823b..fef9f9fdc6f955cbaef4d95fcb4c096283679134 100644 (file)
@@ -1,3 +1,13 @@
+2016-11-20  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
+
+       PR sanitizer/78267
+       * inclhack.def (darwin_availabilityinternal, darwin_os_trace_1)
+       (darwin_os_trace_2, darwin_os_trace_3): New fixes.
+       (hpux_stdint_least_fast): Remove spurious _EOFix_.
+       * fixincl.x: Regenerate.
+       * tests/bases/AvailabilityInternal.h: New file.
+       * tests/bases/os/trace.h: New file.
+
 2016-09-30  Tadek Kijkowski  <tkijkowski@gmail.com>
 
        * check.tpl: Convert line endings to unix on test outputs
index cc5209e6205c4d0e3042e9d76b64e6555e0242f6..00d03be8ffe8eac6e7f88b73e47e250ef13eb654 100644 (file)
@@ -2,11 +2,11 @@
  * 
  * DO NOT EDIT THIS FILE   (fixincl.x)
  * 
- * It has been AutoGen-ed  Sunday September  4, 2016 at 12:15:33 PM EDT
+ * It has been AutoGen-ed  November 20, 2016 at 11:44:36 AM by AutoGen 5.16.2
  * From the definitions    inclhack.def
  * and the template file   fixincl
  */
-/* DO NOT SVN-MERGE THIS FILE, EITHER Sun  4 Sep 2016 12:15:33 EDT
+/* DO NOT SVN-MERGE THIS FILE, EITHER Sun Nov 20 11:44:37 MET 2016
  *
  * You must regenerate it.  Use the ./genfixes script.
  *
@@ -15,7 +15,7 @@
  * certain ANSI-incompatible system header files which are fixed to work
  * correctly with ANSI C and placed in a directory that GNU C will search.
  *
- * This file contains 237 fixup descriptions.
+ * This file contains 241 fixup descriptions.
  *
  * See README for more information.
  *
@@ -2577,6 +2577,51 @@ extern \"C\" {\n\
 #endif\n",
     (char*)NULL };
 
+/* * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Description of Darwin_Availabilityinternal fix
+ */
+tSCC zDarwin_AvailabilityinternalName[] =
+     "darwin_availabilityinternal";
+
+/*
+ *  File name selection pattern
+ */
+tSCC zDarwin_AvailabilityinternalList[] =
+  "AvailabilityInternal.h\0";
+/*
+ *  Machine/OS name selection pattern
+ */
+tSCC* apzDarwin_AvailabilityinternalMachs[] = {
+        "*-*-darwin*",
+        (const char*)NULL };
+
+/*
+ *  content selection pattern - do fix if pattern found
+ */
+tSCC zDarwin_AvailabilityinternalSelect0[] =
+       "#define[ \t]+(__API_[ADU]\\([^)]*\\)).*";
+
+#define    DARWIN_AVAILABILITYINTERNAL_TEST_CT  1
+static tTestDesc aDarwin_AvailabilityinternalTests[] = {
+  { TT_EGREP,    zDarwin_AvailabilityinternalSelect0, (regex_t*)NULL }, };
+
+/*
+ *  Fix Command Arguments for Darwin_Availabilityinternal
+ */
+static const char* apzDarwin_AvailabilityinternalPatch[] = {
+    "format",
+    "#if defined(__has_attribute)\n\
+  #if __has_attribute(availability)\n\
+%0\n\
+  #else\n\
+    #define %1\n\
+  #endif\n\
+#else\n\
+    #define %1\n\
+#endif",
+    (char*)NULL };
+
 /* * * * * * * * * * * * * * * * * * * * * * * * * *
  *
  *  Description of Darwin_9_Long_Double_Funcs_2 fix
@@ -2741,6 +2786,124 @@ static const char* apzDarwin_Longjmp_NoreturnPatch[] = {
     "%1 __attribute__ ((__noreturn__));",
     (char*)NULL };
 
+/* * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Description of Darwin_Os_Trace_1 fix
+ */
+tSCC zDarwin_Os_Trace_1Name[] =
+     "darwin_os_trace_1";
+
+/*
+ *  File name selection pattern
+ */
+tSCC zDarwin_Os_Trace_1List[] =
+  "os/trace.h\0";
+/*
+ *  Machine/OS name selection pattern
+ */
+tSCC* apzDarwin_Os_Trace_1Machs[] = {
+        "*-*-darwin*",
+        (const char*)NULL };
+
+/*
+ *  content selection pattern - do fix if pattern found
+ */
+tSCC zDarwin_Os_Trace_1Select0[] =
+       "^(_os_trace_verify_printf.*) (__attribute__.*)";
+
+#define    DARWIN_OS_TRACE_1_TEST_CT  1
+static tTestDesc aDarwin_Os_Trace_1Tests[] = {
+  { TT_EGREP,    zDarwin_Os_Trace_1Select0, (regex_t*)NULL }, };
+
+/*
+ *  Fix Command Arguments for Darwin_Os_Trace_1
+ */
+static const char* apzDarwin_Os_Trace_1Patch[] = {
+    "format",
+    "%1",
+    (char*)NULL };
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Description of Darwin_Os_Trace_2 fix
+ */
+tSCC zDarwin_Os_Trace_2Name[] =
+     "darwin_os_trace_2";
+
+/*
+ *  File name selection pattern
+ */
+tSCC zDarwin_Os_Trace_2List[] =
+  "os/trace.h\0";
+/*
+ *  Machine/OS name selection pattern
+ */
+tSCC* apzDarwin_Os_Trace_2Machs[] = {
+        "*-*-darwin*",
+        (const char*)NULL };
+
+/*
+ *  content selection pattern - do fix if pattern found
+ */
+tSCC zDarwin_Os_Trace_2Select0[] =
+       "typedef.*\\^os_trace_payload_t.*";
+
+#define    DARWIN_OS_TRACE_2_TEST_CT  1
+static tTestDesc aDarwin_Os_Trace_2Tests[] = {
+  { TT_EGREP,    zDarwin_Os_Trace_2Select0, (regex_t*)NULL }, };
+
+/*
+ *  Fix Command Arguments for Darwin_Os_Trace_2
+ */
+static const char* apzDarwin_Os_Trace_2Patch[] = {
+    "format",
+    "#if __BLOCKS__\n\
+%0\n\
+#endif",
+    (char*)NULL };
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Description of Darwin_Os_Trace_3 fix
+ */
+tSCC zDarwin_Os_Trace_3Name[] =
+     "darwin_os_trace_3";
+
+/*
+ *  File name selection pattern
+ */
+tSCC zDarwin_Os_Trace_3List[] =
+  "os/trace.h\0";
+/*
+ *  Machine/OS name selection pattern
+ */
+tSCC* apzDarwin_Os_Trace_3Machs[] = {
+        "*-*-darwin*",
+        (const char*)NULL };
+
+/*
+ *  content selection pattern - do fix if pattern found
+ */
+tSCC zDarwin_Os_Trace_3Select0[] =
+       "__(API|OSX)_.*\n\
+OS_EXPORT.*\n\
+.*\n\
+_os_trace.*os_trace_payload_t payload);";
+
+#define    DARWIN_OS_TRACE_3_TEST_CT  1
+static tTestDesc aDarwin_Os_Trace_3Tests[] = {
+  { TT_EGREP,    zDarwin_Os_Trace_3Select0, (regex_t*)NULL }, };
+
+/*
+ *  Fix Command Arguments for Darwin_Os_Trace_3
+ */
+static const char* apzDarwin_Os_Trace_3Patch[] = {
+    "format",
+    "#if __BLOCKS__\n\
+%0\n\
+#endif",
+    (char*)NULL };
+
 /* * * * * * * * * * * * * * * * * * * * * * * * * *
  *
  *  Description of Darwin_Private_Extern fix
@@ -9714,9 +9877,9 @@ static const char* apzX11_SprintfPatch[] = {
  *
  *  List of all fixes
  */
-#define REGEX_COUNT          275
+#define REGEX_COUNT          279
 #define MACH_LIST_SIZE_LIMIT 187
-#define FIX_COUNT            237
+#define FIX_COUNT            241
 
 /*
  *  Enumerate the fixes
@@ -9781,10 +9944,14 @@ typedef enum {
     CTRL_QUOTES_DEF_FIXIDX,
     CTRL_QUOTES_USE_FIXIDX,
     CXX_UNREADY_FIXIDX,
+    DARWIN_AVAILABILITYINTERNAL_FIXIDX,
     DARWIN_9_LONG_DOUBLE_FUNCS_2_FIXIDX,
     DARWIN_EXTERNC_FIXIDX,
     DARWIN_GCC4_BREAKAGE_FIXIDX,
     DARWIN_LONGJMP_NORETURN_FIXIDX,
+    DARWIN_OS_TRACE_1_FIXIDX,
+    DARWIN_OS_TRACE_2_FIXIDX,
+    DARWIN_OS_TRACE_3_FIXIDX,
     DARWIN_PRIVATE_EXTERN_FIXIDX,
     DARWIN_STDINT_1_FIXIDX,
     DARWIN_STDINT_2_FIXIDX,
@@ -10257,6 +10424,11 @@ tFixDesc fixDescList[ FIX_COUNT ] = {
      CXX_UNREADY_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
      aCxx_UnreadyTests,   apzCxx_UnreadyPatch, 0 },
 
+  {  zDarwin_AvailabilityinternalName,    zDarwin_AvailabilityinternalList,
+     apzDarwin_AvailabilityinternalMachs,
+     DARWIN_AVAILABILITYINTERNAL_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
+     aDarwin_AvailabilityinternalTests,   apzDarwin_AvailabilityinternalPatch, 0 },
+
   {  zDarwin_9_Long_Double_Funcs_2Name,    zDarwin_9_Long_Double_Funcs_2List,
      apzDarwin_9_Long_Double_Funcs_2Machs,
      DARWIN_9_LONG_DOUBLE_FUNCS_2_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
@@ -10277,6 +10449,21 @@ tFixDesc fixDescList[ FIX_COUNT ] = {
      DARWIN_LONGJMP_NORETURN_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
      aDarwin_Longjmp_NoreturnTests,   apzDarwin_Longjmp_NoreturnPatch, 0 },
 
+  {  zDarwin_Os_Trace_1Name,    zDarwin_Os_Trace_1List,
+     apzDarwin_Os_Trace_1Machs,
+     DARWIN_OS_TRACE_1_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
+     aDarwin_Os_Trace_1Tests,   apzDarwin_Os_Trace_1Patch, 0 },
+
+  {  zDarwin_Os_Trace_2Name,    zDarwin_Os_Trace_2List,
+     apzDarwin_Os_Trace_2Machs,
+     DARWIN_OS_TRACE_2_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
+     aDarwin_Os_Trace_2Tests,   apzDarwin_Os_Trace_2Patch, 0 },
+
+  {  zDarwin_Os_Trace_3Name,    zDarwin_Os_Trace_3List,
+     apzDarwin_Os_Trace_3Machs,
+     DARWIN_OS_TRACE_3_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
+     aDarwin_Os_Trace_3Tests,   apzDarwin_Os_Trace_3Patch, 0 },
+
   {  zDarwin_Private_ExternName,    zDarwin_Private_ExternList,
      apzDarwin_Private_ExternMachs,
      DARWIN_PRIVATE_EXTERN_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
index 1183b590f4496f55bcd21f52232354c228c52c05..931161b69ce8ddc6241a65540eef5ed42959dc53 100644 (file)
@@ -1337,6 +1337,32 @@ fix = {
     test_text = "extern void* malloc( size_t );";
 };
 
+/*
+ *  macOS 10.12 <AvailabilityInternal.h> uses __attribute__((availability))
+ *  unconditionally.
+ */
+fix = {
+    hackname  = darwin_availabilityinternal;
+    mach      = "*-*-darwin*";
+    files     = AvailabilityInternal.h;
+    select    = "#define[ \t]+(__API_[ADU]\\([^)]*\\)).*";
+    c_fix     = format;
+    c_fix_arg = <<- _EOFix_
+       #if defined(__has_attribute)
+         #if __has_attribute(availability)
+       %0
+         #else
+           #define %1
+         #endif
+       #else
+           #define %1
+       #endif
+       _EOFix_;
+
+    test_text = "#define __API_A(x) __attribute__((availability(__API_AVAILABLE_PLATFORM_##x)))\n"
+               "#define __API_D(msg,x) __attribute__((availability(__API_DEPRECATED_PLATFORM_##x,message=msg)))";
+};
+
 /*
  *  For the AAB_darwin7_9_long_double_funcs fix to be useful,
  *  you have to not use "" includes.
@@ -1409,6 +1435,62 @@ fix = {
     test_text = "void siglongjmp(sigjmp_buf, int);";
 };
 
+/*
+ *  Mac OS X 10.11 <os/trace.h> uses attribute on function definition.
+ */
+fix = {
+  hackname  = darwin_os_trace_1;
+  mach      = "*-*-darwin*";
+  files     = os/trace.h;
+  select    = "^(_os_trace_verify_printf.*) (__attribute__.*)";
+  c_fix     = format;
+  c_fix_arg = "%1";
+  test_text = "_os_trace_verify_printf(const char *msg, ...) __attribute__((format(printf, 1, 2)))";
+};
+
+/*
+ *  Mac OS X 10.1[012] <os/trace.h> os_trace_payload_t typedef uses Blocks
+ *  extension without guard.
+ */
+fix = {
+  hackname  = darwin_os_trace_2;
+  mach      = "*-*-darwin*";
+  files     = os/trace.h;
+  select    = "typedef.*\\^os_trace_payload_t.*";
+  c_fix     = format;
+  c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
+  test_text = "typedef void (^os_trace_payload_t)(xpc_object_t xdict);";
+};
+
+/*
+ *  In Mac OS X 10.1[012] <os/trace.h>, need to guard users of
+ *  os_trace_payload_t typedef, too.
+ */
+fix = {
+  hackname  = darwin_os_trace_3;
+  mach      = "*-*-darwin*";
+  files     = os/trace.h;
+  select    = <<- _EOSelect_
+       __(API|OSX)_.*
+       OS_EXPORT.*
+       .*
+       _os_trace.*os_trace_payload_t payload);
+       _EOSelect_;
+  c_fix     = format;
+  c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
+  test_text = <<- _EOText_
+       __API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(8.0))
+       OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
+       void
+       _os_trace_with_buffer(void *dso, const char *message, uint8_t type, const void *buffer, size_t buffer_size, os_trace_payload_t payload);
+
+       __OSX_AVAILABLE_STARTING(__MAC_10_12, __IPHONE_10_0)
+       OS_EXPORT OS_NOTHROW
+       void
+       _os_trace_internal(void *dso, uint8_t type, const char *format, const uint8_t *buf, size_t buf_size, os_trace_payload_t payload);
+       _EOText_;
+};
+
 /*
  *  __private_extern__ doesn't exist in FSF GCC.  Even if it did,
  *  why would you ever put it in a system header file?
@@ -2638,7 +2720,6 @@ fix = {
     c-fix-arg = "#  define     UINT_%164_MAX   __UINT64_MAX__";
     test-text = "#  define       UINT_FAST64_MAX        ULLONG_MAX\n"
                "#  define       UINT_LEAST64_MAX        ULLONG_MAX\n";
-       _EOFix_;
 };
 
 /*
diff --git a/fixincludes/tests/base/AvailabilityInternal.h b/fixincludes/tests/base/AvailabilityInternal.h
new file mode 100644 (file)
index 0000000..60b3503
--- /dev/null
@@ -0,0 +1,31 @@
+/*  DO NOT EDIT THIS FILE.
+
+    It has been auto-edited by fixincludes from:
+
+       "fixinc/tests/inc/AvailabilityInternal.h"
+
+    This had to be done to correct non-standard usages in the
+    original, manufacturer supplied header file.  */
+
+
+
+#if defined( DARWIN_AVAILABILITYINTERNAL_CHECK )
+#if defined(__has_attribute)
+  #if __has_attribute(availability)
+#define __API_A(x) __attribute__((availability(__API_AVAILABLE_PLATFORM_##x)))
+  #else
+    #define __API_A(x)
+  #endif
+#else
+    #define __API_A(x)
+#endif
+#if defined(__has_attribute)
+  #if __has_attribute(availability)
+#define __API_D(msg,x) __attribute__((availability(__API_DEPRECATED_PLATFORM_##x,message=msg)))
+  #else
+    #define __API_D(msg,x)
+  #endif
+#else
+    #define __API_D(msg,x)
+#endif
+#endif  /* DARWIN_AVAILABILITYINTERNAL_CHECK */
diff --git a/fixincludes/tests/base/os/trace.h b/fixincludes/tests/base/os/trace.h
new file mode 100644 (file)
index 0000000..fdbf1a8
--- /dev/null
@@ -0,0 +1,38 @@
+/*  DO NOT EDIT THIS FILE.
+
+    It has been auto-edited by fixincludes from:
+
+       "fixinc/tests/inc/os/trace.h"
+
+    This had to be done to correct non-standard usages in the
+    original, manufacturer supplied header file.  */
+
+
+
+#if defined( DARWIN_OS_TRACE_1_CHECK )
+_os_trace_verify_printf(const char *msg, ...)
+#endif  /* DARWIN_OS_TRACE_1_CHECK */
+
+
+#if defined( DARWIN_OS_TRACE_2_CHECK )
+#if __BLOCKS__
+typedef void (^os_trace_payload_t)(xpc_object_t xdict);
+#endif
+#endif  /* DARWIN_OS_TRACE_2_CHECK */
+
+
+#if defined( DARWIN_OS_TRACE_3_CHECK )
+#if __BLOCKS__
+__API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(8.0))
+OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
+void
+_os_trace_with_buffer(void *dso, const char *message, uint8_t type, const void *buffer, size_t buffer_size, os_trace_payload_t payload);
+#endif
+
+#if __BLOCKS__
+__OSX_AVAILABLE_STARTING(__MAC_10_12, __IPHONE_10_0)
+OS_EXPORT OS_NOTHROW
+void
+_os_trace_internal(void *dso, uint8_t type, const char *format, const uint8_t *buf, size_t buf_size, os_trace_payload_t payload);
+#endif
+#endif  /* DARWIN_OS_TRACE_3_CHECK */
index 844f532d46d7d3ad3cc5a77775157f23c99f8b23..5ac40280fd96bb08db22df65f4f4a5db4eae137e 100644 (file)
@@ -1,3 +1,9 @@
+2016-11-20  Jack Howarth  <howarth.at.gcc@gmail.com>
+
+       PR sanitizer/78267
+       * sanitizer_common/sanitizer_mac.cc: Include <os/trace.h> only if
+       compiler supports blocks extension.
+
 2016-11-16  Markus Trippelsdorf  <markus@trippelsdorf.de>
 
        * LOCAL_PATCHES: Add revision.
index 4408d1dccb961d82e9cb1c859a9547ad570d8f38..62be7b0b15e7a0c2b6901ce05335f0241295e512 100644 (file)
@@ -34,7 +34,7 @@
 extern char **environ;
 #endif
 
-#if defined(__has_include) && __has_include(<os/trace.h>)
+#if defined(__has_include) && __has_include(<os/trace.h>) && defined(__BLOCKS__)
 #define SANITIZER_OS_TRACE 1
 #include <os/trace.h>
 #else