From a510d1748416ff29b1ed3cab92ac0ad943b6e590 Mon Sep 17 00:00:00 2001 From: Jade Lovelace Date: Fri, 23 Aug 2024 16:57:26 -0700 Subject: build-time: hide boost stacktrace in a .cc file Saves about 16s of CPU time. Not a lot but not nothing. Feels more like the principle of the thing. Change-Id: I0992d4024317c20d6985a7977d5649edfb9f46bb --- src/libutil/fmt.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/libutil/fmt.cc') diff --git a/src/libutil/fmt.cc b/src/libutil/fmt.cc index 400fb7ea0..bff5af020 100644 --- a/src/libutil/fmt.cc +++ b/src/libutil/fmt.cc @@ -1,4 +1,9 @@ #include "fmt.hh" // IWYU pragma: keep +// Darwin and FreeBSD stdenv do not define _GNU_SOURCE but do have _Unwind_Backtrace. +#if __APPLE__ || __FreeBSD__ +#define BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED +#endif +#include template class boost::basic_format; @@ -11,4 +16,9 @@ template HintFmt::HintFmt(const std::string &, const uint64_t &, const char * co HintFmt::HintFmt(const std::string & literal) : HintFmt("%s", Uncolored(literal)) {} +void printStackTrace() +{ + std::cerr << boost::stacktrace::stacktrace() << std::endl; +} + } -- cgit v1.2.3