From mboxrd@z Thu Jan 1 00:00:00 1970
Return-Path:
Received: by sourceware.org (Postfix, from userid 2181)
id AAD563858D1E; Sat, 14 Jan 2023 18:06:20 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AAD563858D1E
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org;
s=default; t=1673719580;
bh=bM/QRmbdi1dDEl1luF2E+/LWo2+H1EGh5OwMhwAW5Pg=;
h=From:To:Subject:Date:From;
b=efsmeqvAQS2fOb8wEFI0JoX8zw+vY+HzQqa3erzFtV50Xz6lK/iiemOtV4VtI2Waq
k49TEkBMqBTq5qPKkqzvjGEMUOmTJmsVEp1z8EdRpespEvGgdCLCRVB+ozV8tQZ1Vf
Gs3R0PG/NdL4WZYNaZ7UeX+YcFQsiqDTsF3bAEDM=
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="utf-8"
From: Jonathan Wakely
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r13-5168] libstdc++: Embed a static copy of tzdata.zi
X-Act-Checkin: gcc
X-Git-Author: Jonathan Wakely
X-Git-Refname: refs/heads/master
X-Git-Oldrev: ff6c7617102df365918402c6ccc8e497c47dbe60
X-Git-Newrev: 559993b85744ae09d33eedb1cb062392ac482f94
Message-Id: <20230114180620.AAD563858D1E@sourceware.org>
Date: Sat, 14 Jan 2023 18:06:20 +0000 (GMT)
List-Id:
https://gcc.gnu.org/g:559993b85744ae09d33eedb1cb062392ac482f94
commit r13-5168-g559993b85744ae09d33eedb1cb062392ac482f94
Author: Jonathan Wakely
Date: Sat Jan 14 13:33:58 2023 +0000
libstdc++: Embed a static copy of tzdata.zi
This adds a copy of the tzdata.zi file to the library, and allows
configuring to use it instead of a copy read from disk at runtime.
The content of the file is in the public domain, but will need to be
updated to the latest upstream file before making GCC releases.
libstdc++-v3/ChangeLog:
* acinclude.m4 (GLIBCXX_ZONEINFO_DIR): Replace the
--with-libstdcxx-zoneinfo-dir configure option with
--with-libstdcxx-zoneinfo with yes/no/static choices as well as
a directory.
* config.h.in: Regenerate.
* configure: Regenerate.
* doc/xml/manual/configure.xml: Document configure option.
* doc/html/manual/configure.html: Regenerate.
* src/c++20/Makefile.am: Generate tzdata.zi.h header.
* src/c++20/Makefile.in: Regenerate.
* src/c++20/tzdb.cc (__gnu_cxx::zoneinfo_dir_override): Return a
null pointer if no directory is configured.
(zoneinfo_dir): Replace with ...
(zoneinfo_file): New function.
(tzdata_stream): New istream class.
(remote_version, reload_tzdb): Use tzdata_stream.
* testsuite/lib/libstdc++.exp (check_effective_target_tzdb):
Check new _GLIBCXX_STATIC_TZDATA macro and ignore presence of
tzdata.zi file in default location.
* src/c++20/tzdata.zi: New file.
Diff:
---
libstdc++-v3/acinclude.m4 | 87 +-
libstdc++-v3/config.h.in | 5 +-
libstdc++-v3/configure | 121 +-
libstdc++-v3/doc/html/manual/configure.html | 21 +
libstdc++-v3/doc/xml/manual/configure.xml | 27 +
libstdc++-v3/src/c++20/Makefile.am | 13 +
libstdc++-v3/src/c++20/Makefile.in | 11 +
libstdc++-v3/src/c++20/tzdata.zi | 4207 +++++++++++++++++++++++++++
libstdc++-v3/src/c++20/tzdb.cc | 116 +-
libstdc++-v3/testsuite/lib/libstdc++.exp | 7 +-
10 files changed, 4543 insertions(+), 72 deletions(-)
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 51c3c510364..3840a9d761a 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -5157,28 +5157,87 @@ AC_DEFUN([GLIBCXX_EMERGENCY_EH_ALLOC], [
dnl
dnl Allow the location of tzdata files to be configured.
dnl
-dnl --with-libstdcxx-zoneinfo-dir=PATH will set the directory to PATH.
+dnl --with-libstdcxx-zoneinfo=ARG where ARG can be:
+dnl DIR - use DIR/tzdata.zi and DIR/leapseconds files.
+dnl static - use static copy of tzdata.zi embedded in the library.
+dnl DIR,static - use DIR, but use embedded static copy as fallback.
+dnl yes - equivalent to DIR,static with a system-specific value for DIR.
+dnl no - disable most tzdb functionality.
dnl
dnl Defines:
-dnl _GLIBCXX_ZONEINFO_DIR if std::chrono::tzdb should use a non-default
+dnl _GLIBCXX_ZONEINFO_DIR if std::chrono::tzdb should use the specified
dnl directory for the tzdata.zi and leapseconds files.
+dnl _GLIBCXX_STATIC_TZDATA if std::chrono::tzdb should use an embedded
+dnl static copy of the tzdata.zi file.
dnl
AC_DEFUN([GLIBCXX_ZONEINFO_DIR], [
- AC_ARG_WITH([libstdcxx-zoneinfo-dir],
- AC_HELP_STRING([--with-libstdcxx-zoneinfo-dir],
- [the directory to search for tzdata files]),
- [zoneinfo_dir="${withval}"
- AC_DEFINE(_GLIBCXX_ZONEINFO_DIR, "${withval}",
- [Define if a non-default location should be used for tzdata files.])
- ],
- [
+ AC_ARG_WITH([libstdcxx-zoneinfo],
+ AC_HELP_STRING([--with-libstdcxx-zoneinfo],
+ [the location to use for tzdata]),
+ [],[with_libstdcxx_zoneinfo=yes])
+
+ if test "x${with_libstdcxx_zoneinfo}" = xyes; then
+ # Pick a default when no specific path is set.
case "$host" in
- # *-*-aix*) zoneinfo_dir="/usr/share/lib/zoneinfo" ;;
- *) zoneinfo_dir="/usr/share/zoneinfo" ;;
+ gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
+ # Not all distros ship tzdata.zi in this dir.
+ zoneinfo_dir="/usr/share/zoneinfo"
+ ;;
+ *-*-aix*)
+ # Binary tzfile files are in /usr/share/lib/zoneinfo
+ # but tzdata.zi is not present there.
+ zoneinfo_dir=none
+ ;;
+ *-*-darwin2*)
+ # Binary tzfile files are in /usr/share/lib/zoneinfo.default
+ # but tzdata.zi is not present there.
+ zoneinfo_dir=none
+ ;;
+ *)
+ # Binary tzfile files are commonly found in /usr/share/zoneinfo
+ # but tzdata.zi is not present there.
+ zoneinfo_dir=none
+ ;;
esac
- ])
-
+ # Also embed a copy of the tzdata.zi file as a static string.
+ embed_zoneinfo=yes
+ elif test "x${with_libstdcxx_zoneinfo}" = xno; then
+ # Disable tzdb support completely.
+ zoneinfo_dir=none
+ embed_zoneinfo=no
+ else
+ case "${with_libstdcxx_zoneinfo}" in
+ static)
+ # Do not attempt to read from disk, always use embedded data.
+ zoneinfo_dir=none
+ embed_zoneinfo=yes
+ ;;
+ static,* | *,static)
+ # Try to read from disk, use embedded data as fallback.
+ zoneinfo_dir="${with_libstdcxx_zoneinfo#static,}"
+ zoneinfo_dir="${with_libstdcxx_zoneinfo%,static}"
+ embed_zoneinfo=yes
+ ;;
+ *)
+ zoneinfo_dir="${with_libstdcxx_zoneinfo}"
+ embed_zoneinfo=no
+ ;;
+ esac
+ fi
AC_MSG_NOTICE([zoneinfo data directory: ${zoneinfo_dir}])
+ if test "x${zoneinfo_dir}" != xnone; then
+ AC_DEFINE_UNQUOTED(_GLIBCXX_ZONEINFO_DIR, "${zoneinfo_dir}",
+ [Define if a directory should be searched for tzdata files.])
+ if $GLIBCXX_IS_NATIVE -a ! test -f "$zoneinfo_dir/tzdata.zi"; then
+ AC_MSG_WARN("$zoneinfo_dir does not contain tzdata.zi file")
+ fi
+ fi
+ GLIBCXX_CONDITIONAL(USE_STATIC_TZDATA, test "${embed_zoneinfo}" = yes)
+ if test "x${embed_zoneinfo}" = xyes; then
+ AC_MSG_NOTICE([static tzdata.zi file will be compiled into the library])
+ AC_DEFINE_UNQUOTED(_GLIBCXX_STATIC_TZDATA, 1,
+ [Define if static tzdata should be compiled into the library.])
+ fi
])
# Macros from the top-level gcc directory.
diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in
index 02119b9459e..75eddfd016d 100644
--- a/libstdc++-v3/config.h.in
+++ b/libstdc++-v3/config.h.in
@@ -854,6 +854,9 @@
/* Define if size_t is unsigned int. */
#undef _GLIBCXX_SIZE_T_IS_UINT
+/* Define if static tzdata should be compiled into the library. */
+#undef _GLIBCXX_STATIC_TZDATA
+
/* Define to the value of the EOF integer constant. */
#undef _GLIBCXX_STDIO_EOF
@@ -1037,7 +1040,7 @@
/* Defined if as can handle rdseed. */
#undef _GLIBCXX_X86_RDSEED
-/* Define if a non-default location should be used for tzdata files. */
+/* Define if a directory should be searched for tzdata files. */
#undef _GLIBCXX_ZONEINFO_DIR
/* Define to 1 if mutex_timedlock is available. */
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index bdcd8060797..ab12a2d5b27 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -675,6 +675,8 @@ DOT
DOXYGEN
BUILD_INFO_FALSE
BUILD_INFO_TRUE
+USE_STATIC_TZDATA_FALSE
+USE_STATIC_TZDATA_TRUE
EH_POOL_FLAGS
ENABLE_BACKTRACE_FALSE
ENABLE_BACKTRACE_TRUE
@@ -961,7 +963,7 @@ enable_libstdcxx_filesystem_ts
enable_libstdcxx_backtrace
enable_libstdcxx_static_eh_pool
with_libstdcxx_eh_pool_obj_count
-with_libstdcxx_zoneinfo_dir
+with_libstdcxx_zoneinfo
enable_cet
with_gxx_include_dir
enable_version_specific_runtime_libs
@@ -1705,8 +1707,8 @@ Optional Packages:
--with-libstdcxx-eh-pool-obj-count
the number of exceptions that can be allocated from
the pool if malloc fails
- --with-libstdcxx-zoneinfo-dir
- the directory to search for tzdata files
+ --with-libstdcxx-zoneinfo
+ the location to use for tzdata
--with-gxx-include-dir=DIR
installation directory for include files
--with-toolexeclibdir=DIR
@@ -12185,7 +12187,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12188 "configure"
+#line 12190 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -12291,7 +12293,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12294 "configure"
+#line 12296 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -16015,7 +16017,7 @@ $as_echo "$glibcxx_cv_atomic_long_long" >&6; }
# Fake what AC_TRY_COMPILE does.
cat > conftest.$ac_ext << EOF
-#line 16018 "configure"
+#line 16020 "configure"
int main()
{
typedef bool atomic_type;
@@ -16050,7 +16052,7 @@ $as_echo "$glibcxx_cv_atomic_bool" >&6; }
rm -f conftest*
cat > conftest.$ac_ext << EOF
-#line 16053 "configure"
+#line 16055 "configure"
int main()
{
typedef short atomic_type;
@@ -16085,7 +16087,7 @@ $as_echo "$glibcxx_cv_atomic_short" >&6; }
rm -f conftest*
cat > conftest.$ac_ext << EOF
-#line 16088 "configure"
+#line 16090 "configure"
int main()
{
// NB: _Atomic_word not necessarily int.
@@ -16121,7 +16123,7 @@ $as_echo "$glibcxx_cv_atomic_int" >&6; }
rm -f conftest*
cat > conftest.$ac_ext << EOF
-#line 16124 "configure"
+#line 16126 "configure"
int main()
{
typedef long long atomic_type;
@@ -16277,7 +16279,7 @@ $as_echo "mutex" >&6; }
# unnecessary for this test.
cat > conftest.$ac_ext << EOF
-#line 16280 "configure"
+#line 16282 "configure"
int main()
{
_Decimal32 d1;
@@ -16319,7 +16321,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
# unnecessary for this test.
cat > conftest.$ac_ext << EOF
-#line 16322 "configure"
+#line 16324 "configure"
template
struct same
{ typedef T2 type; };
@@ -71511,25 +71513,85 @@ fi
# For src/c++20/tzdb.cc defaults.
-# Check whether --with-libstdcxx-zoneinfo-dir was given.
-if test "${with_libstdcxx_zoneinfo_dir+set}" = set; then :
- withval=$with_libstdcxx_zoneinfo_dir; zoneinfo_dir="${withval}"
-
-$as_echo "#define _GLIBCXX_ZONEINFO_DIR \"\${withval}\"" >>confdefs.h
-
-
+# Check whether --with-libstdcxx-zoneinfo was given.
+if test "${with_libstdcxx_zoneinfo+set}" = set; then :
+ withval=$with_libstdcxx_zoneinfo;
else
+ with_libstdcxx_zoneinfo=yes
+fi
+
+ if test "x${with_libstdcxx_zoneinfo}" = xyes; then
+ # Pick a default when no specific path is set.
case "$host" in
- # *-*-aix*) zoneinfo_dir="/usr/share/lib/zoneinfo" ;;
- *) zoneinfo_dir="/usr/share/zoneinfo" ;;
+ gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
+ # Not all distros ship tzdata.zi in this dir.
+ zoneinfo_dir="/usr/share/zoneinfo"
+ ;;
+ *-*-aix*)
+ # Binary tzfile files are in /usr/share/lib/zoneinfo
+ # but tzdata.zi is not present there.
+ zoneinfo_dir=none
+ ;;
+ *-*-darwin2*)
+ # Binary tzfile files are in /usr/share/lib/zoneinfo.default
+ # but tzdata.zi is not present there.
+ zoneinfo_dir=none
+ ;;
+ *)
+ # Binary tzfile files are commonly found in /usr/share/zoneinfo
+ # but tzdata.zi is not present there.
+ zoneinfo_dir=none
+ ;;
esac
+ # Also embed a copy of the tzdata.zi file as a static string.
+ embed_zoneinfo=yes
+ elif test "x${with_libstdcxx_zoneinfo}" = xno; then
+ # Disable tzdb support completely.
+ zoneinfo_dir=none
+ embed_zoneinfo=no
+ else
+ case "${with_libstdcxx_zoneinfo}" in
+ static)
+ # Do not attempt to read from disk, always use embedded data.
+ zoneinfo_dir=none
+ embed_zoneinfo=yes
+ ;;
+ static,* | *,static)
+ # Try to read from disk, use embedded data as fallback.
+ zoneinfo_dir="${with_libstdcxx_zoneinfo#static,}"
+ zoneinfo_dir="${with_libstdcxx_zoneinfo%,static}"
+ embed_zoneinfo=yes
+ ;;
+ *)
+ zoneinfo_dir="${with_libstdcxx_zoneinfo}"
+ embed_zoneinfo=no
+ ;;
+ esac
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: zoneinfo data directory: ${zoneinfo_dir}" >&5
+$as_echo "$as_me: zoneinfo data directory: ${zoneinfo_dir}" >&6;}
+ if test "x${zoneinfo_dir}" != xnone; then
-fi
+cat >>confdefs.h <<_ACEOF
+#define _GLIBCXX_ZONEINFO_DIR "${zoneinfo_dir}"
+_ACEOF
+ if $GLIBCXX_IS_NATIVE -a ! test -f "$zoneinfo_dir/tzdata.zi"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \"$zoneinfo_dir does not contain tzdata.zi file\"" >&5
+$as_echo "$as_me: WARNING: \"$zoneinfo_dir does not contain tzdata.zi file\"" >&2;}
+ fi
+ fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: zoneinfo data directory: ${zoneinfo_dir}" >&5
-$as_echo "$as_me: zoneinfo data directory: ${zoneinfo_dir}" >&6;}
+ if test "x${embed_zoneinfo}" = xyes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: static tzdata.zi file will be compiled into the library" >&5
+$as_echo "$as_me: static tzdata.zi file will be compiled into the library" >&6;}
+
+cat >>confdefs.h <<_ACEOF
+#define _GLIBCXX_STATIC_TZDATA 1
+_ACEOF
+
+ fi
# Define documentation rules conditionally.
@@ -72365,6 +72427,15 @@ else
fi
+ if test "${embed_zoneinfo}" = yes; then
+ USE_STATIC_TZDATA_TRUE=
+ USE_STATIC_TZDATA_FALSE='#'
+else
+ USE_STATIC_TZDATA_TRUE='#'
+ USE_STATIC_TZDATA_FALSE=
+fi
+
+
cat >confcache <<\_ACEOF
@@ -72882,6 +72953,10 @@ if test -z "${ENABLE_BACKTRACE_TRUE}" && test -z "${ENABLE_BACKTRACE_FALSE}"; th
as_fn_error $? "conditional \"ENABLE_BACKTRACE\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
+if test -z "${USE_STATIC_TZDATA_TRUE}" && test -z "${USE_STATIC_TZDATA_FALSE}"; then
+ as_fn_error $? "conditional \"USE_STATIC_TZDATA\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
if test -z "${BUILD_INFO_TRUE}" && test -z "${BUILD_INFO_FALSE}"; then
as_fn_error $? "conditional \"BUILD_INFO\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
diff --git a/libstdc++-v3/doc/html/manual/configure.html b/libstdc++-v3/doc/html/manual/configure.html
index 66adc7d77b1..9c5c2d9f170 100644
--- a/libstdc++-v3/doc/html/manual/configure.html
+++ b/libstdc++-v3/doc/html/manual/configure.html
@@ -279,4 +279,25 @@
--with-libstdcxx-eh-pool-obj-count=NUM
Set the size of the emergency exception handling pool. NUM is the
number of simultaneous allocated exceptions to support.
This does not change the library ABI.
+
--with-libstdcxx-zoneinfo=OPTION
Choose how std::chrono::tzdb
will obtain
+ the time zone info. The library requires a copy of the
+ tzdata.zi
and leapseconds
+ files from the IANA Time Zone
+ Database. The choice OPTION=static will embed a copy of the files
+ into the library, and use that static data when time zone information
+ is required. The choice OPTION=dir will use the files
+ dir/tzdata.zi
and
+ dir/leapseconds
(which must exist when a program
+ tries to access time zone information). The choice OPTION=dir,static
+ will try to use files in dir
but if they are
+ not available the embedded static data will be used instead.
+ The default choice is OPTION=yes. This is equivalent to OPTION=dir,static
+ with a system-specific default directory (if a suitable default for
+ the target is known).
+ The choice OPTION=no will disable all code for loading time zone info
+ from file or from the embedded static data, which means that only the
+ "UTC" and "GMT" time zones are defined. Using OPTION=no results in a
+ smaller library, so is suitable for systems that will never need to
+ query the time zone database.
+ This does not change the library ABI.