From: Jonathan Wakely Date: Tue, 19 May 2026 15:13:15 +0000 (+0100) Subject: libstdc++: Use #embed for static tzdata.zi file X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=601cc5ae31d8393da9b7a1047d61343bc25df9ea;p=thirdparty%2Fgcc.git 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 --- diff --git a/libstdc++-v3/src/c++20/Makefile.am b/libstdc++-v3/src/c++20/Makefile.am index 5182d51b9fa..cfd09bddffc 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__(' > $@.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 $< diff --git a/libstdc++-v3/src/c++20/Makefile.in b/libstdc++-v3/src/c++20/Makefile.in index 33e3ba21b52..067419d2e48 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. @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 $< diff --git a/libstdc++-v3/src/c++20/tzdb.cc b/libstdc++-v3/src/c++20/tzdb.cc index 183a0c61a61..5793155b6d8 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(tzdata_chars); - this->setg(p, p, p + std::size(tzdata_chars) - 1); + this->setg(p, p, p + std::size(tzdata_chars)); #endif }