public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [fixincludes] Fix macOS 10.12 <AvailabilityInternal.h> and <os/trace.h> (PR sanitizer/78267)
@ 2016-11-11 10:15 Rainer Orth
  2016-11-11 11:19 ` Mike Stump
       [not found] ` <CAJMcOU-k7qAJC9qpPo1ybTjWpsP7aEQGgZLwaOWomoVqMyMn8A@mail.gmail.com>
  0 siblings, 2 replies; 19+ messages in thread
From: Rainer Orth @ 2016-11-11 10:15 UTC (permalink / raw)
  To: gcc-patches; +Cc: Bruce Korb

[-- Attachment #1: Type: text/plain, Size: 2071 bytes --]

Since the recent libsanitizer import, macOS 10.12 bootstrap is broken:

* <os/trace.h> unconditionally uses the Blocks extension only support by
  Clang without the customary #if __BLOCKS__ guard:

In file included from /vol/gcc/src/hg/trunk/local/libsanitizer/sanitizer_common/sanitizer_mac.cc:39:0:
/usr/include/os/trace.h:204:15: error: expected unqualified-id before '^' token
 typedef void (^os_trace_payload_t)(xpc_object_t xdict);
               ^
/usr/include/os/trace.h:204:15: error: expected ')' before '^' token
In file included from /usr/include/Availability.h:184:0,
                 from /usr/include/stdio.h:65,
                 from /vol/gcc/src/hg/trunk/local/libsanitizer/sanitizer_common/sanitizer_mac.cc:21:

  To fix this, I wrap both the typedef and its single user.

* <AvailabilityInternal.h> uses the __attribute__((availability))
  extension unconditionally instead of wrapping it as is done in many
  other places:

In file included from /usr/include/Availability.h:184:0,
                 from /usr/include/stdio.h:65,
                 from /vol/gcc/src/hg/trunk/local/libsanitizer/sanitizer_common/sanitizer_mac.cc:21:
/var/gcc/regression/trunk/10.12-gcc/build/./gcc/include-fixed/os/trace.h:304:1: error: 'introduced' was not declared in this scope
 __API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
 ^

  I'm wrapping the internal __API_[ADU] macros as is done elsewhere.

* I came across a dangling _EOFix_.

The patch passes fixincludes make check (this time for real ;-) and
restores macOS 10.12 bootstrap.

Ok for mainline?

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2016-11-10  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	PR sanitizer/78267
	* inclhack.def (darwin_availabilityinternal, darwin_os_trace_1)
	(darwin_os_trace_2): 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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: macos-fixincludes-AvailabilityInternal.patch --]
[-- Type: text/x-patch, Size: 4626 bytes --]

# HG changeset patch
# Parent  38420045cf6aa616f517ca5fcfd15f2b55e68cf0
Fix macOS 10.12 <AvailabilityInternal.h> and <os/trace.h> (PR sanitizer/78267)

diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def
--- a/fixincludes/inclhack.def
+++ b/fixincludes/inclhack.def
@@ -1338,6 +1338,32 @@ fix = {
 };
 
 /*
+ *  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.
  */
@@ -1410,6 +1436,44 @@ fix = {
 };
 
 /*
+ *  macOS 10.12 <os/trace.h> os_trace_payload_t typedef uses Blocks
+ *  extension without guard.
+ */
+fix = {
+  hackname  = darwin_os_trace_1;
+  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 macOS 10.12 <os/trace.h>, need to guard users of os_trace_payload_t
+ *  typedef, too.
+ */
+fix = {
+  hackname  = darwin_os_trace_2;
+  mach      = "*-*-darwin*";
+  files     = os/trace.h;
+  select    = <<- _EOSelect_
+	__API_.*
+	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);
+	_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 +2702,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
--- /dev/null
+++ b/fixincludes/tests/base/AvailabilityInternal.h
@@ -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
--- /dev/null
+++ b/fixincludes/tests/base/os/trace.h
@@ -0,0 +1,26 @@
+/*  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 )
+#if __BLOCKS__
+typedef void (^os_trace_payload_t)(xpc_object_t xdict);
+#endif
+#endif  /* DARWIN_OS_TRACE_1_CHECK */
+
+
+#if defined( DARWIN_OS_TRACE_2_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
+#endif  /* DARWIN_OS_TRACE_2_CHECK */

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2016-11-21  9:55 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-11 10:15 [fixincludes] Fix macOS 10.12 <AvailabilityInternal.h> and <os/trace.h> (PR sanitizer/78267) Rainer Orth
2016-11-11 11:19 ` Mike Stump
2016-11-11 16:17   ` Iain Sandoe
2016-11-11 16:50     ` Rainer Orth
2016-11-11 16:58       ` Iain Sandoe
2016-11-11 17:01         ` Rainer Orth
2016-11-11 21:25   ` Bruce Korb
2016-11-18 10:45     ` Rainer Orth
2016-11-18 17:23       ` Bruce Korb
2016-11-18 17:42       ` Mike Stump
2016-11-18 19:25         ` Bruce Korb
2016-11-21  9:55           ` Rainer Orth
2016-11-21  9:52         ` Rainer Orth
     [not found] ` <CAJMcOU-k7qAJC9qpPo1ybTjWpsP7aEQGgZLwaOWomoVqMyMn8A@mail.gmail.com>
2016-11-13 10:53   ` Rainer Orth
     [not found]     ` <CAJMcOU93wuAXjLz7fRR1vRmgXn-BU7ajcOafxUWRfd1Rs4jk5g@mail.gmail.com>
2016-11-13 18:24       ` Fwd: " Jack Howarth
2016-11-14 14:11       ` Rainer Orth
2016-11-14 18:56         ` Jack Howarth
     [not found]       ` <CAJMcOU8m_8oCKpV4RD=1wo=PEs9fBcP52gyD1wtsO4B1v85dfQ@mail.gmail.com>
     [not found]         ` <5829b908.03a3620a.24461.716eSMTPIN_ADDED_MISSING@mx.google.com>
2016-11-14 13:19           ` Fwd: failure notice Jack Howarth
2016-11-14 14:22         ` [fixincludes] Fix macOS 10.12 <AvailabilityInternal.h> and <os/trace.h> (PR sanitizer/78267) Rainer Orth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).