[libc++] Ensure streams are initialized early
When statically linking libc++ on some systems, the streams are not
initialized early enough, which causes all kinds of issues. This was
reported e.g. in http://llvm.org/PR28954, but also in various open
source projects that use libc++.
Fixes http://llvm.org/PR28954.
Differential Revision: https://reviews.llvm.org/D31413
Cr-Mirrored-From: https://chromium.googlesource.com/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 39faf428164a28f3652370958ce893d9200927c8
diff --git a/src/iostream.cpp b/src/iostream.cpp
index ad1920a..d088593 100644
--- a/src/iostream.cpp
+++ b/src/iostream.cpp
@@ -77,7 +77,7 @@
#endif
;
-_LIBCPP_HIDDEN ios_base::Init __start_std_streams;
+_LIBCPP_HIDDEN ios_base::Init __start_std_streams __attribute__((init_priority(101)));
// 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