aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/fmt.cc
diff options
context:
space:
mode:
authorJade Lovelace <lix@jade.fyi>2024-08-23 16:57:26 -0700
committerRebecca Turner <rbt@sent.as>2024-08-28 09:55:09 -0700
commita510d1748416ff29b1ed3cab92ac0ad943b6e590 (patch)
tree7aada007847e6e90ae739365daff549f64b47678 /src/libutil/fmt.cc
parent04f8a1483362212f33f97c13472ded4121a18a86 (diff)
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
Diffstat (limited to 'src/libutil/fmt.cc')
-rw-r--r--src/libutil/fmt.cc10
1 files changed, 10 insertions, 0 deletions
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 <boost/stacktrace/stacktrace.hpp>
template class boost::basic_format<char>;
@@ -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;
+}
+
}