[libcxx-commits] [PATCH] D74885: [libcxx] Construct __start_std_streams at high init priority
Sam Clegg via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Feb 19 19:56:33 PST 2020
sbc100 created this revision.
Herald added a reviewer: EricWF.
Herald added subscribers: libcxx-commits, ldionne, aheejin.
Herald added a project: libc++.
This allows normal static constructors use use std::cout, etc.
We've been patching this in emscripten for a long time now. Perhaps
there is some reason not have this upstream? Does it currently work
on other platforms without this?
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D74885
Files:
libcxx/src/iostream.cpp
Index: libcxx/src/iostream.cpp
===================================================================
--- libcxx/src/iostream.cpp
+++ libcxx/src/iostream.cpp
@@ -77,7 +77,17 @@
#endif
;
-_LIBCPP_HIDDEN ios_base::Init __start_std_streams;
+// Detect if the init_priority attribute is supported.
+#if (defined(_LIBCPP_COMPILER_GCC) && defined(__APPLE__)) \
+ || defined(_LIBCPP_COMPILER_MSVC)
+// GCC on Apple doesn't support the init priority attribute,
+// and MSVC doesn't support any GCC attributes.
+# define _LIBCPP_INIT_PRIORITY_MAX
+#else
+# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101)))
+#endif
+
+_LIBCPP_HIDDEN ios_base::Init __start_std_streams _LIBCPP_INIT_PRIORITY_MAX;
// 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74885.245569.patch
Type: text/x-patch
Size: 876 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200220/473a21d3/attachment.bin>
More information about the libcxx-commits
mailing list