From: Iain Sandoe <iainsandoe@mini-05-seq.local>

Tested on x86_64/aarch64 Darwin and x86_64-linux,
OK for trunk?
backports to branches supporting modules?
thanks
Iain

--- 8< ---

Recent changes to the OS SDKs have altered the way in which include guards
are used for a number of headers when C++ modules are enabled.  Instead of
placing the guards in the included header, they are being placed in the
including header.  This breaks the assumptions in the current GCC stddef.h
specifically, that the presence of __PTRDIFF_T and __SIZE_T means that the
relevant defs are already made.  However in the case of the module-enabled
C++ with these SDKs, that is no longer true.

stddef.h has a large body of special-cases already, but it seems that the
only viable solution here is to add a new one specifically for __APPLE__
and modular code.

This fixes around 280 new fails in the modules test-suite; it is needed on
all open branches that support modules.

        PR target/116827

gcc/ChangeLog:

        * ginclude/stddef.h: Undefine __PTRDIFF_T and __SIZE_T for module-
        enabled c++ on Darwin/macOS platforms.

Signed-off-by: Iain Sandoe <i...@sandoe.co.uk>
---
 gcc/ginclude/stddef.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/gcc/ginclude/stddef.h b/gcc/ginclude/stddef.h
index 0d53103ce20..bf9c6e609dc 100644
--- a/gcc/ginclude/stddef.h
+++ b/gcc/ginclude/stddef.h
@@ -89,6 +89,17 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If 
not, see
 #undef _PTRDIFF_T_
 #endif
 
+#if defined (__APPLE__)
+# if defined(__has_feature) && __has_feature(modules)
+#  if defined (__need_ptrdiff_t)
+#   undef __PTRDIFF_T
+#  endif
+#  if defined (__need_size_t)
+#   undef __SIZE_T
+#  endif
+# endif
+#endif
+
 /* On VxWorks, <type/vxTypesBase.h> may have defined macros like
    _TYPE_size_t which will typedef size_t.  fixincludes patched the
    vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is
-- 
2.39.2 (Apple Git-143)

Reply via email to