[libcxx-commits] [PATCH] D95972: [libc++] Use init_priority(100) when possible
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Feb 8 07:52:35 PST 2021
ldionne updated this revision to Diff 322110.
ldionne added a comment.
Try to fix the build by pretending we're in a system header.
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
@@ -77,7 +77,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,12 +76,7 @@
~ResourceInitHelper() {}
};
-// When compiled in C++14 this initialization should be a constant expression.
-// Only in C++11 is "init_priority" needed to ensure initialization order.
-#if _LIBCPP_STD_VER > 11
-_LIBCPP_SAFE_STATIC
-#endif
-ResourceInitHelper res_init _LIBCPP_INIT_PRIORITY_MAX;
+_LIBCPP_SAFE_STATIC ResourceInitHelper res_init;
} // end namespace
Index: libcxx/include/__config
===================================================================
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -1440,7 +1440,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.322110.patch
Type: text/x-patch
Size: 2068 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210208/654116cb/attachment-0001.bin>
More information about the libcxx-commits
mailing list