https://gcc.gnu.org/g:601cc5ae31d8393da9b7a1047d61343bc25df9ea

commit r17-622-g601cc5ae31d8393da9b7a1047d61343bc25df9ea
Author: Jonathan Wakely <[email protected]>
Date:   Tue May 19 16:13:15 2026 +0100

    libstdc++: Use #embed for static tzdata.zi file
    
    This doesn't make much difference to the time taken to compile tzdb.cc
    but it is simpler and more maintainable than generating a header in the
    makefile.
    
    libstdc++-v3/ChangeLog:
    
            * src/c++20/Makefile.am [USE_STATIC_TZDATA]: Remove targets for
            tzdata.zi.h, tzdb.lo and tzdb.o.
            * src/c++20/Makefile.in: Regenerate.
            * src/c++20/tzdb.cc (tzdata_chars): Use #embed.
            (tzdata_stream::ispanbuf): Remove adjustment for extra newline
            inserted by the Makefile recipe for tzdata.zi.h.
    
    Reviewed-by: Tomasz KamiƄski <[email protected]>

Diff:
---
 libstdc++-v3/src/c++20/Makefile.am | 13 -------------
 libstdc++-v3/src/c++20/Makefile.in | 11 -----------
 libstdc++-v3/src/c++20/tzdb.cc     |  8 +++++---
 3 files changed, 5 insertions(+), 27 deletions(-)

diff --git a/libstdc++-v3/src/c++20/Makefile.am 
b/libstdc++-v3/src/c++20/Makefile.am
index 5182d51b9faa..cfd09bddffcb 100644
--- a/libstdc++-v3/src/c++20/Makefile.am
+++ b/libstdc++-v3/src/c++20/Makefile.am
@@ -54,19 +54,6 @@ if ENABLE_DUAL_ABI
 cow-string-inst.lo cow-string-inst.o: string-inst.cc
 endif
 
-if USE_STATIC_TZDATA
-tzdata.zi.h: $(top_srcdir)/src/c++20/tzdata.zi
-       echo 'static const char tzdata_chars[] = R"__libstdcxx__(' > [email protected]
-       cat $^ >> [email protected]
-       echo ')__libstdcxx__";' >> [email protected]
-       mv [email protected] $@
-
-tzdb.lo: tzdb.cc tzdata.zi.h
-       $(LTCXXCOMPILE) -I. -c $<
-tzdb.o: tzdb.cc tzdata.zi.h
-       $(CXXCOMPILE) -I. -c $<
-endif
-
 # This needs access to std::text_encoding and to the internals of std::locale.
 format.lo: format.cc
        $(LTCXXCOMPILE) -std=gnu++26 -fno-access-control -c $<
diff --git a/libstdc++-v3/src/c++20/Makefile.in 
b/libstdc++-v3/src/c++20/Makefile.in
index 33e3ba21b522..067419d2e485 100644
--- a/libstdc++-v3/src/c++20/Makefile.in
+++ b/libstdc++-v3/src/c++20/Makefile.in
@@ -758,17 +758,6 @@ vpath % $(top_srcdir)/src/c++20
 # These files should be rebuilt if the .cc prerequisite changes.
 @[email protected] cow-string-inst.o: string-inst.cc
 
-@[email protected]: $(top_srcdir)/src/c++20/tzdata.zi
-@USE_STATIC_TZDATA_TRUE@       echo 'static const char tzdata_chars[] = 
R"__libstdcxx__(' > [email protected]
-@USE_STATIC_TZDATA_TRUE@       cat $^ >> [email protected]
-@USE_STATIC_TZDATA_TRUE@       echo ')__libstdcxx__";' >> [email protected]
-@USE_STATIC_TZDATA_TRUE@       mv [email protected] $@
-
-@[email protected]: tzdb.cc tzdata.zi.h
-@USE_STATIC_TZDATA_TRUE@       $(LTCXXCOMPILE) -I. -c $<
-@[email protected]: tzdb.cc tzdata.zi.h
-@USE_STATIC_TZDATA_TRUE@       $(CXXCOMPILE) -I. -c $<
-
 # This needs access to std::text_encoding and to the internals of std::locale.
 format.lo: format.cc
        $(LTCXXCOMPILE) -std=gnu++26 -fno-access-control -c $<
diff --git a/libstdc++-v3/src/c++20/tzdb.cc b/libstdc++-v3/src/c++20/tzdb.cc
index 183a0c61a616..5793155b6d89 100644
--- a/libstdc++-v3/src/c++20/tzdb.cc
+++ b/libstdc++-v3/src/c++20/tzdb.cc
@@ -1208,8 +1208,10 @@ namespace std::chrono
     const string_view leaps_file = "/leapseconds";
 
 #ifdef _GLIBCXX_STATIC_TZDATA
-// Static copy of tzdata.zi embedded in the library as tzdata_chars[]
-#include "tzdata.zi.h"
+// Static copy of tzdata.zi embedded in the library.
+static constexpr char tzdata_chars[] = {
+#embed "tzdata.zi"
+};
 #endif
 
     // An istream type that can read from a file or from a string.
@@ -1222,7 +1224,7 @@ namespace std::chrono
        {
 #ifdef _GLIBCXX_STATIC_TZDATA
          char* p = const_cast<char*>(tzdata_chars);
-         this->setg(p, p, p + std::size(tzdata_chars) - 1);
+         this->setg(p, p, p + std::size(tzdata_chars));
 #endif
        }

Reply via email to