diff options
author | Jade Lovelace <lix@jade.fyi> | 2024-08-22 21:02:52 -0700 |
---|---|---|
committer | Rebecca Turner <rbt@sent.as> | 2024-08-28 09:52:05 -0700 |
commit | 4d8984420788d6253d2fd9bfa3ada92be8bfd73b (patch) | |
tree | d5db726ff1b87672c01f04e27064d5188d27d45a /src/libutil/fmt.hh | |
parent | 422550fd68a5877534b1ca577fc3c7d89b6706dd (diff) |
build: remove about 30 cpu-sec of compile time by explicit instantiation
Apparently the fmt contraption has some extremely popular overloads, and
the boost stuff in there gets built approximately infinite times in
every compilation unit.
Change-Id: Ideba2db7d6bf8559e4d91974bab636f5ed106198
Diffstat (limited to 'src/libutil/fmt.hh')
-rw-r--r-- | src/libutil/fmt.hh | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/libutil/fmt.hh b/src/libutil/fmt.hh index d015f7e5f..7589e51e2 100644 --- a/src/libutil/fmt.hh +++ b/src/libutil/fmt.hh @@ -3,7 +3,6 @@ #include <iostream> #include <string> -#include <optional> #include <boost/format.hpp> // Darwin and FreeBSD stdenv do not define _GNU_SOURCE but do have _Unwind_Backtrace. #if __APPLE__ || __FreeBSD__ @@ -12,6 +11,9 @@ #include <boost/stacktrace.hpp> #include "ansicolor.hh" +// Explicit instantiation in fmt.cc +extern template class boost::basic_format<char>; + namespace nix { /** @@ -157,7 +159,9 @@ public: * Format the given string literally, without interpolating format * placeholders. */ - HintFmt(const std::string & literal) : HintFmt("%s", Uncolored(literal)) {} + // Moved out of line because it was instantiating the template below in + // every file in the project. + HintFmt(const std::string & literal); /** * Interpolate the given arguments into the format string. @@ -193,6 +197,11 @@ public: } }; +// Explicit instantiations in fmt.cc +extern template HintFmt::HintFmt(const std::string &, const Uncolored<std::string> &s); +extern template HintFmt::HintFmt(const std::string &, const std::string &s); +extern template HintFmt::HintFmt(const std::string &, const uint64_t &, const char * const &); + std::ostream & operator<<(std::ostream & os, const HintFmt & hf); } |