]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Use #embed for static tzdata.zi file
authorJonathan Wakely <jwakely@redhat.com>
Tue, 19 May 2026 15:13:15 +0000 (16:13 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 20 May 2026 12:18:46 +0000 (13:18 +0100)
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 <tkaminsk@redhat.com>
libstdc++-v3/src/c++20/Makefile.am
libstdc++-v3/src/c++20/Makefile.in
libstdc++-v3/src/c++20/tzdb.cc

index 5182d51b9faaba8f577b70833a9fda6bb5abbb7a..cfd09bddffcbdc9552c88b60ead398af97729041 100644 (file)
@@ -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__(' > $@.tmp
-       cat $^ >> $@.tmp
-       echo ')__libstdcxx__";' >> $@.tmp
-       mv $@.tmp $@
-
-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 $<
index 33e3ba21b522bbbf328d02baee0e12e6765974c8..067419d2e485de4f9901b0716acfccb6101f9ffe 100644 (file)
@@ -758,17 +758,6 @@ vpath % $(top_srcdir)/src/c++20
 # These files should be rebuilt if the .cc prerequisite changes.
 @ENABLE_DUAL_ABI_TRUE@cow-string-inst.lo cow-string-inst.o: string-inst.cc
 
-@USE_STATIC_TZDATA_TRUE@tzdata.zi.h: $(top_srcdir)/src/c++20/tzdata.zi
-@USE_STATIC_TZDATA_TRUE@       echo 'static const char tzdata_chars[] = R"__libstdcxx__(' > $@.tmp
-@USE_STATIC_TZDATA_TRUE@       cat $^ >> $@.tmp
-@USE_STATIC_TZDATA_TRUE@       echo ')__libstdcxx__";' >> $@.tmp
-@USE_STATIC_TZDATA_TRUE@       mv $@.tmp $@
-
-@USE_STATIC_TZDATA_TRUE@tzdb.lo: tzdb.cc tzdata.zi.h
-@USE_STATIC_TZDATA_TRUE@       $(LTCXXCOMPILE) -I. -c $<
-@USE_STATIC_TZDATA_TRUE@tzdb.o: 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 $<
index 183a0c61a616c461622b772e101eaa534621191d..5793155b6d89a35754e8b85429f8f675d80afa3b 100644 (file)
@@ -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
        }