From 6edaf4e79673682d7d77a05b14e3f6bdc9d2613c Mon Sep 17 00:00:00 2001 From: Ken Dreyer Date: Mon, 1 Dec 2014 18:24:22 -0700 Subject: [PATCH] heap_profiler: support new gperftools header locations The google/ headers location has been deprecated as of gperftools 2.0. As of gperftools 2.2rc, the google/ headers will now give deprecation warnings, and they will probably disappear in a future gperftools update. Signed-off-by: Ken Dreyer --- configure.ac | 8 +++++++- src/perfglue/cpu_profiler.cc | 13 +++++++++++-- src/perfglue/heap_profiler.cc | 19 +++++++++++++++++-- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 28e05746736..a671fef44cc 100644 --- a/configure.ac +++ b/configure.ac @@ -290,7 +290,13 @@ AC_ARG_WITH([profiler], [with_profiler=no]) AS_IF([test "x$with_profiler" = xyes], [AC_CHECK_LIB([profiler], [ProfilerFlush], [], - [AC_MSG_FAILURE([--with-profiler was given but libprofiler (libgoogle-perftools-dev on debian) not found])])], + [AC_MSG_FAILURE([--with-profiler was given but libprofiler (libgoogle-perftools-dev on debian) not found])]), + AC_LANG_PUSH([C++]), + AC_CHECK_HEADERS([gperftools/heap-profiler.h \ + gperftools/malloc_extension.h \ + gperftools/profiler.h]), + AC_LANG_POP([C++]) + ], []) AM_CONDITIONAL(WITH_PROFILER, test "$with_profiler" = "yes") AS_IF([test "$with_profiler" = "yes"], diff --git a/src/perfglue/cpu_profiler.cc b/src/perfglue/cpu_profiler.cc index 8ba15b0af1a..d2a69842090 100644 --- a/src/perfglue/cpu_profiler.cc +++ b/src/perfglue/cpu_profiler.cc @@ -12,11 +12,20 @@ * */ +#include "acconfig.h" + +// Use the newer gperftools header locations if available. +// If not, fall back to the old (gperftools < 2.0) locations. + +#ifdef HAVE_GPERFTOOLS_PROFILER_H + #include +#else + #include +#endif + #include "common/LogClient.h" #include "perfglue/cpu_profiler.h" -#include - void cpu_profiler_handle_command(const std::vector &cmd, ostream& out) { diff --git a/src/perfglue/heap_profiler.cc b/src/perfglue/heap_profiler.cc index dd082c63821..0fe1f9a43db 100644 --- a/src/perfglue/heap_profiler.cc +++ b/src/perfglue/heap_profiler.cc @@ -12,8 +12,23 @@ * */ -#include -#include +#include "acconfig.h" + +// Use the newer gperftools header locations if available. +// If not, fall back to the old (gperftools < 2.0) locations. + +#ifdef HAVE_GPERFTOOLS_HEAP_PROFILER_H + #include +#else + #include +#endif + +#ifdef HAVE_GPERFTOOLS_MALLOC_EXTENSION_H + #include +#else + #include +#endif + #include "heap_profiler.h" #include "common/environment.h" #include "common/LogClient.h" -- 2.47.3