diff --git a/libcxx/include/__config b/libcxx/include/__config --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -1435,6 +1435,15 @@ #define _LIBCPP_HAS_NO_FGETPOS_FSETPOS #endif +// Detect if the init_priority attribute is supported. +// GCC on Apple doesn't support the init priority attribute,same for MSVC z/OS. +#if (defined(_LIBCPP_COMPILER_GCC) && defined(__APPLE__)) \ + || defined(_LIBCPP_COMPILER_MSVC) || defined(__MVS__) +# define _LIBCPP_INIT_PRIORITY_MAX +#else +# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101))) +#endif + #endif // __cplusplus #endif // _LIBCPP_CONFIG diff --git a/libcxx/src/iostream.cpp b/libcxx/src/iostream.cpp --- a/libcxx/src/iostream.cpp +++ b/libcxx/src/iostream.cpp @@ -77,7 +77,7 @@ #endif ; -_LIBCPP_HIDDEN ios_base::Init __start_std_streams __attribute__((init_priority(101))); +_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