-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[libc++][modules] Guard carved-out headers more consistently #108637
[libc++][modules] Guard carved-out headers more consistently #108637
Conversation
Several headers that should not be provided when localization or threads are disabled were not guarded. That works until one tries to build with modules and these headers get pulled in. Note that this could be cleaned up further into something more systematic, but this patch solves the immediate problems I ran into with the monolithic modulemap and doesn't create any new inconsistency that wasn't already there.
@llvm/pr-subscribers-libcxx Author: Louis Dionne (ldionne) ChangesSeveral headers that should not be provided when localization or threads are disabled were not guarded. That works until one tries to build with modules and these headers get pulled in. Note that this could be cleaned up further into something more systematic, but this patch solves the immediate problems I ran into with the monolithic modulemap and doesn't create any new inconsistency that wasn't already there. Patch is 108.41 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/108637.diff 15 Files Affected:
diff --git a/libcxx/include/__chrono/formatter.h b/libcxx/include/__chrono/formatter.h
index 449c415e957602..ff2593f7230292 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -10,55 +10,58 @@
#ifndef _LIBCPP___CHRONO_FORMATTER_H
#define _LIBCPP___CHRONO_FORMATTER_H
-#include <__algorithm/ranges_copy.h>
-#include <__chrono/calendar.h>
-#include <__chrono/concepts.h>
-#include <__chrono/convert_to_tm.h>
-#include <__chrono/day.h>
-#include <__chrono/duration.h>
-#include <__chrono/file_clock.h>
-#include <__chrono/hh_mm_ss.h>
-#include <__chrono/local_info.h>
-#include <__chrono/month.h>
-#include <__chrono/month_weekday.h>
-#include <__chrono/monthday.h>
-#include <__chrono/ostream.h>
-#include <__chrono/parser_std_format_spec.h>
-#include <__chrono/statically_widen.h>
-#include <__chrono/sys_info.h>
-#include <__chrono/system_clock.h>
-#include <__chrono/time_point.h>
-#include <__chrono/weekday.h>
-#include <__chrono/year.h>
-#include <__chrono/year_month.h>
-#include <__chrono/year_month_day.h>
-#include <__chrono/year_month_weekday.h>
-#include <__chrono/zoned_time.h>
-#include <__concepts/arithmetic.h>
-#include <__concepts/same_as.h>
#include <__config>
-#include <__format/concepts.h>
-#include <__format/format_error.h>
-#include <__format/format_functions.h>
-#include <__format/format_parse_context.h>
-#include <__format/formatter.h>
-#include <__format/parser_std_format_spec.h>
-#include <__format/write_escaped.h>
-#include <__memory/addressof.h>
-#include <__type_traits/is_specialization.h>
-#include <cmath>
-#include <ctime>
-#include <limits>
-#include <sstream>
-#include <string_view>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-#endif
+
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+
+# include <__algorithm/ranges_copy.h>
+# include <__chrono/calendar.h>
+# include <__chrono/concepts.h>
+# include <__chrono/convert_to_tm.h>
+# include <__chrono/day.h>
+# include <__chrono/duration.h>
+# include <__chrono/file_clock.h>
+# include <__chrono/hh_mm_ss.h>
+# include <__chrono/local_info.h>
+# include <__chrono/month.h>
+# include <__chrono/month_weekday.h>
+# include <__chrono/monthday.h>
+# include <__chrono/ostream.h>
+# include <__chrono/parser_std_format_spec.h>
+# include <__chrono/statically_widen.h>
+# include <__chrono/sys_info.h>
+# include <__chrono/system_clock.h>
+# include <__chrono/time_point.h>
+# include <__chrono/weekday.h>
+# include <__chrono/year.h>
+# include <__chrono/year_month.h>
+# include <__chrono/year_month_day.h>
+# include <__chrono/year_month_weekday.h>
+# include <__chrono/zoned_time.h>
+# include <__concepts/arithmetic.h>
+# include <__concepts/same_as.h>
+# include <__format/concepts.h>
+# include <__format/format_error.h>
+# include <__format/format_functions.h>
+# include <__format/format_parse_context.h>
+# include <__format/formatter.h>
+# include <__format/parser_std_format_spec.h>
+# include <__format/write_escaped.h>
+# include <__memory/addressof.h>
+# include <__type_traits/is_specialization.h>
+# include <cmath>
+# include <ctime>
+# include <limits>
+# include <sstream>
+# include <string_view>
+
+# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+# endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER >= 20
+# if _LIBCPP_STD_VER >= 20
namespace __formatter {
@@ -139,24 +142,24 @@ __format_sub_seconds(basic_stringstream<_CharT>& __sstr, const chrono::hh_mm_ss<
__value.fractional_width);
}
-# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && \
- !defined(_LIBCPP_HAS_NO_FILESYSTEM) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && \
+ !defined(_LIBCPP_HAS_NO_FILESYSTEM)
template <class _CharT, class _Duration, class _TimeZonePtr>
_LIBCPP_HIDE_FROM_ABI void
__format_sub_seconds(basic_stringstream<_CharT>& __sstr, const chrono::zoned_time<_Duration, _TimeZonePtr>& __value) {
__formatter::__format_sub_seconds(__sstr, __value.get_local_time().time_since_epoch());
}
-# endif
+# endif
template <class _Tp>
consteval bool __use_fraction() {
if constexpr (__is_time_point<_Tp>)
return chrono::hh_mm_ss<typename _Tp::duration>::fractional_width;
-# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && \
- !defined(_LIBCPP_HAS_NO_FILESYSTEM) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && \
+ !defined(_LIBCPP_HAS_NO_FILESYSTEM)
else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
return chrono::hh_mm_ss<typename _Tp::duration>::fractional_width;
-# endif
+# endif
else if constexpr (chrono::__is_duration<_Tp>::value)
return chrono::hh_mm_ss<_Tp>::fractional_width;
else if constexpr (__is_hh_mm_ss<_Tp>)
@@ -225,16 +228,15 @@ struct _LIBCPP_HIDE_FROM_ABI __time_zone {
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] const _Tp& __value) {
-# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
if constexpr (same_as<_Tp, chrono::sys_info>)
return {__value.abbrev, __value.offset};
-# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
- !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
return __formatter::__convert_to_time_zone(__value.get_info());
-# endif
+# endif
else
-# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
return {"UTC", chrono::seconds{0}};
}
@@ -341,12 +343,12 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
//
// TODO FMT evaluate the comment above.
-# if defined(__GLIBC__) || defined(_AIX) || defined(_WIN32)
+# if defined(__GLIBC__) || defined(_AIX) || defined(_WIN32)
case _CharT('y'):
// Glibc fails for negative values, AIX for positive values too.
__sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), (std::abs(__t.tm_year + 1900)) % 100);
break;
-# endif // defined(__GLIBC__) || defined(_AIX) || defined(_WIN32)
+# endif // defined(__GLIBC__) || defined(_AIX) || defined(_WIN32)
case _CharT('Y'):
// Depending on the platform's libc the range of supported years is
@@ -442,17 +444,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_ok(const _Tp& __value) {
return __value.weekday().ok();
else if constexpr (__is_hh_mm_ss<_Tp>)
return true;
-# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
else if constexpr (same_as<_Tp, chrono::sys_info>)
return true;
else if constexpr (same_as<_Tp, chrono::local_info>)
return true;
-# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
- !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
return true;
-# endif
-# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# endif
+# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
else
static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
}
@@ -493,17 +494,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_name_ok(const _Tp& __value) {
return __value.weekday().ok();
else if constexpr (__is_hh_mm_ss<_Tp>)
return true;
-# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
else if constexpr (same_as<_Tp, chrono::sys_info>)
return true;
else if constexpr (same_as<_Tp, chrono::local_info>)
return true;
-# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
- !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
return true;
-# endif
-# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# endif
+# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
else
static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
}
@@ -544,17 +544,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __date_ok(const _Tp& __value) {
return __value.ok();
else if constexpr (__is_hh_mm_ss<_Tp>)
return true;
-# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
else if constexpr (same_as<_Tp, chrono::sys_info>)
return true;
else if constexpr (same_as<_Tp, chrono::local_info>)
return true;
-# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
- !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
return true;
-# endif
-# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# endif
+# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
else
static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
}
@@ -595,17 +594,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __month_name_ok(const _Tp& __value) {
return __value.month().ok();
else if constexpr (__is_hh_mm_ss<_Tp>)
return true;
-# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
else if constexpr (same_as<_Tp, chrono::sys_info>)
return true;
else if constexpr (same_as<_Tp, chrono::local_info>)
return true;
-# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
- !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
return true;
-# endif
-# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# endif
+# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
else
static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
}
@@ -943,7 +941,7 @@ struct formatter<chrono::hh_mm_ss<_Duration>, _CharT> : public __formatter_chron
}
};
-# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
template <__fmt_char_type _CharT>
struct formatter<chrono::sys_info, _CharT> : public __formatter_chrono<_CharT> {
public:
@@ -965,8 +963,7 @@ struct formatter<chrono::local_info, _CharT> : public __formatter_chrono<_CharT>
return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags{});
}
};
-# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
- !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
// Note due to how libc++'s formatters are implemented there is no need to add
// the exposition only local-time-format-t abstraction.
template <class _Duration, class _TimeZonePtr, __fmt_char_type _CharT>
@@ -979,12 +976,13 @@ struct formatter<chrono::zoned_time<_Duration, _TimeZonePtr>, _CharT> : public _
return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__clock);
}
};
-# endif // !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) &&
- // !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# endif // !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
+# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
-#endif // if _LIBCPP_STD_VER >= 20
+# endif // if _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
+#endif // !_LIBCPP_HAS_NO_LOCALIZATION
+
#endif // _LIBCPP___CHRONO_FORMATTER_H
diff --git a/libcxx/include/__chrono/ostream.h b/libcxx/include/__chrono/ostream.h
index e6c43254eea15e..196ebd518541c7 100644
--- a/libcxx/include/__chrono/ostream.h
+++ b/libcxx/include/__chrono/ostream.h
@@ -10,37 +10,40 @@
#ifndef _LIBCPP___CHRONO_OSTREAM_H
#define _LIBCPP___CHRONO_OSTREAM_H
-#include <__chrono/calendar.h>
-#include <__chrono/day.h>
-#include <__chrono/duration.h>
-#include <__chrono/file_clock.h>
-#include <__chrono/hh_mm_ss.h>
-#include <__chrono/local_info.h>
-#include <__chrono/month.h>
-#include <__chrono/month_weekday.h>
-#include <__chrono/monthday.h>
-#include <__chrono/statically_widen.h>
-#include <__chrono/sys_info.h>
-#include <__chrono/system_clock.h>
-#include <__chrono/weekday.h>
-#include <__chrono/year.h>
-#include <__chrono/year_month.h>
-#include <__chrono/year_month_day.h>
-#include <__chrono/year_month_weekday.h>
-#include <__chrono/zoned_time.h>
-#include <__concepts/same_as.h>
#include <__config>
-#include <__format/format_functions.h>
-#include <__fwd/ostream.h>
-#include <ratio>
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-#endif
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+
+# include <__chrono/calendar.h>
+# include <__chrono/day.h>
+# include <__chrono/duration.h>
+# include <__chrono/file_clock.h>
+# include <__chrono/hh_mm_ss.h>
+# include <__chrono/local_info.h>
+# include <__chrono/month.h>
+# include <__chrono/month_weekday.h>
+# include <__chrono/monthday.h>
+# include <__chrono/statically_widen.h>
+# include <__chrono/sys_info.h>
+# include <__chrono/system_clock.h>
+# include <__chrono/weekday.h>
+# include <__chrono/year.h>
+# include <__chrono/year_month.h>
+# include <__chrono/year_month_day.h>
+# include <__chrono/year_month_weekday.h>
+# include <__chrono/zoned_time.h>
+# include <__concepts/same_as.h>
+# include <__format/format_functions.h>
+# include <__fwd/ostream.h>
+# include <ratio>
+
+# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+# endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER >= 20
+# if _LIBCPP_STD_VER >= 20
namespace chrono {
@@ -82,11 +85,11 @@ _LIBCPP_HIDE_FROM_ABI auto __units_suffix() {
else if constexpr (same_as<typename _Period::type, nano>)
return _LIBCPP_STATICALLY_WIDEN(_CharT, "ns");
else if constexpr (same_as<typename _Period::type, micro>)
-# ifndef _LIBCPP_HAS_NO_UNICODE
+# ifndef _LIBCPP_HAS_NO_UNICODE
return _LIBCPP_STATICALLY_WIDEN(_CharT, "\u00b5s");
-# else
+# else
return _LIBCPP_STATICALLY_WIDEN(_CharT, "us");
-# endif
+# endif
else if constexpr (same_as<typename _Period::type, milli>)
return _LIBCPP_STATICALLY_WIDEN(_CharT, "ms");
else if constexpr (same_as<typename _Period::type, centi>)
@@ -265,7 +268,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const hh_mm_ss<_Duration> __hms
return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%T}"), __hms);
}
-# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
template <class _CharT, class _Traits>
_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
@@ -303,20 +306,21 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const local_info& __info) {
_LIBCPP_STATICALLY_WIDEN(_CharT, "{}: {{{}, {}}}"), __result(), __info.first, __info.second);
}
-# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
- !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
template <class _CharT, class _Traits, class _Duration, class _TimeZonePtr>
_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const zoned_time<_Duration, _TimeZonePtr>& __tp) {
return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%F %T %Z}"), __tp);
}
-# endif
-# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# endif
+# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
} // namespace chrono
-#endif // if _LIBCPP_STD_VER >= 20
+# endif // if _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
+#endif // !_LIBCPP_HAS_NO_LOCALIZATION
+
#endif // _LIBCPP___CHRONO_OSTREAM_H
diff --git a/libcxx/include/__chrono/parser_std_format_spec.h b/libcxx/include/__chrono/parser_std_format_spec.h
index 6803d03ad882fd..c9cfcc6d572f41 100644
--- a/libcxx/include/__chrono/parser_std_format_spec.h
+++ b/libcxx/include/__chrono/parser_std_format_spec.h
@@ -11,20 +11,23 @@
#define _LIBCPP___CHRONO_PARSER_STD_FORMAT_SPEC_H
#include <__config>
-#include <__format/concepts.h>
-#include <__format/format_error.h>
-#include <__format/format_parse_context.h>
-#include <__format/formatter_string.h>
-#include <__format/parser_std_format_spec.h>
-#include <string_view>
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-#endif
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+
+# include <__format/concepts.h>
+# include <__format/format_error.h>
+# include <__format/format_parse_context.h>
+# include <__format/formatter_string.h>
+# include <__format/parser_std_format_spec.h>
+# include <string_view>
+
+# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+# endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER >= 20
+# if _LIBCPP_STD_VER >= 20
namespace __format_spec {
@@ -409,8 +412,10 @@ class _LIBCPP_TEMPLATE_VIS __parser_chrono {
} // namespace __format_spec
-#endif // _LIBCPP_STD_VER >= 20
+# endif // _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
+#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+
#endif // _LIBCPP___CHRONO_PARSER_STD_FORMAT_SPEC_H
diff --git a/libcxx/include/__ostream/basic_ostream.h b/libcxx/include/__ostream/basic_ostream.h
index e0698ccb4842a5..1f7fe8338c5894 100644
--- a/libcxx/include/__ostream/basic_ostream.h
+++ b/libcxx/include/__ostream/basic_ostream.h
@@ -10,29 +10,32 @@
#define _LIBCPP___OSTREAM_BASIC_OSTREAM_H
#include <__config>
-#include <__exception/operations.h>
-#include <__memory/shared_ptr.h>
-#include <__memory/unique_ptr.h>
-#include <__system_error/error_code.h>
-#include <__type_traits/conjunction.h>
-#include <__type_traits/enable_if.h>
-#include <__type_traits/is_base_of.h>
-#include <__type_traits/void_t.h>
-#include <__utility/declval.h>
-#include <bitset>
-#include <cstddef>
-#include <ios>
-#include <locale>
-#include <new> // for __throw_bad_alloc
-#include <streambuf>
-#include <string_view>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-#endif
+
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+
+# include <__exception/operations.h>
+# include <__memory/shared_ptr.h>
+# include <__memory/unique_ptr.h>
+# include <__system_error/error_code.h>
+# include <__type_traits/conjunction.h>
+# include <__type_traits/enable_if.h>
+# include <__type_traits/is_base_of.h>
+# include <__type_traits/void_t.h>
+# include <__utility/declval.h>
+# include <bitset>
+# include <cstddef>
+# include <ios>
+# include <locale>
+# include <new> // for __throw_bad_alloc
+# include <streambuf>
+# include <string_view>
+
+# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+# endif
_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
+# include <__undef_macros>
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -99,19 +102,19 @@ class _LIBCPP_TEMPLATE_VIS basic_ostream : virtual public basic_ios<_CharT, _Tra
basic_ostream& operator<<(long double __f);
basic_ostream& operator<<(const void* __p);
-#if _LIBCPP_STD_VER >= 23
+# if _LIBCPP_STD_VER >= 23
...
[truncated]
|
Several headers that should not be provided when localization or threads are disabled were not guarded. That works until one tries to build with modules and these headers get pulled in.
Note that this could be cleaned up further into something more systematic, but this patch solves the immediate problems I ran into with the monolithic modulemap and doesn't create any new inconsistency that wasn't already there.