[libcxx-commits] [libcxx] 3f65c8f - Revert "[libc++] Remove workarounds for systems that used to require __need_XXX macros"

Yi Kong via libcxx-commits libcxx-commits at lists.llvm.org
Tue Nov 22 03:46:53 PST 2022


Author: Yi Kong
Date: 2022-11-22T20:46:38+09:00
New Revision: 3f65c8fcbe4ed4886500a0b9b939a363b70a43c3

URL: https://github.com/llvm/llvm-project/commit/3f65c8fcbe4ed4886500a0b9b939a363b70a43c3
DIFF: https://github.com/llvm/llvm-project/commit/3f65c8fcbe4ed4886500a0b9b939a363b70a43c3.diff

LOG: Revert "[libc++] Remove workarounds for systems that used to require __need_XXX macros"

This reverts commit 119cef40d18c48240854edc553dca61c4e9fdf27.

The change broke multiple builders.

Added: 
    

Modified: 
    libcxx/include/ext/__hash
    libcxx/include/module.modulemap.in
    libcxx/include/stdbool.h
    libcxx/include/stddef.h
    libcxx/include/stdio.h
    libcxx/include/stdlib.h
    libcxx/include/wchar.h

Removed: 
    


################################################################################
diff  --git a/libcxx/include/ext/__hash b/libcxx/include/ext/__hash
index 880d0eebef490..0e6c2cc05b529 100644
--- a/libcxx/include/ext/__hash
+++ b/libcxx/include/ext/__hash
@@ -14,7 +14,6 @@
 
 #include <__config>
 #include <cstring>
-#include <stddef.h>
 #include <string>
 
 namespace __gnu_cxx {

diff  --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index bc4526b5d05d8..5f07d9df0a59b 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -75,12 +75,14 @@ module std [system] {
       export Darwin.C.stdint
     }
     module stdio_h {
-      header "stdio.h"
+      // <stdio.h>'s __need_* macros require textual inclusion.
+      textual header "stdio.h"
       export *
       export Darwin.C.stdio
     }
     module stdlib_h {
-      header "stdlib.h"
+      // <stdlib.h>'s __need_* macros require textual inclusion.
+      textual header "stdlib.h"
       export *
     }
     module string_h {
@@ -94,7 +96,8 @@ module std [system] {
     // <time.h> provided by C library.
     module wchar_h {
       @requires_LIBCXX_ENABLE_WIDE_CHARACTERS@
-      header "wchar.h"
+      // <wchar.h>'s __need_* macros require textual inclusion.
+      textual header "wchar.h"
       export *
     }
     module wctype_h {

diff  --git a/libcxx/include/stdbool.h b/libcxx/include/stdbool.h
index 74869b46d5614..5bba00568dffc 100644
--- a/libcxx/include/stdbool.h
+++ b/libcxx/include/stdbool.h
@@ -6,7 +6,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-
 #ifndef _LIBCPP_STDBOOL_H
 #define _LIBCPP_STDBOOL_H
 

diff  --git a/libcxx/include/stddef.h b/libcxx/include/stddef.h
index e97100b2f8c39..f1725db062125 100644
--- a/libcxx/include/stddef.h
+++ b/libcxx/include/stddef.h
@@ -7,7 +7,16 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef _LIBCPP_STDDEF_H
+#if defined(__need_ptr
diff _t) || defined(__need_size_t) || \
+    defined(__need_wchar_t) || defined(__need_NULL) || defined(__need_wint_t)
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#include_next <stddef.h>
+
+#elif !defined(_LIBCPP_STDDEF_H)
 #define _LIBCPP_STDDEF_H
 
 /*
@@ -33,38 +42,9 @@
 #  pragma GCC system_header
 #endif
 
-#if __has_include_next(<stddef.h>)
-    // The Clang builtin headers only define the types we need when we request it explicitly.
-    // TODO: We should fix that in Clang and drop these defines.
-#  ifndef __need_ptr
diff _t
-#    define __need_ptr
diff _t
-#  endif
-#  ifndef __need_size_t
-#    define __need_size_t
+#  if __has_include_next(<stddef.h>)
+#    include_next <stddef.h>
 #  endif
-#  ifndef __need_wchar_t
-#    define __need_wchar_t
-#  endif
-#  ifndef __need_NULL
-#    define __need_NULL
-#  endif
-#  ifndef __need_STDDEF_H_misc
-#    define __need_STDDEF_H_misc
-#  endif
-
-#  include_next <stddef.h>
-
-    // Now re-include the header without requesting any specific types, so as to get
-    // any other remaining types from stddef.h. This can all go away once the Clang
-    // buitin headers stop using these macros.
-#  undef __need_ptr
diff _t
-#  undef __need_size_t
-#  undef __need_wchar_t
-#  undef __need_NULL
-#  undef __need_STDDEF_H_misc
-
-#  include_next <stddef.h>
-#endif
 
 #ifdef __cplusplus
     typedef decltype(nullptr) nullptr_t;

diff  --git a/libcxx/include/stdio.h b/libcxx/include/stdio.h
index 4ca40df2b5269..cea43aa7680bc 100644
--- a/libcxx/include/stdio.h
+++ b/libcxx/include/stdio.h
@@ -7,7 +7,15 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef _LIBCPP_STDIO_H
+#if defined(__need_FILE) || defined(__need___FILE)
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#include_next <stdio.h>
+
+#elif !defined(_LIBCPP_STDIO_H)
 #define _LIBCPP_STDIO_H
 
 /*

diff  --git a/libcxx/include/stdlib.h b/libcxx/include/stdlib.h
index 1c990c162956c..64581b67f245f 100644
--- a/libcxx/include/stdlib.h
+++ b/libcxx/include/stdlib.h
@@ -7,7 +7,15 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef _LIBCPP_STDLIB_H
+#if defined(__need_malloc_and_calloc)
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#include_next <stdlib.h>
+
+#elif !defined(_LIBCPP_STDLIB_H)
 #define _LIBCPP_STDLIB_H
 
 /*

diff  --git a/libcxx/include/wchar.h b/libcxx/include/wchar.h
index d34ed4d3a1cf2..c684508dc2ccd 100644
--- a/libcxx/include/wchar.h
+++ b/libcxx/include/wchar.h
@@ -7,7 +7,15 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef _LIBCPP_WCHAR_H
+#if defined(__need_wint_t) || defined(__need_mbstate_t)
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#include_next <wchar.h>
+
+#elif !defined(_LIBCPP_WCHAR_H)
 #define _LIBCPP_WCHAR_H
 
 /*


        


More information about the libcxx-commits mailing list