[libcxx-commits] [PATCH] D95972: [libc++] Use init_priority(100) when possible

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Oct 6 08:23:29 PDT 2021


ldionne updated this revision to Diff 377557.
ldionne added a comment.

Fix oversight in memory_resource.cpp


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95972/new/

https://reviews.llvm.org/D95972

Files:
  libcxx/include/__config
  libcxx/src/experimental/memory_resource.cpp
  libcxx/src/iostream.cpp


Index: libcxx/src/iostream.cpp
===================================================================
--- libcxx/src/iostream.cpp
+++ libcxx/src/iostream.cpp
@@ -73,7 +73,12 @@
 #endif
 ;
 
+// Hacky way to make the compiler believe that we're inside a system header so
+// it doesn't flag the use of the init_priority attribute with a value that's
+// reserved for the implementation (we're the implementation).
+# 80 "iostream.cpp" 1 3
 _LIBCPP_HIDDEN ios_base::Init __start_std_streams _LIBCPP_INIT_PRIORITY_MAX;
+# 82 "iostream.cpp" 2
 
 // On Windows the TLS storage for locales needs to be initialized before we create
 // the standard streams, otherwise it may not be alive during program termination
Index: libcxx/src/experimental/memory_resource.cpp
===================================================================
--- libcxx/src/experimental/memory_resource.cpp
+++ libcxx/src/experimental/memory_resource.cpp
@@ -76,7 +76,9 @@
   ~ResourceInitHelper() {}
 };
 
+# 79 "memory_resource.cpp" 1 3
 _LIBCPP_SAFE_STATIC ResourceInitHelper res_init _LIBCPP_INIT_PRIORITY_MAX;
+# 81 "memory_resource.cpp" 2
 
 } // end namespace
 
Index: libcxx/include/__config
===================================================================
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -1330,7 +1330,13 @@
 #endif
 
 #if __has_attribute(init_priority)
-# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101)))
+    // TODO: Remove this once we drop support for building libc++ with old Clangs
+#   if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1200) || \
+       (defined(__apple_build_version__) && __apple_build_version__ < 13000000)
+#     define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101)))
+#   else
+#     define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(100)))
+#   endif
 #else
 # define _LIBCPP_INIT_PRIORITY_MAX
 #endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95972.377557.patch
Type: text/x-patch
Size: 1888 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211006/8473ec22/attachment.bin>


More information about the libcxx-commits mailing list