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
(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.
x11/waybar also wants std::chrono::current_zone but tries harder to support older C++ libraries, so didn't break on -CURRENT.
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. :)
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.
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(+)
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=4aed98a65ac91a65dc711fe1df5bdd1842d5c391 commit 4aed98a65ac91a65dc711fe1df5bdd1842d5c391 Author: Philip Paeps <philip@FreeBSD.org> AuthorDate: 2025-04-01 08:09:37 +0000 Commit: Philip Paeps <philip@FreeBSD.org> CommitDate: 2025-05-01 00:51:12 +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 (cherry picked from commit 91506dba7f2eb147eeb55ec30640bc11755a1e8e) share/zoneinfo/Makefile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=3502f06c6686fbb8335872b8bb3b951b549d8b2f commit 3502f06c6686fbb8335872b8bb3b951b549d8b2f Author: Philip Paeps <philip@FreeBSD.org> AuthorDate: 2025-04-01 08:09:37 +0000 Commit: Philip Paeps <philip@FreeBSD.org> CommitDate: 2025-05-06 01:57:32 +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 (cherry picked from commit 91506dba7f2eb147eeb55ec30640bc11755a1e8e) share/zoneinfo/Makefile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
^Triage: assign to committer who resolved.
https://en.cppreference.com/w/cpp/chrono/current_zone.html still fails because _LIBCPP_HAS_NO_TIME_ZONE_DATABASE (in lib/libc++/__config_site) blocks std::chrono::current_zone even with -fexperimental-library. This bug was originally opened against libc++, so it's not complete until libc++ is fixed.
Do you need me to do anything else for this?
Created attachment 265387 [details] [incomplete] Enable tzdb in libc++ Not sure. Waiting for feedback from Clang/libc++ maintainer. With the attached patch cppreference's example successfully compiles but doesn't seem to work. $ c++ -std=c++20 -fexperimental-library -o test_tzdb test_tzdb.cc $ export TZ=UTC $ ./test_tzdb corrupt tzdb: expected a digit $ truss ./test_tzdb |& fgrep -B5 "corrupt tzdb" open("/usr/share/zoneinfo/tzdata.zi",O_RDONLY,0666) = 3 (0x3) fstat(3,{ mode=-r--r--r-- ,inode=15587,size=107651,blksize=108032 }) = 0 (0x0) read(3,"# version 2025b\n# redo posix_on"...,108032) = 107651 (0x1a483) lseek(3,0x0,SEEK_CUR) = 107651 (0x1a483) close(3) = 0 (0x0) corrupt tzdb: expected a digitwrite(2,"corrupt tzdb: expected a digit",30) = 30 (0x1e)
Replacing /usr/share/zoneinfo/tzdata.zi with https://data.iana.org/time-zones/tzdb-2025b/tzdata.zi makes it work. The cause is the following: -Z Factory 0 - -00 +Z Factory 0 - "Local time zone must be set--use tzsetup"