Skip to content

[libc++][chrono] implements UTC clock. #90393

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

Merged
merged 1 commit into from
Jan 24, 2025

Conversation

mordante
Copy link
Member

While implementing this feature and its associated LWG issues it turns out

  • LWG3316 Correctly define epoch for utc_clock / utc_timepoint only added non-normative wording to the standard.

Implements parts of:

  • P0355 Extending to Calendars and Time Zones
  • P1361 Integration of chrono with text formatting
  • LWG3359 leap second support should allow for negative leap seconds

@mordante mordante requested a review from a team as a code owner April 28, 2024 10:26
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Apr 28, 2024
@llvmbot
Copy link
Member

llvmbot commented Apr 28, 2024

@llvm/pr-subscribers-libcxx

Author: Mark de Wever (mordante)

Changes

While implementing this feature and its associated LWG issues it turns out

  • LWG3316 Correctly define epoch for utc_clock / utc_timepoint only added non-normative wording to the standard.

Implements parts of:

  • P0355 Extending <chrono> to Calendars and Time Zones
  • P1361 Integration of chrono with text formatting
  • LWG3359 <chrono> leap second support should allow for negative leap seconds

Patch is 115.96 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/90393.diff

26 Files Affected:

  • (modified) libcxx/benchmarks/CMakeLists.txt (+1)
  • (added) libcxx/benchmarks/utc_clock.bench.cpp (+54)
  • (modified) libcxx/docs/Status/Cxx20.rst (+1-1)
  • (modified) libcxx/docs/Status/Cxx20Issues.csv (+1-1)
  • (modified) libcxx/docs/Status/FormatPaper.csv (+1-1)
  • (modified) libcxx/include/CMakeLists.txt (+1)
  • (modified) libcxx/include/__chrono/convert_to_tm.h (+18)
  • (modified) libcxx/include/__chrono/formatter.h (+18)
  • (modified) libcxx/include/__chrono/ostream.h (+12)
  • (added) libcxx/include/__chrono/utc_clock.h (+155)
  • (modified) libcxx/include/chrono (+38)
  • (modified) libcxx/include/module.modulemap (+4)
  • (modified) libcxx/modules/std/chrono.inc (+10-2)
  • (modified) libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp (+14)
  • (added) libcxx/test/libcxx/time/time.clock/time.clock.utc/get_leap_second_info.pass.cpp (+124)
  • (added) libcxx/test/libcxx/time/time.clock/time.clock.utc/time.clock.utc.members/from_sys.pass.cpp (+106)
  • (added) libcxx/test/libcxx/time/time.clock/time.clock.utc/time.clock.utc.members/to_sys.pass.cpp (+115)
  • (added) libcxx/test/std/time/time.clock/time.clock.utc/get_leap_second_info.pass.cpp (+126)
  • (added) libcxx/test/std/time/time.clock/time.clock.utc/leap_second_info.members.pass.cpp (+37)
  • (added) libcxx/test/std/time/time.clock/time.clock.utc/time.clock.utc.members/from_sys.pass.cpp (+213)
  • (added) libcxx/test/std/time/time.clock/time.clock.utc/time.clock.utc.members/now.pass.cpp (+30)
  • (added) libcxx/test/std/time/time.clock/time.clock.utc/time.clock.utc.members/to_sys.pass.cpp (+147)
  • (added) libcxx/test/std/time/time.clock/time.clock.utc/types.compile.pass.cpp (+59)
  • (added) libcxx/test/std/time/time.clock/time.clock.utc/utc_time.ostream.pass.cpp (+165)
  • (added) libcxx/test/std/time/time.syn/formatter.utc_time.pass.cpp (+1004)
  • (modified) libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp (+1-1)
diff --git a/libcxx/benchmarks/CMakeLists.txt b/libcxx/benchmarks/CMakeLists.txt
index 527a2acf2d3b36..ea7ef6902f7266 100644
--- a/libcxx/benchmarks/CMakeLists.txt
+++ b/libcxx/benchmarks/CMakeLists.txt
@@ -229,6 +229,7 @@ set(BENCHMARK_TESTS
     system_error.bench.cpp
     to_chars.bench.cpp
     unordered_set_operations.bench.cpp
+    utc_clock.bench.cpp
     util_smartptr.bench.cpp
     variant_visit_1.bench.cpp
     variant_visit_2.bench.cpp
diff --git a/libcxx/benchmarks/utc_clock.bench.cpp b/libcxx/benchmarks/utc_clock.bench.cpp
new file mode 100644
index 00000000000000..255b1dde52aa67
--- /dev/null
+++ b/libcxx/benchmarks/utc_clock.bench.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include <chrono>
+
+#include "benchmark/benchmark.h"
+
+// Benchmarks the performance of the UTC <-> system time conversions. These
+// operations determine the sum of leap second insertions at a specific time.
+
+static void BM_from_sys(benchmark::State& state) {
+  std::chrono::sys_days date{std::chrono::July / 1 / state.range(0)};
+  for (auto _ : state)
+    benchmark::DoNotOptimize(std::chrono::utc_clock::from_sys(date));
+}
+
+BENCHMARK(BM_from_sys)
+    ->Arg(1970)  // before the first leap seconds
+    ->Arg(1979)  // in the first half of inserted leap seconds
+    ->Arg(1993)  // in the second half of inserted leap seconds
+    ->Arg(2100); // after the last leap second
+
+BENCHMARK(BM_from_sys)->Arg(1970)->Arg(1979)->Arg(1993)->Arg(2100)->Threads(4);
+BENCHMARK(BM_from_sys)->Arg(1970)->Arg(1979)->Arg(1993)->Arg(2100)->Threads(16);
+
+static void BM_to_sys(benchmark::State& state) {
+  // 59 sec offset means we pass th UTC offset for the leap second; assuming
+  // there won't be more than 59 leap seconds ever.
+  std::chrono::utc_seconds date{
+      std::chrono::sys_days{std::chrono::July / 1 / state.range(0)}.time_since_epoch() + std::chrono::seconds{59}};
+  for (auto _ : state)
+    benchmark::DoNotOptimize(std::chrono::utc_clock::to_sys(date));
+}
+
+BENCHMARK(BM_to_sys)
+    ->Arg(1970)  // before the first leap seconds
+    ->Arg(1979)  // in the first half of inserted leap seconds
+    ->Arg(1993)  // in the second half of inserted leap seconds
+    ->Arg(2100); // after the last leap second
+
+BENCHMARK(BM_to_sys)->Arg(1970)->Arg(1979)->Arg(1993)->Arg(2100)->Threads(4);
+BENCHMARK(BM_to_sys)->Arg(1970)->Arg(1979)->Arg(1993)->Arg(2100)->Threads(16);
+
+int main(int argc, char** argv) {
+  benchmark::Initialize(&argc, argv);
+  if (benchmark::ReportUnrecognizedArguments(argc, argv))
+    return 1;
+
+  benchmark::RunSpecifiedBenchmarks();
+}
diff --git a/libcxx/docs/Status/Cxx20.rst b/libcxx/docs/Status/Cxx20.rst
index 23289dc6e5961b..baa1dc6d613826 100644
--- a/libcxx/docs/Status/Cxx20.rst
+++ b/libcxx/docs/Status/Cxx20.rst
@@ -55,9 +55,9 @@ Paper Status
       * ``Input parsers`` not done
       * ``Stream output`` Obsolete due to `P1361R2 <https://wg21.link/P1361R2>`_ "Integration of chrono with text formatting"
       * ``Time zone and leap seconds`` In Progress
+      * ``UTC clock`` Clang 19
       * ``TAI clock`` not done
       * ``GPS clock`` not done
-      * ``UTC clock`` not done
 
    .. [#note-P0718] P0718: Implemented deprecation of ``shared_ptr`` atomic access APIs only.
 
diff --git a/libcxx/docs/Status/Cxx20Issues.csv b/libcxx/docs/Status/Cxx20Issues.csv
index fed1c7e736248f..556da4fc72f83a 100644
--- a/libcxx/docs/Status/Cxx20Issues.csv
+++ b/libcxx/docs/Status/Cxx20Issues.csv
@@ -238,7 +238,7 @@
 "`3313 <https://wg21.link/LWG3313>`__","``join_view::iterator::operator--``\  is incorrectly constrained","Prague","|Complete|","14.0","|ranges|"
 "`3314 <https://wg21.link/LWG3314>`__","Is stream insertion behavior locale dependent when ``Period::type``\  is ``micro``\ ?","Prague","|Complete|","16.0","|chrono|"
 "`3315 <https://wg21.link/LWG3315>`__","Correct Allocator Default Behavior","Prague","",""
-"`3316 <https://wg21.link/LWG3316>`__","Correctly define epoch for ``utc_clock``\  / ``utc_timepoint``\ ","Prague","","","|chrono|"
+"`3316 <https://wg21.link/LWG3316>`__","Correctly define epoch for ``utc_clock``\  / ``utc_timepoint``\ ","Prague","|Nothing To Do|","","|chrono|"
 "`3317 <https://wg21.link/LWG3317>`__","Incorrect ``operator<<``\  for floating-point durations","Prague","","","|chrono|"
 "`3318 <https://wg21.link/LWG3318>`__","Clarify whether clocks can represent time before their epoch","Prague","","","|chrono|"
 "`3319 <https://wg21.link/LWG3319>`__","Properly reference specification of IANA time zone database","Prague","|Nothing To Do|","","|chrono|"
diff --git a/libcxx/docs/Status/FormatPaper.csv b/libcxx/docs/Status/FormatPaper.csv
index f29f1f7ca74875..bf733e264cde22 100644
--- a/libcxx/docs/Status/FormatPaper.csv
+++ b/libcxx/docs/Status/FormatPaper.csv
@@ -2,7 +2,7 @@ Section,Description,Dependencies,Assignee,Status,First released version
 `P1361 <https://wg21.link/P1361>`__ `P2372 <https://wg21.link/P2372>`__,"Formatting chrono"
 `[time.syn] <https://wg21.link/time.syn>`_,"Formatter ``chrono::duration<Rep, Period>``",,Mark de Wever,|Complete|,16.0
 `[time.syn] <https://wg21.link/time.syn>`_,"Formatter ``chrono::sys_time<Duration>``",,Mark de Wever,|Complete|,17.0
-`[time.syn] <https://wg21.link/time.syn>`_,"Formatter ``chrono::utc_time<Duration>``",A ``<chrono>`` implementation,Mark de Wever,,,
+`[time.syn] <https://wg21.link/time.syn>`_,"Formatter ``chrono::utc_time<Duration>``",,Mark de Wever,|Complete|,19.0
 `[time.syn] <https://wg21.link/time.syn>`_,"Formatter ``chrono::tai_time<Duration>``",A ``<chrono>`` implementation,Mark de Wever,,,
 `[time.syn] <https://wg21.link/time.syn>`_,"Formatter ``chrono::gps_time<Duration>``",A ``<chrono>`` implementation,Mark de Wever,,,
 `[time.syn] <https://wg21.link/time.syn>`_,"Formatter ``chrono::file_time<Duration>``",,Mark de Wever,|Complete|,17.0
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 1296c536bc882c..4aff1487030500 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -285,6 +285,7 @@ set(files
   __chrono/time_zone_link.h
   __chrono/tzdb.h
   __chrono/tzdb_list.h
+  __chrono/utc_clock.h
   __chrono/weekday.h
   __chrono/year.h
   __chrono/year_month.h
diff --git a/libcxx/include/__chrono/convert_to_tm.h b/libcxx/include/__chrono/convert_to_tm.h
index 881a4970822d8e..8e9310da2ce94a 100644
--- a/libcxx/include/__chrono/convert_to_tm.h
+++ b/libcxx/include/__chrono/convert_to_tm.h
@@ -24,6 +24,7 @@
 #include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
+#include <__chrono/utc_clock.h>
 #include <__chrono/weekday.h>
 #include <__chrono/year.h>
 #include <__chrono/year_month.h>
@@ -96,6 +97,21 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const chrono::sys_time<_Duration> __tp
   return __result;
 }
 
+#  if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) &&                            \
+      !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+template <class _Tm, class _Duration>
+_LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(chrono::utc_time<_Duration> __tp) {
+  _Tm __result = std::__convert_to_tm<_Tm>(chrono::utc_clock::to_sys(__tp));
+
+  if (chrono::get_leap_second_info(__tp).is_leap_second)
+    ++__result.tm_sec;
+
+  return __result;
+}
+
+#  endif //  !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) &&
+         //  !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+
 // Convert a chrono (calendar) time point, or dururation to the given _Tm type,
 // which must have the same properties as std::tm.
 template <class _Tm, class _ChronoT>
@@ -108,6 +124,8 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& __value) {
   if constexpr (__is_time_point<_ChronoT>) {
     if constexpr (same_as<typename _ChronoT::clock, chrono::system_clock>)
       return std::__convert_to_tm<_Tm>(__value);
+    else if constexpr (same_as<typename _ChronoT::clock, chrono::utc_clock>)
+      return std::__convert_to_tm<_Tm>(__value);
     else if constexpr (same_as<typename _ChronoT::clock, chrono::file_clock>)
       return std::__convert_to_tm<_Tm>(_ChronoT::clock::to_sys(__value));
     else if constexpr (same_as<typename _ChronoT::clock, chrono::local_t>)
diff --git a/libcxx/include/__chrono/formatter.h b/libcxx/include/__chrono/formatter.h
index e9b81c3de8a700..6a6f60341c1394 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -28,6 +28,7 @@
 #include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
+#include <__chrono/utc_clock.h>
 #include <__chrono/weekday.h>
 #include <__chrono/year.h>
 #include <__chrono/year_month.h>
@@ -673,6 +674,23 @@ struct _LIBCPP_TEMPLATE_VIS formatter<chrono::sys_time<_Duration>, _CharT> : pub
   }
 };
 
+#  if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) &&                            \
+      !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+
+template <class _Duration, __fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS formatter<chrono::utc_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {
+public:
+  using _Base = __formatter_chrono<_CharT>;
+
+  template <class _ParseContext>
+  _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
+    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)
+
 template <class _Duration, __fmt_char_type _CharT>
 struct _LIBCPP_TEMPLATE_VIS formatter<chrono::file_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {
 public:
diff --git a/libcxx/include/__chrono/ostream.h b/libcxx/include/__chrono/ostream.h
index ecf07a320c8b94..4862a8ae326a3e 100644
--- a/libcxx/include/__chrono/ostream.h
+++ b/libcxx/include/__chrono/ostream.h
@@ -22,6 +22,7 @@
 #include <__chrono/statically_widen.h>
 #include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
+#include <__chrono/utc_clock.h>
 #include <__chrono/weekday.h>
 #include <__chrono/year.h>
 #include <__chrono/year_month.h>
@@ -56,6 +57,17 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const sys_days& __dp) {
   return __os << year_month_day{__dp};
 }
 
+#  if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) &&                            \
+      !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+
+template <class _CharT, class _Traits, class _Duration>
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const utc_time<_Duration>& __tp) {
+  return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%F %T}"), __tp);
+}
+#  endif //  !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) &&
+         //  !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+
 template <class _CharT, class _Traits, class _Duration>
 _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
 operator<<(basic_ostream<_CharT, _Traits>& __os, const file_time<_Duration> __tp) {
diff --git a/libcxx/include/__chrono/utc_clock.h b/libcxx/include/__chrono/utc_clock.h
new file mode 100644
index 00000000000000..a3db972f26a4e2
--- /dev/null
+++ b/libcxx/include/__chrono/utc_clock.h
@@ -0,0 +1,155 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___CHRONO_UTC_CLOCK_H
+#define _LIBCPP___CHRONO_UTC_CLOCK_H
+
+#include <version>
+// Enable the contents of the header only when libc++ was built with experimental features enabled.
+#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
+
+#  include <__chrono/duration.h>
+#  include <__chrono/system_clock.h>
+#  include <__chrono/time_point.h>
+#  include <__chrono/tzdb.h>
+#  include <__chrono/tzdb_list.h>
+#  include <__config>
+#  include <__type_traits/common_type.h>
+
+#  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#    pragma GCC system_header
+#  endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#  if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) &&   \
+      !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+
+namespace chrono {
+
+class utc_clock;
+
+template <class _Duration>
+using utc_time    = time_point<utc_clock, _Duration>;
+using utc_seconds = utc_time<seconds>;
+
+class utc_clock {
+public:
+  using rep                       = system_clock::rep;
+  using period                    = system_clock::period;
+  using duration                  = chrono::duration<rep, period>;
+  using time_point                = chrono::time_point<utc_clock>;
+  static constexpr bool is_steady = false; // The system_clock is not steady.
+
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static time_point now() { return from_sys(system_clock::now()); }
+
+  template <class _Duration>
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static sys_time<common_type_t<_Duration, seconds>>
+  to_sys(const utc_time<_Duration>& __time);
+
+  template <class _Duration>
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static utc_time<common_type_t<_Duration, seconds>>
+  from_sys(const sys_time<_Duration>& __time) {
+    using _Rp = utc_time<common_type_t<_Duration, seconds>>;
+    // TODO TZDB investigate optimizations.
+    //
+    // The leap second database stores all transitions, this mean to calculate
+    // the current number of leap seconds the code needs to iterate over all
+    // leap seconds to accumulate the sum. Then the sum can be used to determine
+    // the sys_time. Accessing the database involves acquiring a mutex.
+    //
+    // The historic entries in the database are immutable. Hard-coding these
+    // values in a table would allow:
+    // - To store the sum, allowing a binary search on the data.
+    // - Avoid acquiring a mutex.
+    // The disadvantage are:
+    // - A slightly larger code size.
+    //
+    // There are two optimization directions
+    // - hard-code the database and do a linear search for future entries. This
+    //   search can start at the back, and should probably contain very few
+    //   entries. (Adding leap seconds is quite rare and new release of libc++
+    //   can add the new entries; they are announced half a year before they are
+    //   added.)
+    // - During parsing the leap seconds store an additional database in the
+    //   dylib with the list of the sum of the leap seconds. In that case there
+    //   can be a private function __get_utc_to_sys_table that returns the
+    //   table.
+    //
+    // Note for to_sys there are no optimizations to be done; it uses
+    // get_leap_second_info. The function get_leap_second_info could benefit
+    // from optimizations as described above; again both options apply.
+
+    // Both UTC and the system clock use the same epoch. The Standard
+    // specifies from 1970-01-01 even when UTC starts at
+    // 1972-01-01 00:00:10 TAI. So when the sys_time is before epoch we can be
+    // sure there both clocks return the same value.
+
+    const tzdb& __tzdb = chrono::get_tzdb();
+    _Rp __result{__time.time_since_epoch()};
+    for (const auto& __leap_second : __tzdb.leap_seconds) {
+      if (__time < __leap_second)
+        return __result;
+
+      __result += __leap_second.value();
+    }
+    return __result;
+  }
+};
+
+struct leap_second_info {
+  bool is_leap_second;
+  seconds elapsed;
+};
+
+template <class _Duration>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI leap_second_info get_leap_second_info(const utc_time<_Duration>& __time) {
+  const tzdb& __tzdb = chrono::get_tzdb();
+  if (__tzdb.leap_seconds.empty())
+    return {false, chrono::seconds{0}};
+
+  sys_seconds __sys{chrono::floor<seconds>(__time).time_since_epoch()};
+  seconds __elapsed{0};
+  for (const auto& __leap_second : __tzdb.leap_seconds) {
+    if (__sys == __leap_second.date() + __elapsed)
+      return {__leap_second.value() > 0s, // only positive leap seconds are considered leap seconds
+              __elapsed + __leap_second.value()};
+
+    if (__sys < __leap_second.date() + __elapsed)
+      return {false, __elapsed};
+
+    __elapsed += __leap_second.value();
+  }
+
+  return {false, __elapsed};
+}
+
+template <class _Duration>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_time<common_type_t<_Duration, seconds>>
+utc_clock::to_sys(const utc_time<_Duration>& __time) {
+  using _Dp               = common_type_t<_Duration, seconds>;
+  leap_second_info __info = get_leap_second_info(__time);
+
+  sys_time<common_type_t<_Duration, seconds>> __result{__time.time_since_epoch() - __info.elapsed};
+  if (__info.is_leap_second)
+    return chrono::floor<seconds>(__result) + chrono::seconds{1} - _Dp{1};
+
+  return __result;
+}
+
+} // namespace chrono
+
+#  endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
+         // && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
+
+#endif // _LIBCPP___CHRONO_UTC_CLOCK_H
diff --git a/libcxx/include/chrono b/libcxx/include/chrono
index 4d8398af1a108f..7ce527f120e9e4 100644
--- a/libcxx/include/chrono
+++ b/libcxx/include/chrono
@@ -300,6 +300,41 @@ template<class charT, class traits>                    // C++20
   basic_ostream<charT, traits>&
     operator<<(basic_ostream<charT, traits>& os, const sys_days& dp);
 
+// [time.clock.utc], class utc_clock
+class utc_clock {                                      // C++20
+public:
+    using rep                       = a signed arithmetic type;
+    using period                    = ratio<unspecified, unspecified>;
+    using duration                  = chrono::duration<rep, period>;
+    using time_point                = chrono::time_point<utc_clock>;
+    static constexpr bool is_steady = unspecified;
+
+    static time_point now();
+
+    template<class Duration>
+      static sys_time<common_type_t<Duration, seconds>>
+        to_sys(const utc_time<Duration>& t);
+    template<class Duration>
+      static utc_time<common_type_t<Duration, seconds>>
+        from_sys(const sys_time<Duration>& t);
+};
+
+template<class Duration>
+using utc_time  = time_point<utc_clock, Duration>;      // C++20
+using utc_seconds = utc_time<seconds>;                  // C++20
+
+template<class charT, class traits, class Duration>     // C++20
+  basic_ostream<charT, traits>&
+    operator<<(basic_ostream<charT, traits>& os, const utc_time<Duration>& t);
+
+struct leap_second_info {                               // C++20
+  bool    is_leap_second;
+  seconds elapsed;
+};
+
+template<class Duration>                                // C++20
+  leap_second_info get_leap_second_info(const utc_time<Duration>& ut);
+
 class file_clock                                        // C++20
 {
 public:
@@ -827,6 +862,8 @@ strong_ordering operator<=>(const time_zone_link& x, const time_zone_link& y);
 namespace std {
   template<class Duration, class charT>
     struct formatter<chrono::sys_time<Duration>, charT>;                          // C++20
+  template<class Duration, class charT>
+    struct formatter<chrono::utc_time<Duration>, charT>;                          // C++20
   template<class Duration, class charT>
     struct formatter<chrono::filetime<Duration>, charT>;                          // C++20
   template<class Duration, class charT>
@@ -942,6 +979,7 @@ constexpr chrono::year                                  operator ""y(unsigned lo
 #    include <__chrono/time_zone_link.h>
 #    include <__chrono/tzdb.h>
 #    include <__chrono/tzdb_list.h>
+#    include <__chrono/utc_clock.h>
 #  endif
 
 #endif
diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap
index...
[truncated]

@mordante mordante force-pushed the users/mordante/implements_utc_clock branch from 188e6f4 to 77edef4 Compare April 28, 2024 18:57

sys_time<common_type_t<_Duration, seconds>> __result{__time.time_since_epoch() - __info.elapsed};
if (__info.is_leap_second)
return chrono::floor<seconds>(__result) + chrono::seconds{1} - _Dp{1};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is right for floating point duration reps, where the ulp can be more or less than _Dp{1}. I think nextafter is needed for reps where treat_as_floating_point_v is true. (Assuming you have such an overload for extended-precision floats. I'm also uncertain if [time.duration.general]/2 allows a user-defined type to "emulate" a floating point type by specializing treat_as_floating_point.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I'll need to look into this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added some tests with floating point, but I don't see an issue with the existing code. Do you have an example of problematic values?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't use float because the ulp is not less than 1 in the relevant range, so it's difficult to observe the effect. Also, the test does the same thing as the product code, which is subtract 1, but I don't think that's correct. For example, with the first leap second (78796800s) and double precision, I think the answer should be S{D{nextafter(78796800.0, 0.0)}}, i.e. 0x1.2c95fffffffffp+26, for any UTC time during the leap second insertion. To me, that's the "last representable value" prior to the insertion.

}

template <class CharT>
static void test_utc_transitions() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you can customize the leap second db like in some of the other tests, it might be useful to verify that a negative leap second has the correct behavior, i.e., "23:59:58" is followed by "00:00:00".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I had such a test, but seems only with my own faked data. I'll look at adding such a test and I want to look at using the fake numbers Paul Eggert generated. Thanks for that link!

Copy link
Member Author

@mordante mordante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your review comments.


sys_time<common_type_t<_Duration, seconds>> __result{__time.time_since_epoch() - __info.elapsed};
if (__info.is_leap_second)
return chrono::floor<seconds>(__result) + chrono::seconds{1} - _Dp{1};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I'll need to look into this.

@mordante mordante force-pushed the users/mordante/fixes_leap_second_database_format branch from d094cde to 9e551c1 Compare July 4, 2024 14:38
Base automatically changed from users/mordante/fixes_leap_second_database_format to main July 4, 2024 18:45
@mordante mordante force-pushed the users/mordante/implements_utc_clock branch from 77edef4 to 3fd4c66 Compare July 8, 2024 16:02
Copy link

github-actions bot commented Jul 8, 2024

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff b7abc510c515c4df521c84c6f664a138f8cf01e0 f7d3064842caeb4c6716d92e05073c5c2740c5ed --extensions cpp,,h,inc -- libcxx/include/__chrono/utc_clock.h libcxx/test/benchmarks/utc_clock.bench.cpp libcxx/test/libcxx/time/time.clock/time.clock.utc/get_leap_second_info.pass.cpp libcxx/test/libcxx/time/time.clock/time.clock.utc/time.clock.utc.members/from_sys.pass.cpp libcxx/test/libcxx/time/time.clock/time.clock.utc/time.clock.utc.members/to_sys.pass.cpp libcxx/test/std/time/time.clock/time.clock.utc/get_leap_second_info.pass.cpp libcxx/test/std/time/time.clock/time.clock.utc/leap_second_info.members.pass.cpp libcxx/test/std/time/time.clock/time.clock.utc/time.clock.utc.members/from_sys.pass.cpp libcxx/test/std/time/time.clock/time.clock.utc/time.clock.utc.members/now.pass.cpp libcxx/test/std/time/time.clock/time.clock.utc/time.clock.utc.members/to_sys.pass.cpp libcxx/test/std/time/time.clock/time.clock.utc/types.compile.pass.cpp libcxx/test/std/time/time.clock/time.clock.utc/utc_time.ostream.pass.cpp libcxx/test/std/time/time.syn/formatter.utc_time.pass.cpp libcxx/include/__chrono/convert_to_tm.h libcxx/include/__chrono/formatter.h libcxx/include/__chrono/ostream.h libcxx/include/chrono libcxx/modules/std/chrono.inc libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp
View the diff from clang-format here.
diff --git a/libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp b/libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp
index 88a485a256..49d3e756e3 100644
--- a/libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp
@@ -156,7 +156,7 @@ void test_P1361() {
   //assert_is_formattable<std::chrono::tai_time<std::chrono::microseconds>, CharT>();
   //assert_is_formattable<std::chrono::gps_time<std::chrono::microseconds>, CharT>();
 
-#  endif // !defined(TEST_HAS_NO_EXPERIMENTAL_TZDB) && !defined(TEST_HAS_NO_TIME_ZONE_DATABASE) &&
+#  endif // !defined(TEST_HAS_NO_EXPERIMENTAL_TZDB) && !defined(TEST_HAS_NO_TIME_ZONE_DATABASE) &&                     \
          // !defined(TEST_HAS_NO_FILESYSTEM)
 
   assert_is_formattable<std::chrono::file_time<std::chrono::microseconds>, CharT>();

@ldionne ldionne added this to the LLVM 19.X Release milestone Jul 9, 2024
Copy link
Member

@ldionne ldionne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this LGTM once a few questions have been answered, but I'd like to see this one last time after the rebase.


sys_time<common_type_t<_Duration, seconds>> __result{__time.time_since_epoch() - __info.elapsed};
if (__info.is_leap_second)
return chrono::floor<seconds>(__result) + chrono::seconds{1} - _Dp{1};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Floating-point concerns aside, I don't understand how this works. My (naive) understanding is that _Dp can be smaller than seconds, for example if common_type_t<_Duration, seconds> is chrono::milliseconds. In that case, you'd be flooring the result, then adding 1 second and subtracting one millisecond. So basically you'd be adding 0.999 seconds to the result. I don't understand why that is correct. If that's a bug, let's add a test!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The relevant language is [time.clock.utc.members]/2: "[If u represents a time during a leap second insertion,] the last representable value of sys_time prior to the insertion of the leap second is returned."

Briefly, I think the part you might be missing is that leap_second_info::elapsed is being subtracted before adding seconds{1} - _Dp{1}, and elapsed is incremented as soon as the insertion begins. So in this branch, when is_leap_second is true, floor<seconds>(__result) is one second before the leap second insertion began.

To illustrate, suppose that we're examining a day with a positive leap second. To make things easier, assume that the UTC epoch is midnight of that day, this is the first leap second ever, and the _Dpratio isratio<1,4>`. Then:

UTC time __time __info __result floor<seconds>(__result) + seconds{1} - _Dp{1} Returned system time
23:59:59.75 345,599 {false, 0s} 345,599 N/A 23:59:59.75
23:59:60.00 345,600 {true,1s} 345,596 345,599 (=345,596+4-1) 23:59:59.75
23:59:60.25 345,601 {true,1s} 345,597 345,599 23:59:59.75
23:59:60.50 345,602 {true,1s} 345,598 345,599 23:59:59.75
23:59:60.75 345,603 {true,1s} 345,599 345,599 23:59:59.75
00:00:00.00 345,604 {false,1s} 345,600 N/A 00:00:00.00

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MattStephanson I read your comment, but I'm not sure what the issue is. "the last representable value of sys_time prior to the insertion of the leap second is returned." Looking at the floor<seconds>(__result) + seconds{1} - _Dp{1} and "Returned system time" columns these are the values returned. Could you show the values you would have expected?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mordante I think the returned values are correct. I was trying to explain to @ldionne why the code is correct (except, as I said earlier, for floating point).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the explanation, this makes a lot more sense now!

@mordante mordante force-pushed the users/mordante/implements_utc_clock branch 2 times, most recently from b7044a0 to 1dc7845 Compare December 23, 2024 16:19
@mordante mordante force-pushed the users/mordante/implements_utc_clock branch 7 times, most recently from c31fcda to 3f47c8f Compare January 20, 2025 21:04
Copy link
Member

@ldionne ldionne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with green CI


sys_time<common_type_t<_Duration, seconds>> __result{__time.time_since_epoch() - __info.elapsed};
if (__info.is_leap_second)
return chrono::floor<seconds>(__result) + chrono::seconds{1} - _Dp{1};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the explanation, this makes a lot more sense now!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How long does this benchmark take? I'm trying to keep benchmarks pretty cheap to run so that we can move towards running them automatically on a regular basis.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About 10 seconds.

@ldionne ldionne added the pending-ci Merging the PR is only pending completion of CI label Jan 21, 2025
@mordante mordante force-pushed the users/mordante/implements_utc_clock branch 3 times, most recently from 01fe3f9 to ecf9334 Compare January 23, 2025 17:34
While implementing this feature and its associated LWG issues it turns out
- LWG3316 Correctly define epoch for utc_clock / utc_timepoint
only added non-normative wording to the standard.

Implements parts of:
- P0355 Extending <chrono> to Calendars and Time Zones
- P1361 Integration of chrono with text formatting
- LWG3359 <chrono> leap second support should allow for negative leap seconds
@mordante mordante force-pushed the users/mordante/implements_utc_clock branch from ecf9334 to f7d3064 Compare January 23, 2025 18:14
@mordante
Copy link
Member Author

The formatting error is ignored; there seems to be an issue in clang-format where it formats things in a way it makes GCC unhappy. (The issue is in the test code, not in the library code.)

@mordante mordante merged commit 0cd794d into main Jan 24, 2025
78 of 79 checks passed
@mordante mordante deleted the users/mordante/implements_utc_clock branch January 24, 2025 17:56
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jan 24, 2025

LLVM Buildbot has detected a new failure on builder sanitizer-aarch64-linux-bootstrap-hwasan running on sanitizer-buildbot11 while building libcxx at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/55/builds/6086

Here is the relevant piece of the build log for the reference
Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxx/utils/libcxx/test/config.py:24: note: (llvm-libc++-shared.cfg.in) Using %{cxx} substitution: '/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build0/bin/clang++'
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxx/utils/libcxx/test/config.py:24: note: (llvm-libc++-shared.cfg.in) Using %{flags} substitution: '-pthread --target=aarch64-unknown-linux-gnu -g -fno-omit-frame-pointer -fsanitize=hwaddress'
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxx/utils/libcxx/test/config.py:24: note: (llvm-libc++-shared.cfg.in) Using %{compile_flags} substitution: '-nostdinc++ -I %{target-include-dir} -I %{include-dir} -I %{libcxx-dir}/test/support -std=c++26 -Werror -Wall -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier -Wdeprecated-copy -Wdeprecated-copy-dtor -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args -Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed -Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_ENABLE_EXPERIMENTAL -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE -Werror=thread-safety -Wuser-defined-warnings'
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxx/utils/libcxx/test/config.py:24: note: (llvm-libc++-shared.cfg.in) Using %{link_flags} substitution: '-lc++experimental -nostdlib++ -L %{lib-dir} -Wl,-rpath,%{lib-dir} -lc++ -latomic'
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxx/utils/libcxx/test/config.py:24: note: (llvm-libc++-shared.cfg.in) Using %{benchmark_flags} substitution: '-I /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxx/test/benchmarks/google-benchmark/include -L /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxx/test/benchmarks/google-benchmark/lib -L /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxx/test/benchmarks/google-benchmark/lib64 -l benchmark'
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxx/utils/libcxx/test/config.py:24: note: (llvm-libc++-shared.cfg.in) Using %{exec} substitution: '%{executor} --execdir %T -- '
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxx/utils/libcxx/test/config.py:24: note: (llvm-libc++-shared.cfg.in) All available features: add-latomic-workaround, buildhost=linux, c++26, c++experimental, can-create-symlinks, clang, clang-20, clang-20.0, clang-20.0.0, diagnose-if-support, enable-benchmarks=no, gcc-style-warnings, glibc-old-ru_RU-decimal-point, has-1024-bit-atomics, has-64-bit-atomics, has-fblocks, has-fconstexpr-steps, has-unix-headers, hwasan, large_tests, libcpp-abi-version=1, libcpp-hardening-mode=none, libcpp-has-no-availability-markup, libcpp-has-thread-api-pthread, linux, lsan, objective-c++, optimization=none, sanitizer-new-delete, stdlib=libc++, stdlib=llvm-libc++, target=aarch64-unknown-linux-gnu, thread-safety, verify-support
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 1500 seconds was requested on the command line. Forcing timeout to be 1500 seconds.
-- Testing: 10019 of 10038 tests, 72 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
FAIL: llvm-libc++abi-shared.cfg.in :: forced_unwind4.pass.cpp (9990 of 10019)
******************** TEST 'llvm-libc++abi-shared.cfg.in :: forced_unwind4.pass.cpp' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# COMPILED WITH
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build0/bin/clang++ /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxxabi/test/forced_unwind4.pass.cpp  --target=aarch64-unknown-linux-gnu -g -fno-omit-frame-pointer -fsanitize=hwaddress -nostdinc++ -I /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include -I /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1 -I /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/aarch64-unknown-linux-gnu/c++/v1  -I /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxxabi/../libcxx/test/support -I /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxxabi/../libcxx/src -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS -std=c++26 -Werror -Wall -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier -Wdeprecated-copy -Wdeprecated-copy-dtor -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args -Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed -Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -Werror=thread-safety -Wuser-defined-warnings  -nostdlib++ -L /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/lib -Wl,-rpath,/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/lib -lc++ -lc++abi -pthread -latomic -o /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test/Output/forced_unwind4.pass.cpp.dir/t.tmp.exe
# executed command: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build0/bin/clang++ /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxxabi/test/forced_unwind4.pass.cpp --target=aarch64-unknown-linux-gnu -g -fno-omit-frame-pointer -fsanitize=hwaddress -nostdinc++ -I /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include -I /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1 -I /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/aarch64-unknown-linux-gnu/c++/v1 -I /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxxabi/../libcxx/test/support -I /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxxabi/../libcxx/src -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS -std=c++26 -Werror -Wall -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier -Wdeprecated-copy -Wdeprecated-copy-dtor -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args -Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed -Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -Werror=thread-safety -Wuser-defined-warnings -nostdlib++ -L /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/lib -Wl,-rpath,/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/lib -lc++ -lc++abi -pthread -latomic -o /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test/Output/forced_unwind4.pass.cpp.dir/t.tmp.exe
# .---command stderr------------
# | In file included from /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxxabi/test/forced_unwind4.pass.cpp:25:
# | In file included from /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1/chrono:1009:
# | In file included from /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1/__chrono/formatter.h:20:
# | In file included from /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1/__chrono/convert_to_tm.h:27:
# | /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1/__chrono/utc_clock.h:94:11: error: unknown type name 'tzdb'
# |    94 |     const tzdb& __tzdb = chrono::get_tzdb();
# |       |           ^
# | /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1/__chrono/utc_clock.h:94:34: error: no member named 'get_tzdb' in namespace 'std::chrono'
# |    94 |     const tzdb& __tzdb = chrono::get_tzdb();
# |       |                          ~~~~~~~~^
# | /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1/__chrono/utc_clock.h:113:9: error: unknown type name 'tzdb'
# |   113 |   const tzdb& __tzdb = chrono::get_tzdb();
# |       |         ^
# | /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1/__chrono/utc_clock.h:113:32: error: no member named 'get_tzdb' in namespace 'std::chrono'
# |   113 |   const tzdb& __tzdb = chrono::get_tzdb();
# |       |                        ~~~~~~~~^
# | In file included from /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxxabi/test/forced_unwind4.pass.cpp:25:
# | In file included from /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1/chrono:1009:
# | In file included from /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1/__chrono/formatter.h:29:
# | In file included from /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1/__chrono/ostream.h:40:
# | In file included from /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1/sstream:323:
# | In file included from /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1/__ostream/basic_ostream.h:27:
# | /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1/bitset:385:59: error: shift count >= width of type [-Werror,-Wshift-count-overflow]
# |   385 |     __r |= static_cast<unsigned long long>(__first_[__i]) << (sizeof(__storage_type) * CHAR_BIT);
# |       |                                                           ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 5 errors generated.
# `-----------------------------
# error: command failed with exit status: 1

Step 10 (stage2/hwasan check-cxx) failure: stage2/hwasan check-cxx (failure)
...
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxx/utils/libcxx/test/config.py:24: note: (llvm-libc++-shared.cfg.in) Using %{cxx} substitution: '/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build0/bin/clang++'
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxx/utils/libcxx/test/config.py:24: note: (llvm-libc++-shared.cfg.in) Using %{flags} substitution: '-pthread --target=aarch64-unknown-linux-gnu -g -fno-omit-frame-pointer -fsanitize=hwaddress'
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxx/utils/libcxx/test/config.py:24: note: (llvm-libc++-shared.cfg.in) Using %{compile_flags} substitution: '-nostdinc++ -I %{target-include-dir} -I %{include-dir} -I %{libcxx-dir}/test/support -std=c++26 -Werror -Wall -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier -Wdeprecated-copy -Wdeprecated-copy-dtor -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args -Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed -Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_ENABLE_EXPERIMENTAL -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE -Werror=thread-safety -Wuser-defined-warnings'
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxx/utils/libcxx/test/config.py:24: note: (llvm-libc++-shared.cfg.in) Using %{link_flags} substitution: '-lc++experimental -nostdlib++ -L %{lib-dir} -Wl,-rpath,%{lib-dir} -lc++ -latomic'
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxx/utils/libcxx/test/config.py:24: note: (llvm-libc++-shared.cfg.in) Using %{benchmark_flags} substitution: '-I /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxx/test/benchmarks/google-benchmark/include -L /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxx/test/benchmarks/google-benchmark/lib -L /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxx/test/benchmarks/google-benchmark/lib64 -l benchmark'
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxx/utils/libcxx/test/config.py:24: note: (llvm-libc++-shared.cfg.in) Using %{exec} substitution: '%{executor} --execdir %T -- '
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxx/utils/libcxx/test/config.py:24: note: (llvm-libc++-shared.cfg.in) All available features: add-latomic-workaround, buildhost=linux, c++26, c++experimental, can-create-symlinks, clang, clang-20, clang-20.0, clang-20.0.0, diagnose-if-support, enable-benchmarks=no, gcc-style-warnings, glibc-old-ru_RU-decimal-point, has-1024-bit-atomics, has-64-bit-atomics, has-fblocks, has-fconstexpr-steps, has-unix-headers, hwasan, large_tests, libcpp-abi-version=1, libcpp-hardening-mode=none, libcpp-has-no-availability-markup, libcpp-has-thread-api-pthread, linux, lsan, objective-c++, optimization=none, sanitizer-new-delete, stdlib=libc++, stdlib=llvm-libc++, target=aarch64-unknown-linux-gnu, thread-safety, verify-support
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 1500 seconds was requested on the command line. Forcing timeout to be 1500 seconds.
-- Testing: 10019 of 10038 tests, 72 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
FAIL: llvm-libc++abi-shared.cfg.in :: forced_unwind4.pass.cpp (9990 of 10019)
******************** TEST 'llvm-libc++abi-shared.cfg.in :: forced_unwind4.pass.cpp' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# COMPILED WITH
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build0/bin/clang++ /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxxabi/test/forced_unwind4.pass.cpp  --target=aarch64-unknown-linux-gnu -g -fno-omit-frame-pointer -fsanitize=hwaddress -nostdinc++ -I /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include -I /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1 -I /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/aarch64-unknown-linux-gnu/c++/v1  -I /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxxabi/../libcxx/test/support -I /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxxabi/../libcxx/src -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS -std=c++26 -Werror -Wall -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier -Wdeprecated-copy -Wdeprecated-copy-dtor -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args -Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed -Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -Werror=thread-safety -Wuser-defined-warnings  -nostdlib++ -L /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/lib -Wl,-rpath,/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/lib -lc++ -lc++abi -pthread -latomic -o /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test/Output/forced_unwind4.pass.cpp.dir/t.tmp.exe
# executed command: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build0/bin/clang++ /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxxabi/test/forced_unwind4.pass.cpp --target=aarch64-unknown-linux-gnu -g -fno-omit-frame-pointer -fsanitize=hwaddress -nostdinc++ -I /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include -I /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1 -I /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/aarch64-unknown-linux-gnu/c++/v1 -I /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxxabi/../libcxx/test/support -I /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxxabi/../libcxx/src -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS -std=c++26 -Werror -Wall -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier -Wdeprecated-copy -Wdeprecated-copy-dtor -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args -Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed -Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -Werror=thread-safety -Wuser-defined-warnings -nostdlib++ -L /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/lib -Wl,-rpath,/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/lib -lc++ -lc++abi -pthread -latomic -o /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test/Output/forced_unwind4.pass.cpp.dir/t.tmp.exe
# .---command stderr------------
# | In file included from /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxxabi/test/forced_unwind4.pass.cpp:25:
# | In file included from /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1/chrono:1009:
# | In file included from /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1/__chrono/formatter.h:20:
# | In file included from /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1/__chrono/convert_to_tm.h:27:
# | /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1/__chrono/utc_clock.h:94:11: error: unknown type name 'tzdb'
# |    94 |     const tzdb& __tzdb = chrono::get_tzdb();
# |       |           ^
# | /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1/__chrono/utc_clock.h:94:34: error: no member named 'get_tzdb' in namespace 'std::chrono'
# |    94 |     const tzdb& __tzdb = chrono::get_tzdb();
# |       |                          ~~~~~~~~^
# | /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1/__chrono/utc_clock.h:113:9: error: unknown type name 'tzdb'
# |   113 |   const tzdb& __tzdb = chrono::get_tzdb();
# |       |         ^
# | /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1/__chrono/utc_clock.h:113:32: error: no member named 'get_tzdb' in namespace 'std::chrono'
# |   113 |   const tzdb& __tzdb = chrono::get_tzdb();
# |       |                        ~~~~~~~~^
# | In file included from /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/libcxxabi/test/forced_unwind4.pass.cpp:25:
# | In file included from /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1/chrono:1009:
# | In file included from /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1/__chrono/formatter.h:29:
# | In file included from /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1/__chrono/ostream.h:40:
# | In file included from /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1/sstream:323:
# | In file included from /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1/__ostream/basic_ostream.h:27:
# | /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/libcxx_build_hwasan/libcxxabi/test-suite-install/include/c++/v1/bitset:385:59: error: shift count >= width of type [-Werror,-Wshift-count-overflow]
# |   385 |     __r |= static_cast<unsigned long long>(__first_[__i]) << (sizeof(__storage_type) * CHAR_BIT);
# |       |                                                           ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 5 errors generated.
# `-----------------------------
# error: command failed with exit status: 1


@llvm-ci
Copy link
Collaborator

llvm-ci commented Jan 24, 2025

LLVM Buildbot has detected a new failure on builder llvm-clang-win-x-aarch64 running on as-builder-2 while building libcxx at step 14 "test-check-cxxabi-aarch64-unknown-linux-gnu".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/193/builds/5195

Here is the relevant piece of the build log for the reference
Step 14 (test-check-cxxabi-aarch64-unknown-linux-gnu) failure: Test just built components: check-cxxabi-aarch64-unknown-linux-gnu completed (failure)
******************** TEST 'llvm-libc++abi-static.cfg.in :: forced_unwind4.pass.cpp' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# COMPILED WITH
C:/buildbot/as-builder-2/x-aarch64/build/./bin/clang++.exe C:\buildbot\as-builder-2\x-aarch64\llvm-project\libcxxabi\test\forced_unwind4.pass.cpp  --target=aarch64-unknown-linux-gnu -nostdinc++ -I C:/buildbot/as-builder-2/x-aarch64/build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/libcxxabi/test-suite-install/include -I C:/buildbot/as-builder-2/x-aarch64/build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/libcxxabi/test-suite-install/include/c++/v1 -I C:/buildbot/as-builder-2/x-aarch64/build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/libcxxabi/test-suite-install/include/aarch64-unknown-linux-gnu/c++/v1 -I "C:/buildbot/as-builder-2/x-aarch64/llvm-project/libunwind/include" -I C:/buildbot/as-builder-2/x-aarch64/llvm-project/libcxxabi/../libcxx/test/support -I C:/buildbot/as-builder-2/x-aarch64/llvm-project/libcxxabi/../libcxx/src -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS -std=c++26 -Werror -Wall -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier -Wdeprecated-copy -Wdeprecated-copy-dtor -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args -Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed -Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -Werror=thread-safety -Wuser-defined-warnings  -nostdlib++ -L C:/buildbot/as-builder-2/x-aarch64/build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/libcxxabi/test-suite-install/lib/aarch64-unknown-linux-gnu -lc++ -lc++abi -pthread -latomic -o C:\buildbot\as-builder-2\x-aarch64\build\runtimes\runtimes-aarch64-unknown-linux-gnu-bins\libcxxabi\test\Output\forced_unwind4.pass.cpp.dir\t.tmp.exe
# executed command: C:/buildbot/as-builder-2/x-aarch64/build/./bin/clang++.exe 'C:\buildbot\as-builder-2\x-aarch64\llvm-project\libcxxabi\test\forced_unwind4.pass.cpp' --target=aarch64-unknown-linux-gnu -nostdinc++ -I C:/buildbot/as-builder-2/x-aarch64/build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/libcxxabi/test-suite-install/include -I C:/buildbot/as-builder-2/x-aarch64/build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/libcxxabi/test-suite-install/include/c++/v1 -I C:/buildbot/as-builder-2/x-aarch64/build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/libcxxabi/test-suite-install/include/aarch64-unknown-linux-gnu/c++/v1 -I C:/buildbot/as-builder-2/x-aarch64/llvm-project/libunwind/include -I C:/buildbot/as-builder-2/x-aarch64/llvm-project/libcxxabi/../libcxx/test/support -I C:/buildbot/as-builder-2/x-aarch64/llvm-project/libcxxabi/../libcxx/src -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS -std=c++26 -Werror -Wall -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier -Wdeprecated-copy -Wdeprecated-copy-dtor -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args -Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed -Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -Werror=thread-safety -Wuser-defined-warnings -nostdlib++ -L C:/buildbot/as-builder-2/x-aarch64/build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/libcxxabi/test-suite-install/lib/aarch64-unknown-linux-gnu -lc++ -lc++abi -pthread -latomic -o 'C:\buildbot\as-builder-2\x-aarch64\build\runtimes\runtimes-aarch64-unknown-linux-gnu-bins\libcxxabi\test\Output\forced_unwind4.pass.cpp.dir\t.tmp.exe'
# .---command stderr------------
# | In file included from C:\buildbot\as-builder-2\x-aarch64\llvm-project\libcxxabi\test\forced_unwind4.pass.cpp:25:
# | In file included from C:/buildbot/as-builder-2/x-aarch64/build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/libcxxabi/test-suite-install/include/c++/v1\chrono:1009:
# | In file included from C:/buildbot/as-builder-2/x-aarch64/build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/libcxxabi/test-suite-install/include/c++/v1\__chrono/formatter.h:20:
# | In file included from C:/buildbot/as-builder-2/x-aarch64/build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/libcxxabi/test-suite-install/include/c++/v1\__chrono/convert_to_tm.h:27:
# | C:/buildbot/as-builder-2/x-aarch64/build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/libcxxabi/test-suite-install/include/c++/v1\__chrono/utc_clock.h:94:11: error: unknown type name 'tzdb'
# |    94 |     const tzdb& __tzdb = chrono::get_tzdb();
# |       |           ^
# | C:/buildbot/as-builder-2/x-aarch64/build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/libcxxabi/test-suite-install/include/c++/v1\__chrono/utc_clock.h:94:34: error: no member named 'get_tzdb' in namespace 'std::chrono'
# |    94 |     const tzdb& __tzdb = chrono::get_tzdb();
# |       |                          ~~~~~~~~^
# | C:/buildbot/as-builder-2/x-aarch64/build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/libcxxabi/test-suite-install/include/c++/v1\__chrono/utc_clock.h:113:9: error: unknown type name 'tzdb'
# |   113 |   const tzdb& __tzdb = chrono::get_tzdb();
# |       |         ^
# | C:/buildbot/as-builder-2/x-aarch64/build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/libcxxabi/test-suite-install/include/c++/v1\__chrono/utc_clock.h:113:32: error: no member named 'get_tzdb' in namespace 'std::chrono'
# |   113 |   const tzdb& __tzdb = chrono::get_tzdb();
# |       |                        ~~~~~~~~^
# | In file included from C:\buildbot\as-builder-2\x-aarch64\llvm-project\libcxxabi\test\forced_unwind4.pass.cpp:25:
# | In file included from C:/buildbot/as-builder-2/x-aarch64/build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/libcxxabi/test-suite-install/include/c++/v1\chrono:1009:
# | In file included from C:/buildbot/as-builder-2/x-aarch64/build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/libcxxabi/test-suite-install/include/c++/v1\__chrono/formatter.h:29:
# | In file included from C:/buildbot/as-builder-2/x-aarch64/build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/libcxxabi/test-suite-install/include/c++/v1\__chrono/ostream.h:40:
# | In file included from C:/buildbot/as-builder-2/x-aarch64/build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/libcxxabi/test-suite-install/include/c++/v1\sstream:323:
# | In file included from C:/buildbot/as-builder-2/x-aarch64/build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/libcxxabi/test-suite-install/include/c++/v1\__ostream/basic_ostream.h:27:
# | C:/buildbot/as-builder-2/x-aarch64/build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/libcxxabi/test-suite-install/include/c++/v1\bitset:385:59: error: shift count >= width of type [-Werror,-Wshift-count-overflow]
# |   385 |     __r |= static_cast<unsigned long long>(__first_[__i]) << (sizeof(__storage_type) * CHAR_BIT);
# |       |                                                           ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 5 errors generated.
# `-----------------------------
# error: command failed with exit status: 1

--

********************


@asmok-g
Copy link

asmok-g commented Jan 30, 2025

Heads-up; this is probably causing an infinite loop in the compiler, where clang just halts forever. Working on a repro.

@asmok-g
Copy link

asmok-g commented Jan 30, 2025

Heads-up; this is probably causing an infinite loop in the compiler, where clang just halts forever. Working on a repro.

False alarm, this patch caused a failure that masked another in the root-causing.. I'll try to understand the relation between the culprits first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. pending-ci Merging the PR is only pending completion of CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants