Bug 282377 - Missing std::chrono::current_zone in libc++ 19
Summary: Missing std::chrono::current_zone in libc++ 19
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-toolchain (Nobody)
URL: https://reviews.freebsd.org/D49577
Keywords:
Depends on:
Blocks:
 
Reported: 2024-10-28 06:08 UTC by Jan Beich
Modified: 2025-04-01 08:10 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Beich freebsd_committer freebsd_triage 2024-10-28 06:08:15 UTC
Added by https://github.com/llvm/llvm-project/commit/4167fec40768 but disabled in FreeBSD via _LIBCPP_HAS_NO_TIME_ZONE_DATABASE in libcxx/include/__config_site. Not sure where the rationale is documented ("git log" on the file is empty due to merges).

Required by x11/hyprlock to drop devel/date. tzdb support is part of C++20, supported by libstdc++ and not marked experimental in libc++.

src/renderer/widgets/IWidget.cpp:104:44: error: no member named 'current_zone' in namespace 'std::chrono'
  104 |     const auto current_zone = std::chrono::current_zone();
      |                               ~~~~~~~~~~~~~^
src/renderer/widgets/IWidget.cpp:113:44: error: no member named 'current_zone' in namespace 'std::chrono'
  113 |     const auto current_zone = std::chrono::current_zone();
      |                               ~~~~~~~~~~~~~^

https://pkg-status.freebsd.org/beefy18/data/main-amd64-default/p645a502a4f60_s8b2e7da7085/logs/errors/hyprlock-0.5.0.log
Comment 1 Jan Beich freebsd_committer freebsd_triage 2024-10-28 06:20:27 UTC
(In reply to Jan Beich from comment #0)
> not marked experimental in libc++

Oops, it *is* due to _LIBCPP_HAS_NO_EXPERIMENTAL_TZDB unless -fexperimental-library is passed. FreeBSD just disables that specific feature, so -fexperimental-library wouldn't help.
Comment 2 Jan Beich freebsd_committer freebsd_triage 2024-10-28 06:34:01 UTC
x11/waybar also wants std::chrono::current_zone but tries harder to support older C++ libraries, so didn't break on -CURRENT.
Comment 3 Dimitry Andric freebsd_committer freebsd_triage 2024-10-29 18:05:49 UTC
At the moment upstream only really supports LIBCXX_ENABLE_TIME_ZONE_DATABASE on Linux, other OSes are apparently entirely untested.

I tried configuring libc++ with this option turned on, but the experimental tzdb.cpp did not even compile. :) Now that was quite easily fixed with an additional #ifdef, but then it turns out that reading the time zone information does not work at runtime either.

It assumes there is a file called /usr/share/zoneinfo/tzdata.zi, which apparently is a shrunk version of (most of?) the time zone database. In FreeBSD we do have /usr/share/zoneinfo, but not a tzdata.zi file. Since libc++'s tzdb parser depends on the exact text format of this file, we would first have to add it to the base system.

It looks like this format could be produced by contrib/tzdata/zishrink.awk, but I am definitely not an expert in this area, therefore I'm putting Philip on CC. :)
Comment 4 Philip Paeps freebsd_committer freebsd_triage 2024-10-29 22:15:21 UTC
There's a build knob in tzdata to generate that file.  I'll try to remember how to turn that on.

Cc:ing DES since he's been working in tzcode-land and may have opinions too.
Comment 5 commit-hook freebsd_committer freebsd_triage 2025-04-01 08:10:26 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=91506dba7f2eb147eeb55ec30640bc11755a1e8e

commit 91506dba7f2eb147eeb55ec30640bc11755a1e8e
Author:     Philip Paeps <philip@FreeBSD.org>
AuthorDate: 2025-04-01 08:09:37 +0000
Commit:     Philip Paeps <philip@FreeBSD.org>
CommitDate: 2025-04-01 08:09:37 +0000

    zoneinfo: also install tzdata.zi and version

    Build and install the shrunk version of the time zone database required
    by libc++ 19 std::chrono::current_zone (etc).  While here, also install
    the tzdata 'version' file to align more closely with other vendors.

    PR:             282377
    Reviewed by:    dim, emaste, imp
    Differential Revision:  https://reviews.freebsd.org/D49577

 share/zoneinfo/Makefile | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)