2007-03-22 03:00:33 +00:00
|
|
|
## Process this file with autoconf to produce configure.
|
2007-07-18 18:30:50 +00:00
|
|
|
## In general, the safest way to proceed is to run ./autogen.sh
|
2007-03-22 03:00:33 +00:00
|
|
|
|
|
|
|
# make sure we're interpreted by some minimal autoconf
|
2023-06-21 14:37:51 +00:00
|
|
|
AC_PREREQ([2.69])
|
2007-03-22 03:00:33 +00:00
|
|
|
|
2024-01-05 17:23:30 +00:00
|
|
|
AC_INIT([gperftools],[2.15],[gperftools@googlegroups.com])
|
2011-02-05 00:19:37 +00:00
|
|
|
# Update this value for every release! (A:B:C will map to foo.so.(A-C).C.B)
|
|
|
|
# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
|
2024-01-05 17:23:30 +00:00
|
|
|
TCMALLOC_SO_VERSION=9:16:5
|
|
|
|
PROFILER_SO_VERSION=5:11:5
|
|
|
|
TCMALLOC_AND_PROFILER_SO_VERSION=10:11:6
|
2010-11-18 01:07:25 +00:00
|
|
|
|
|
|
|
AC_SUBST(TCMALLOC_SO_VERSION)
|
|
|
|
AC_SUBST(PROFILER_SO_VERSION)
|
2020-07-06 09:51:43 +00:00
|
|
|
AC_SUBST(TCMALLOC_AND_PROFILER_SO_VERSION)
|
2010-11-18 01:07:25 +00:00
|
|
|
|
2007-03-22 03:00:33 +00:00
|
|
|
# The argument here is just something that should be in the current directory
|
|
|
|
# (for sanity checking)
|
|
|
|
AC_CONFIG_SRCDIR(README)
|
2010-11-18 01:07:25 +00:00
|
|
|
AC_CONFIG_MACRO_DIR([m4])
|
2009-03-11 20:50:03 +00:00
|
|
|
AC_CANONICAL_HOST
|
2023-06-27 05:43:44 +00:00
|
|
|
AM_INIT_AUTOMAKE([dist-zip foreign])
|
2012-11-04 17:21:00 +00:00
|
|
|
AC_CONFIG_HEADERS([src/config.h])
|
2007-03-22 03:00:33 +00:00
|
|
|
|
2013-12-06 20:23:48 +00:00
|
|
|
AM_MAINTAINER_MODE()
|
2009-09-11 18:42:32 +00:00
|
|
|
# Export the version information (for tc_version and friends)
|
|
|
|
TC_VERSION_MAJOR=`expr "$PACKAGE_VERSION" : '\([[0-9]]*\)'`
|
2011-08-11 22:06:22 +00:00
|
|
|
TC_VERSION_MINOR=`expr "$PACKAGE_VERSION" : '[[0-9]]*\.\([[0-9]]*\)'`
|
|
|
|
TC_VERSION_PATCH=`expr "$PACKAGE_VERSION" : '[[0-9]]*\.[[0-9]]*\(.*\)$'`
|
2009-09-11 18:42:32 +00:00
|
|
|
AC_SUBST(TC_VERSION_MAJOR)
|
|
|
|
AC_SUBST(TC_VERSION_MINOR)
|
|
|
|
AC_SUBST(TC_VERSION_PATCH)
|
|
|
|
AC_SUBST(PACKAGE_STRING)
|
|
|
|
|
2009-03-11 20:50:03 +00:00
|
|
|
# The user can choose not to compile in the heap-profiler, the
|
|
|
|
# heap-checker, or the cpu-profiler. There's also the possibility
|
|
|
|
# for a 'fully minimal' compile, which leaves out the stacktrace
|
|
|
|
# code as well. By default, we include all of these that the
|
|
|
|
# target system supports.
|
|
|
|
default_enable_cpu_profiler=yes
|
|
|
|
default_enable_heap_profiler=yes
|
2023-06-21 14:39:38 +00:00
|
|
|
# heap checker is Linux-only.
|
2023-06-21 14:39:25 +00:00
|
|
|
default_enable_heap_checker=no
|
2023-06-21 14:39:38 +00:00
|
|
|
heap_checker_supported=no
|
2009-09-11 18:42:32 +00:00
|
|
|
default_enable_debugalloc=yes
|
2009-03-11 20:50:03 +00:00
|
|
|
default_enable_minimal=no
|
2014-12-23 12:29:49 +00:00
|
|
|
default_tcmalloc_alignment=16
|
2023-06-21 14:39:38 +00:00
|
|
|
heap_checker_is_default=no
|
2009-03-11 20:50:03 +00:00
|
|
|
need_nanosleep=yes # Used later, to decide if to run ACX_NANOSLEEP
|
|
|
|
case "$host" in
|
2009-09-11 18:42:32 +00:00
|
|
|
*-mingw*) default_enable_minimal=yes; default_enable_debugalloc=no;
|
|
|
|
need_nanosleep=no;;
|
2023-06-21 14:39:25 +00:00
|
|
|
*-cygwin*) default_enable_cpu_profiler=no;;
|
2023-06-21 14:39:38 +00:00
|
|
|
*-linux*) default_enable_heap_checker=yes; heap_checker_supported=yes;;
|
2009-03-11 20:50:03 +00:00
|
|
|
esac
|
|
|
|
|
2021-03-01 01:52:17 +00:00
|
|
|
# Currently only backtrace works on s390 and OSX.
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [
|
|
|
|
#if !defined(__s390__) && !defined(__APPLE__)
|
|
|
|
#error not s390 and not osx
|
|
|
|
#endif
|
|
|
|
return 1
|
|
|
|
])],
|
2016-01-22 17:26:47 +00:00
|
|
|
[default_enable_libunwind=no
|
|
|
|
default_enable_backtrace=yes],
|
|
|
|
[default_enable_libunwind=yes
|
|
|
|
default_enable_backtrace=no])
|
|
|
|
|
2014-11-27 16:11:09 +00:00
|
|
|
# Disable libunwind linking on ppc64 by default.
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [return __PPC64__])],
|
2014-12-23 12:55:22 +00:00
|
|
|
[default_enable_libunwind=no
|
|
|
|
default_tcmalloc_pagesize=64],
|
|
|
|
[default_enable_libunwind=yes
|
|
|
|
default_tcmalloc_pagesize=8])
|
2014-11-27 16:11:09 +00:00
|
|
|
|
2009-03-11 20:50:03 +00:00
|
|
|
AC_ARG_ENABLE([cpu-profiler],
|
|
|
|
[AS_HELP_STRING([--disable-cpu-profiler],
|
|
|
|
[do not build the cpu profiler])],
|
|
|
|
[],
|
|
|
|
[enable_cpu_profiler="$default_enable_cpu_profiler"])
|
|
|
|
AC_ARG_ENABLE([heap-profiler],
|
|
|
|
[AS_HELP_STRING([--disable-heap-profiler],
|
|
|
|
[do not build the heap profiler])],
|
|
|
|
[],
|
|
|
|
[enable_heap_profiler="$default_enable_heap_profiler"])
|
|
|
|
AC_ARG_ENABLE([heap-checker],
|
|
|
|
[AS_HELP_STRING([--disable-heap-checker],
|
|
|
|
[do not build the heap checker])],
|
|
|
|
[],
|
2023-06-21 14:39:38 +00:00
|
|
|
[enable_heap_checker="$default_enable_heap_checker"; heap_checker_is_default=yes])
|
2009-09-11 18:42:32 +00:00
|
|
|
AC_ARG_ENABLE([debugalloc],
|
|
|
|
[AS_HELP_STRING([--disable-debugalloc],
|
|
|
|
[do not build versions of libs with debugalloc])],
|
|
|
|
[],
|
|
|
|
[enable_debugalloc="$default_enable_debugalloc"])
|
2009-03-11 20:50:03 +00:00
|
|
|
AC_ARG_ENABLE([minimal],
|
|
|
|
[AS_HELP_STRING([--enable-minimal],
|
2009-09-11 18:42:32 +00:00
|
|
|
[build only tcmalloc-minimal (and maybe tcmalloc-minimal-debug)])],
|
2009-03-11 20:50:03 +00:00
|
|
|
[],
|
|
|
|
[enable_minimal="$default_enable_minimal"])
|
|
|
|
if test "$enable_minimal" = yes; then
|
|
|
|
enable_cpu_profiler=no
|
|
|
|
enable_heap_profiler=no
|
|
|
|
enable_heap_checker=no
|
|
|
|
fi
|
2014-04-12 19:38:19 +00:00
|
|
|
AC_ARG_ENABLE([stacktrace-via-backtrace],
|
|
|
|
[AS_HELP_STRING([--enable-stacktrace-via-backtrace],
|
|
|
|
[enable use of backtrace() for stacktrace capturing (may deadlock)])],
|
|
|
|
[enable_backtrace=yes],
|
2016-01-22 17:26:47 +00:00
|
|
|
[enable_backtrace="$default_enable_backtrace"])
|
2023-07-23 00:45:52 +00:00
|
|
|
AC_ARG_ENABLE([libgcc-unwinder-by-default],
|
|
|
|
[AS_HELP_STRING([--enable-libgcc-unwinder-by-default],
|
|
|
|
[prefer libgcc's _Unwind_Backtrace as default stacktrace capturing method])],
|
|
|
|
[enable_libgcc_by_default=yes],
|
|
|
|
[enable_libgcc_by_default=no])
|
|
|
|
AS_IF([test "x$enable_libgcc_by_default" = xyes],
|
|
|
|
[AC_DEFINE(PREFER_LIBGCC_UNWINDER, 1, [if libgcc stacktrace method should be default])])
|
2014-11-27 16:11:09 +00:00
|
|
|
AC_ARG_ENABLE([libunwind],
|
|
|
|
[AS_HELP_STRING([--enable-libunwind],
|
|
|
|
[enable libunwind linking])],
|
|
|
|
[],
|
|
|
|
[enable_libunwind="$default_enable_libunwind"])
|
2014-12-23 12:29:49 +00:00
|
|
|
AC_ARG_WITH([tcmalloc-pagesize],
|
|
|
|
[AS_HELP_STRING([--with-tcmalloc-pagesize],
|
2019-01-29 18:25:40 +00:00
|
|
|
[Set the tcmalloc internal page size to 4K, 8K, 16K, 32K, 64K, 128K or 256K])],
|
2014-12-23 12:29:49 +00:00
|
|
|
[],
|
|
|
|
[with_tcmalloc_pagesize=$default_tcmalloc_pagesize])
|
|
|
|
AC_ARG_WITH([tcmalloc-alignment],
|
|
|
|
[AS_HELP_STRING([--with-tcmalloc-alignment],
|
|
|
|
[Set the tcmalloc allocation alignment to 8 or 16 bytes])],
|
|
|
|
[],
|
|
|
|
[with_tcmalloc_alignment=$default_tcmalloc_alignment])
|
|
|
|
|
|
|
|
case "$with_tcmalloc_pagesize" in
|
2019-01-29 18:25:40 +00:00
|
|
|
4)
|
|
|
|
AC_DEFINE(TCMALLOC_PAGE_SIZE_SHIFT, 12);;
|
2014-12-23 12:29:49 +00:00
|
|
|
8)
|
|
|
|
#Default tcmalloc page size.
|
|
|
|
;;
|
2019-01-29 18:25:40 +00:00
|
|
|
16)
|
|
|
|
AC_DEFINE(TCMALLOC_PAGE_SIZE_SHIFT, 14);;
|
2014-12-23 12:29:49 +00:00
|
|
|
32)
|
2019-01-29 18:25:40 +00:00
|
|
|
AC_DEFINE(TCMALLOC_PAGE_SIZE_SHIFT, 15);;
|
2014-12-23 12:29:49 +00:00
|
|
|
64)
|
2019-01-29 18:25:40 +00:00
|
|
|
AC_DEFINE(TCMALLOC_PAGE_SIZE_SHIFT, 16);;
|
|
|
|
128)
|
|
|
|
AC_DEFINE(TCMALLOC_PAGE_SIZE_SHIFT, 17);;
|
|
|
|
256)
|
|
|
|
AC_DEFINE(TCMALLOC_PAGE_SIZE_SHIFT, 18,
|
|
|
|
[Define internal page size for tcmalloc as number of left bitshift]);;
|
2014-12-23 12:29:49 +00:00
|
|
|
*)
|
|
|
|
AC_MSG_WARN([${with_tcmalloc_pagesize}K size not supported, using default tcmalloc page size.])
|
|
|
|
esac
|
|
|
|
case "$with_tcmalloc_alignment" in
|
|
|
|
8)
|
|
|
|
AC_DEFINE(TCMALLOC_ALIGN_8BYTES, 1,
|
|
|
|
[Define 8 bytes of allocation alignment for tcmalloc]);;
|
|
|
|
16)
|
|
|
|
#Default tcmalloc allocation alignment.
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
AC_MSG_WARN([${with_tcmalloc_alignment} bytes not supported, using default tcmalloc allocation alignment.])
|
|
|
|
esac
|
2009-03-11 20:50:03 +00:00
|
|
|
|
2023-06-21 14:39:38 +00:00
|
|
|
AS_IF([test "x$enable_heap_checker" = xyes],
|
|
|
|
[AS_IF([test "x$heap_checker_supported" = xno],
|
|
|
|
[AC_MSG_NOTICE([your system isn't Linux, and I won't build heap checker despite your request])]
|
|
|
|
enable_heap_checker=no)])
|
|
|
|
|
|
|
|
dnl Heap checker is (and has always been) Linux-only, and also now
|
|
|
|
dnl depends on clone support in libc. Most Linux libc's do ship clone()
|
|
|
|
dnl (includes glibc, musl and even bionic), but not all. So we check.
|
|
|
|
AS_IF([test "x$enable_heap_checker" = xyes],
|
|
|
|
[AC_MSG_CHECKING([clone() support])
|
|
|
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
|
|
|
#ifndef _GNU_SOURCE
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <sched.h>
|
|
|
|
|
|
|
|
static int fn(void *dummy) { return 0; }
|
|
|
|
|
|
|
|
]],[[
|
|
|
|
char stk[16];
|
|
|
|
return clone(fn, stk, CLONE_VM|CLONE_FS|CLONE_FILES, 0);
|
|
|
|
]])], [AC_MSG_RESULT([yes])], [ dnl clone not found
|
|
|
|
AC_MSG_RESULT([no])
|
|
|
|
enable_heap_checker=no
|
|
|
|
AS_IF([test "x$heap_checker_is_default" = xyes],
|
|
|
|
[AC_MSG_NOTICE([your Linux system won't have heap checker built due to missing clone() support])],
|
|
|
|
[AC_MSG_WARN([you requested heap checker built, but your libc doesn't have clone() support])])
|
|
|
|
])])
|
|
|
|
|
2007-03-22 03:00:33 +00:00
|
|
|
# Checks for programs.
|
2011-10-18 20:57:45 +00:00
|
|
|
AC_PROG_CXX
|
2023-06-26 18:28:02 +00:00
|
|
|
AC_LANG([C++])
|
2007-08-17 20:56:15 +00:00
|
|
|
AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc
|
2009-04-18 00:02:25 +00:00
|
|
|
|
2024-01-30 19:44:06 +00:00
|
|
|
AX_CXX_COMPILE_STDCXX(17, ext, mandatory)
|
2018-08-05 22:09:20 +00:00
|
|
|
|
2023-06-21 14:37:51 +00:00
|
|
|
LT_INIT
|
2007-03-22 03:00:33 +00:00
|
|
|
|
2023-07-02 23:35:46 +00:00
|
|
|
# Lets try enable frame pointers to enable simpler stacktrace
|
|
|
|
# capturing methods, but keep performace for critical bits with
|
|
|
|
# -momit-leaf-frame-pointer. However, we should be conservative so
|
|
|
|
# that we don't disable leaf frame pointers on whatever architectures
|
|
|
|
# that have them enabled by default.
|
|
|
|
AC_CACHE_CHECK(
|
|
|
|
[compiler and target supports -fno-omit-frame-pointer -momit-leaf-frame-pointer],
|
|
|
|
[ac_cv_frame_pointer_cflags],
|
|
|
|
[OLD_CXXFLAGS="$CXXFLAGS"
|
|
|
|
CXXFLAGS="$CXXFLAGS -fno-omit-frame-pointer -momit-leaf-frame-pointer"
|
|
|
|
AC_COMPILE_IFELSE(
|
|
|
|
[AC_LANG_PROGRAM(
|
|
|
|
#if !(__i386__ || __x86_64__ || __riscv || __aarch64__)
|
|
|
|
#error unsupported arch
|
|
|
|
#endif
|
|
|
|
)],
|
|
|
|
[ac_cv_frame_pointer_cflags=yes],
|
|
|
|
[ac_cv_frame_pointer_cflags=no])
|
|
|
|
CXXFLAGS="$OLD_CXXFLAGS"])
|
|
|
|
AM_CONDITIONAL(ENABLE_FP_FLAGS, [test "x$ac_cv_frame_pointer_cflags" = "xyes"])
|
|
|
|
|
2024-02-04 18:37:53 +00:00
|
|
|
# Clang-only (so far?) -Wthread-safety is a useful thing. We want.
|
|
|
|
AC_CACHE_CHECK(
|
|
|
|
[compiler and target supports -Wthread-safety],
|
|
|
|
[ac_cv_w_thread_safety],
|
|
|
|
[OLD_CXXFLAGS="$CXXFLAGS"
|
|
|
|
CXXFLAGS="$CXXFLAGS -Wthread-safety"
|
|
|
|
AC_COMPILE_IFELSE(
|
|
|
|
[AC_LANG_PROGRAM([], [])],
|
|
|
|
[ac_cv_w_thread_safety=yes],
|
|
|
|
[ac_cv_w_thread_safety=no])
|
|
|
|
CXXFLAGS="$OLD_CXXFLAGS"])
|
|
|
|
AM_CONDITIONAL(ENABLE_W_THREAD_SAFETY, [test "x$ac_cv_w_thread_safety" = "xyes"])
|
|
|
|
|
2007-03-22 03:00:33 +00:00
|
|
|
AX_C___ATTRIBUTE__
|
|
|
|
|
2017-05-22 06:15:59 +00:00
|
|
|
AC_MSG_CHECKING(for __attribute__((aligned(N))) on functions)
|
|
|
|
AC_CACHE_VAL(ac_cv___attribute__aligned_fn, [
|
2023-06-21 14:37:51 +00:00
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
|
2017-05-22 06:15:59 +00:00
|
|
|
void foo(void) __attribute__((aligned(128)));
|
2023-06-21 14:37:51 +00:00
|
|
|
void foo(void) { exit(1); }]], [[]])],[ac_cv___attribute__aligned_fn=yes],[ac_cv___attribute__aligned_fn=no
|
|
|
|
])])
|
2017-05-22 06:15:59 +00:00
|
|
|
if test "$ac_cv___attribute__aligned_fn" = "yes"; then
|
|
|
|
AC_DEFINE(HAVE___ATTRIBUTE__ALIGNED_FN, 1, [define if your compiler supports alignment of functions])
|
|
|
|
fi
|
|
|
|
AC_MSG_RESULT($ac_cv___attribute__aligned_fn)
|
|
|
|
|
|
|
|
|
2009-03-11 20:50:03 +00:00
|
|
|
# TODO(csilvers): we could remove a lot when WITH_CPU_PROFILER etc is "no".
|
2007-04-16 20:49:32 +00:00
|
|
|
AC_CHECK_TYPES([struct mallinfo],,, [#include <malloc.h>])
|
2023-12-07 13:10:51 +00:00
|
|
|
AC_CHECK_TYPES([struct mallinfo2],,, [#include <malloc.h>])
|
2007-03-22 03:00:33 +00:00
|
|
|
AC_CHECK_FUNCS(sbrk) # for tcmalloc to get memory
|
2018-10-06 18:43:19 +00:00
|
|
|
AC_CHECK_FUNCS(__sbrk) # for tcmalloc to get memory
|
2007-07-18 18:30:50 +00:00
|
|
|
AC_CHECK_FUNCS(geteuid) # for turning off services when run as root
|
2021-02-13 10:35:20 +00:00
|
|
|
AC_CHECK_HEADERS(features.h) # for vdso_support.h, __GLIBC__ macros
|
2007-07-18 18:30:50 +00:00
|
|
|
AC_CHECK_HEADERS(malloc.h) # some systems define stuff there, others not
|
|
|
|
AC_CHECK_HEADERS(glob.h) # for heap-profile-table (cleaning up profiles)
|
2007-03-22 03:28:56 +00:00
|
|
|
AC_CHECK_HEADERS(execinfo.h) # for stacktrace? and heapchecker_unittest
|
2007-04-16 20:49:32 +00:00
|
|
|
AC_CHECK_HEADERS(unwind.h) # for stacktrace
|
2009-06-10 02:04:26 +00:00
|
|
|
AC_CHECK_HEADERS(sched.h) # for being nice in our spinlock code
|
2007-08-17 20:56:15 +00:00
|
|
|
AC_CHECK_HEADERS(sys/syscall.h)
|
2009-03-11 20:50:03 +00:00
|
|
|
AC_CHECK_HEADERS(sys/socket.h) # optional; for forking out to symbolizer
|
|
|
|
AC_CHECK_HEADERS(sys/wait.h) # optional; for forking out to symbolizer
|
2009-09-11 18:42:32 +00:00
|
|
|
AC_CHECK_HEADERS(poll.h) # optional; for forking out to symbolizer
|
2007-08-17 20:56:15 +00:00
|
|
|
AC_CHECK_HEADERS(fcntl.h) # for tcmalloc_unittest
|
2011-05-19 21:37:12 +00:00
|
|
|
AC_CHECK_HEADERS(sys/cdefs.h) # Where glibc defines __THROW
|
2023-11-27 04:43:24 +00:00
|
|
|
|
|
|
|
AC_CHECK_HEADERS(sys/ucontext.h)
|
|
|
|
AC_CHECK_HEADERS(ucontext.h)
|
|
|
|
AC_CHECK_HEADERS(cygwin/signal.h) # ucontext on cywgin
|
|
|
|
AC_CHECK_HEADERS(asm/ptrace.h) # get ptrace macros, e.g. PT_NIP
|
2010-03-23 20:39:55 +00:00
|
|
|
|
2023-09-21 07:42:33 +00:00
|
|
|
# check for socketpair, some system, such as QNX, need link in an socket library to use it
|
|
|
|
AC_SEARCH_LIBS([socketpair], [socket])
|
|
|
|
|
2007-07-18 18:30:50 +00:00
|
|
|
# We override a lot of memory allocation routines, not all of which are
|
|
|
|
# standard. For those the system doesn't declare, we'll declare ourselves.
|
|
|
|
AC_CHECK_DECLS([cfree,
|
|
|
|
posix_memalign,
|
|
|
|
memalign,
|
|
|
|
valloc,
|
|
|
|
pvalloc],,,
|
|
|
|
[#define _XOPEN_SOURCE 600
|
2023-10-30 23:47:02 +00:00
|
|
|
#define _QNX_SOURCE 1
|
2007-07-18 18:30:50 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <malloc.h>])
|
|
|
|
|
2009-06-10 02:04:26 +00:00
|
|
|
if test "$ac_cv_type_struct_mallinfo" = yes; then
|
2012-02-04 00:07:36 +00:00
|
|
|
AC_SUBST(ac_cv_have_struct_mallinfo, 1) # gperftools/tcmalloc.h needs this
|
2009-06-10 02:04:26 +00:00
|
|
|
else
|
|
|
|
AC_SUBST(ac_cv_have_struct_mallinfo, 0)
|
|
|
|
fi
|
|
|
|
|
2023-12-07 13:10:51 +00:00
|
|
|
if test "$ac_cv_type_struct_mallinfo2" = yes; then
|
|
|
|
AC_SUBST(ac_cv_have_struct_mallinfo2, 1) # gperftools/tcmalloc.h needs this
|
|
|
|
else
|
|
|
|
AC_SUBST(ac_cv_have_struct_mallinfo2, 0)
|
|
|
|
fi
|
|
|
|
|
2019-04-07 22:27:17 +00:00
|
|
|
# We hardcode HAVE_MMAP to 1. There are no interesting systems anymore
|
2020-03-23 08:15:40 +00:00
|
|
|
# without functional mmap. And our windows (except mingw) builds
|
|
|
|
# aren't using autoconf. So we keep HAVE_MMAP define, but only to
|
|
|
|
# distingush windows and rest.
|
|
|
|
case "$host" in
|
2021-02-15 06:28:34 +00:00
|
|
|
*-mingw*) default_emergency_malloc=no;;
|
|
|
|
*) default_emergency_malloc=yes
|
|
|
|
AC_DEFINE(HAVE_MMAP, 1, [Define to 1 if you have a working `mmap' system call.])
|
2020-03-23 08:15:40 +00:00
|
|
|
esac
|
2008-06-14 02:30:53 +00:00
|
|
|
|
2007-08-17 20:56:15 +00:00
|
|
|
# We want to access the "PC" (Program Counter) register from a struct
|
2023-11-27 04:43:24 +00:00
|
|
|
# ucontext. Every system has its own way of doing that. But in case
|
|
|
|
# we're dealing with unknown system, we have to check if GetPC
|
|
|
|
# actually works. But don't bother if we're not doing cpu-profiling.
|
2009-03-11 20:50:03 +00:00
|
|
|
if test "$enable_cpu_profiler" = yes; then
|
2023-11-27 04:43:24 +00:00
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include "src/getpc.h"]], [GetPC({})])],
|
|
|
|
[],
|
|
|
|
[AC_MSG_WARN(Could not find the PC. Will not try to compile libprofiler...)
|
|
|
|
enable_cpu_profiler=no])
|
2007-08-17 20:56:15 +00:00
|
|
|
fi
|
|
|
|
|
2009-11-10 16:24:57 +00:00
|
|
|
# Some tests test the behavior of .so files, and only make sense for dynamic.
|
|
|
|
AM_CONDITIONAL(ENABLE_STATIC, test "$enable_static" = yes)
|
|
|
|
|
2017-05-15 06:45:08 +00:00
|
|
|
# We want to link in libunwind if it is enabled and exists.
|
|
|
|
UNWIND_LIBS=
|
2014-11-27 16:11:09 +00:00
|
|
|
if test "$enable_libunwind" = yes; then
|
2017-05-15 06:45:08 +00:00
|
|
|
AC_CHECK_HEADERS([libunwind.h],
|
2023-06-21 14:38:31 +00:00
|
|
|
[AC_CHECK_LIB(unwind, backtrace,
|
|
|
|
[UNWIND_LIBS=-lunwind
|
|
|
|
AC_DEFINE([USE_LIBUNWIND], [1], [libunwind.h was found and is working])
|
|
|
|
will_use_libunwind=yes])])
|
2014-11-27 16:11:09 +00:00
|
|
|
fi
|
2017-05-15 06:45:08 +00:00
|
|
|
AC_SUBST(UNWIND_LIBS)
|
2007-04-16 20:49:32 +00:00
|
|
|
|
2008-02-13 00:55:09 +00:00
|
|
|
AC_ARG_ENABLE(frame_pointers,
|
|
|
|
AS_HELP_STRING([--enable-frame-pointers],
|
2023-07-02 23:35:46 +00:00
|
|
|
[Add -fno-omit-frame-pointer to compile flags]),
|
2008-02-13 00:55:09 +00:00
|
|
|
, enable_frame_pointers=no)
|
2009-11-10 16:24:57 +00:00
|
|
|
AM_CONDITIONAL(ENABLE_FRAME_POINTERS, test "$enable_frame_pointers" = yes)
|
|
|
|
|
2018-08-26 18:37:59 +00:00
|
|
|
AC_ARG_ENABLE([deprecated-pprof],
|
|
|
|
[AS_HELP_STRING([--disable-deprecated-pprof],
|
|
|
|
[do not install old deprecated and unmaintained bundled pprof
|
|
|
|
(see github.com/google/pprof for supported version)])],
|
|
|
|
[enable_pprof="$enableval"],
|
|
|
|
[enable_pprof=yes])
|
|
|
|
|
|
|
|
AM_CONDITIONAL(INSTALL_PPROF,
|
|
|
|
[test "x$enable_pprof" = xyes])
|
|
|
|
|
2015-10-25 06:16:45 +00:00
|
|
|
AC_ARG_ENABLE([dynamic-sized-delete-support],
|
2017-05-23 01:58:15 +00:00
|
|
|
[AS_HELP_STRING([--enable-dynamic-sized-delete-support],
|
|
|
|
[try to build run-time switch for sized delete operator])],
|
2015-10-25 06:16:45 +00:00
|
|
|
[enable_dyn_sized_delete="$enableval"],
|
2017-05-23 01:58:15 +00:00
|
|
|
[enable_dyn_sized_delete=no])
|
2015-10-25 06:16:45 +00:00
|
|
|
|
|
|
|
AS_IF([test "x$enable_dyn_sized_delete" = xyes],
|
|
|
|
[AC_DEFINE([ENABLE_DYNAMIC_SIZED_DELETE], 1,
|
|
|
|
[Build runtime detection for sized delete])])
|
|
|
|
|
2015-10-05 04:12:28 +00:00
|
|
|
AC_ARG_ENABLE([sized-delete],
|
|
|
|
[AS_HELP_STRING([--enable-sized-delete],
|
|
|
|
[build sized delete operator])],
|
|
|
|
[enable_sized_delete="$enableval"],
|
|
|
|
[enable_sized_delete="no"])
|
|
|
|
AS_IF([test "x$enable_sized_delete" = xyes],
|
|
|
|
[AC_DEFINE([ENABLE_SIZED_DELETE], 1, [Build sized deletion operators])
|
|
|
|
AC_MSG_NOTICE([Will build sized deallocation operators])],
|
2016-02-07 00:19:54 +00:00
|
|
|
[AS_IF([test "x$enable_dyn_sized_delete" = xyes],
|
|
|
|
[AC_MSG_NOTICE([Will build dynamically detected sized deallocation operators])],
|
2018-03-05 07:29:46 +00:00
|
|
|
[AC_MSG_NOTICE([Will build sized deallocation operators that ignore size])])])
|
2015-10-05 04:12:28 +00:00
|
|
|
|
2016-03-05 23:47:25 +00:00
|
|
|
AC_CACHE_CHECK([if C++ compiler supports -fsized-deallocation],
|
|
|
|
[perftools_cv_sized_deallocation_result],
|
2023-06-26 18:28:02 +00:00
|
|
|
[OLD_CXXFLAGS="$CXXFLAGS"
|
2016-03-05 23:47:25 +00:00
|
|
|
CXXFLAGS="$CXXFLAGS -fsized-deallocation"
|
2018-03-05 07:29:46 +00:00
|
|
|
AC_LINK_IFELSE([AC_LANG_PROGRAM(
|
|
|
|
[[#include <new>
|
|
|
|
#include <stddef.h>]],
|
|
|
|
[[static void (* volatile ptr)(void *, size_t) = ::operator delete; (*ptr)(0, 256);]])],
|
2017-02-21 00:04:14 +00:00
|
|
|
perftools_cv_sized_deallocation_result=yes,
|
|
|
|
perftools_cv_sized_deallocation_result=no)
|
2023-06-26 18:28:02 +00:00
|
|
|
CXXFLAGS="$OLD_CXXFLAGS"])
|
2015-10-05 04:12:28 +00:00
|
|
|
|
2015-10-04 18:15:37 +00:00
|
|
|
AM_CONDITIONAL(HAVE_SIZED_DEALLOCATION,
|
|
|
|
test "$perftools_cv_sized_deallocation_result" = yes)
|
|
|
|
|
2016-02-21 04:33:27 +00:00
|
|
|
AC_CACHE_CHECK([if target has _Unwind_Backtrace],
|
|
|
|
[perftools_cv_have_unwind_backtrace],
|
2023-06-26 18:28:02 +00:00
|
|
|
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
|
2021-03-01 01:52:17 +00:00
|
|
|
[[#include <unwind.h>
|
2023-06-27 00:33:30 +00:00
|
|
|
#if defined(__APPLE__) || defined(__FreeBSD__)
|
|
|
|
#error OSX and FreeBSD _Unwind_Backtrace recurses back to malloc
|
2021-03-01 01:52:17 +00:00
|
|
|
#endif
|
|
|
|
]],
|
2016-02-21 04:33:27 +00:00
|
|
|
[[&_Unwind_Backtrace]])],
|
|
|
|
[perftools_cv_have_unwind_backtrace=yes],
|
2023-06-26 18:28:02 +00:00
|
|
|
[perftools_cv_have_unwind_backtrace=no])])
|
2016-02-21 04:33:27 +00:00
|
|
|
AS_IF([test "x$perftools_cv_have_unwind_backtrace" = xyes],
|
|
|
|
[AC_DEFINE(HAVE_UNWIND_BACKTRACE, 1, [Whether <unwind.h> contains _Unwind_Backtrace])])
|
|
|
|
|
2016-02-21 21:52:47 +00:00
|
|
|
AS_IF([test "x$will_use_libunwind" = xyes],
|
|
|
|
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [return __arm__])],
|
|
|
|
[default_emergency_malloc=yes])])
|
|
|
|
|
2016-02-01 07:17:50 +00:00
|
|
|
AC_ARG_ENABLE([emergency-malloc],
|
|
|
|
[AS_HELP_STRING([--enable-emergency-malloc],
|
|
|
|
[build emergency malloc feature])],
|
|
|
|
[enable_emergency_malloc="$enableval"],
|
2016-02-21 21:52:47 +00:00
|
|
|
[enable_emergency_malloc="$default_emergency_malloc"])
|
2016-02-01 07:17:50 +00:00
|
|
|
|
|
|
|
AM_CONDITIONAL(BUILD_EMERGENCY_MALLOC, [test "x$enable_emergency_malloc" = xyes])
|
|
|
|
|
2007-08-17 20:56:15 +00:00
|
|
|
# Also make sure we get standard PRI... definitions, even with glibc.
|
|
|
|
# We have to use AH_VERBATIM because we need the #ifdef guard (gcc buglet)
|
|
|
|
AH_VERBATIM([__STDC_FORMAT_MACROS],
|
|
|
|
[/* C99 says: define this to get the PRI... macros from stdint.h */
|
|
|
|
#ifndef __STDC_FORMAT_MACROS
|
|
|
|
# define __STDC_FORMAT_MACROS 1
|
|
|
|
#endif])
|
|
|
|
|
2009-12-02 18:15:13 +00:00
|
|
|
# Check if __environ is available (for GetenvBeforeMain)
|
|
|
|
AC_MSG_CHECKING([for __environ])
|
|
|
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <unistd.h>],
|
|
|
|
[char **env = __environ])],
|
|
|
|
[AC_DEFINE(HAVE___ENVIRON, 1,
|
|
|
|
[Define to 1 if compiler supports __environ])
|
|
|
|
AC_MSG_RESULT([yes])],
|
|
|
|
[AC_MSG_RESULT([no])])
|
|
|
|
|
2009-03-11 20:50:03 +00:00
|
|
|
# Nanosleep requires extra libraries on some architectures (solaris).
|
|
|
|
# This sets NANOSLEEP_LIBS. nanosleep doesn't exist on mingw, which
|
|
|
|
# is fine for us because we don't compile libspinlock, which uses it.
|
|
|
|
if test "$need_nanosleep" = yes; then
|
|
|
|
ACX_NANOSLEEP
|
|
|
|
AC_SUBST(NANOSLEEP_LIBS)
|
|
|
|
fi
|
|
|
|
|
2007-04-16 20:49:32 +00:00
|
|
|
# In fact, a lot of the code in this directory depends on pthreads
|
2023-06-21 14:37:51 +00:00
|
|
|
AX_PTHREAD
|
2007-03-22 03:00:33 +00:00
|
|
|
|
|
|
|
# Figure out where libc has program_invocation_name
|
|
|
|
AC_PROGRAM_INVOCATION_NAME
|
|
|
|
|
2013-07-20 21:35:14 +00:00
|
|
|
dnl only very recent mingw has sleep and nanosleep
|
|
|
|
case "$host" in
|
|
|
|
*-mingw*)
|
|
|
|
AC_CHECK_DECLS([sleep], [], [], [#include <unistd.h>])
|
|
|
|
AC_CHECK_DECLS([nanosleep], [], [], [#include <time.h>])
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2014-04-12 19:38:19 +00:00
|
|
|
if test "x$enable_backtrace" = xyes; then
|
|
|
|
AC_CHECK_DECLS([backtrace], [], [], [#include <execinfo.h>])
|
2017-05-15 06:45:08 +00:00
|
|
|
save_LIBS=$LIBS
|
|
|
|
LIBS=$UNWIND_LIBS
|
|
|
|
AC_SEARCH_LIBS([backtrace], [execinfo])
|
|
|
|
UNWIND_LIBS=$LIBS
|
|
|
|
LIBS=$save_LIBS
|
2014-04-12 19:38:19 +00:00
|
|
|
fi
|
2013-07-20 21:35:14 +00:00
|
|
|
|
2023-06-26 23:57:48 +00:00
|
|
|
STACKTRACE_UNITTEST_LIBS=
|
|
|
|
AS_IF([test "x$ac_cv_header_execinfo_h" = xyes],
|
|
|
|
AS_IF([test "x$enable_cpu_profiler" = xyes -o "x$enable_heap_profiler" = xyes -o "x$enable_heap_checker" = xyes],
|
|
|
|
[AC_CHECK_DECLS([backtrace_symbols], [], [], [#include <execinfo.h>
|
|
|
|
])
|
|
|
|
save_LIBS=$LIBS
|
|
|
|
LIBS=
|
|
|
|
AC_SEARCH_LIBS([backtrace_symbols], [execinfo])
|
|
|
|
STACKTRACE_UNITTEST_LIBS=$LIBS
|
|
|
|
LIBS=$save_LIBS]))
|
|
|
|
AC_SUBST(STACKTRACE_UNITTEST_LIBS)
|
|
|
|
|
2024-03-20 23:35:01 +00:00
|
|
|
AC_ARG_ENABLE([hidden-visibility],
|
|
|
|
[AS_HELP_STRING([--enable-hidden-visibility],
|
|
|
|
[build libraries with -fvisibility=hidden])],
|
|
|
|
[enable_visibility=yes],
|
|
|
|
[enable_visibility=no])
|
|
|
|
|
|
|
|
AC_DEFINE([PERFTOOLS_DLL_DECL], [], [dllexport or attribute visibility])
|
|
|
|
|
|
|
|
AS_IF([test "x$enable_visibility" = xyes],
|
|
|
|
[AC_DEFINE([PERFTOOLS_DLL_DECL], [__attribute((visibility("default")))], [])
|
|
|
|
CXXFLAGS="-fvisibility=hidden $CXXFLAGS"])
|
2007-07-18 18:30:50 +00:00
|
|
|
|
2024-01-26 20:12:43 +00:00
|
|
|
# In theory, config.h files shouldn't need a header guard.
|
|
|
|
# Now there were historical reasons for doing so
|
2023-07-31 18:28:58 +00:00
|
|
|
# https://github.com/gperftools/gperftools/issues/248
|
2024-01-26 20:12:43 +00:00
|
|
|
# but these days we are keeping it mostly for consistency and safety.
|
2010-06-21 15:59:56 +00:00
|
|
|
AH_TOP([
|
2012-02-04 00:07:36 +00:00
|
|
|
#ifndef GPERFTOOLS_CONFIG_H_
|
|
|
|
#define GPERFTOOLS_CONFIG_H_
|
2010-06-21 15:59:56 +00:00
|
|
|
])
|
|
|
|
|
2007-11-29 23:39:24 +00:00
|
|
|
# MinGW uses autoconf, but also needs the windows shim routines
|
|
|
|
# (since it doesn't have its own support for, say, pthreads).
|
|
|
|
# This requires us to #include a special header file, and also to
|
|
|
|
# link in some windows versions of .o's instead of the unix versions.
|
2011-07-16 01:07:10 +00:00
|
|
|
#
|
|
|
|
# Also, manually mark systems where we have to be careful how early
|
|
|
|
# we run pthreads. TODO(csilvers): turn this into an autoconf check.
|
2007-11-29 23:39:24 +00:00
|
|
|
AH_BOTTOM([
|
2024-01-26 20:12:43 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
// TODO(csilvers): include windows/port.h in every relevant source file instead?
|
|
|
|
#include "windows/port.h"
|
2007-11-29 23:39:24 +00:00
|
|
|
#endif
|
2010-06-21 15:59:56 +00:00
|
|
|
|
2012-02-04 00:07:36 +00:00
|
|
|
#endif /* #ifndef GPERFTOOLS_CONFIG_H_ */
|
2007-11-29 23:39:24 +00:00
|
|
|
])
|
2009-03-11 20:50:03 +00:00
|
|
|
AM_CONDITIONAL(MINGW, expr $host : '.*-mingw' >/dev/null 2>&1)
|
2011-07-16 01:07:10 +00:00
|
|
|
AM_CONDITIONAL(OSX, expr $host : '.*-apple-darwin.*' >/dev/null 2>&1)
|
2009-03-11 20:50:03 +00:00
|
|
|
|
|
|
|
# Export the --enable flags we set above. We do this at the end so
|
|
|
|
# other configure rules can enable or disable targets based on what
|
|
|
|
# they find.
|
|
|
|
AM_CONDITIONAL(WITH_CPU_PROFILER, test "$enable_cpu_profiler" = yes)
|
|
|
|
AM_CONDITIONAL(WITH_HEAP_PROFILER, test "$enable_heap_profiler" = yes)
|
|
|
|
AM_CONDITIONAL(WITH_HEAP_CHECKER, test "$enable_heap_checker" = yes)
|
2009-09-11 18:42:32 +00:00
|
|
|
AM_CONDITIONAL(WITH_DEBUGALLOC, test "$enable_debugalloc" = yes)
|
2009-03-11 20:50:03 +00:00
|
|
|
# We make tcmalloc.so if either heap-profiler or heap-checker is asked for.
|
|
|
|
AM_CONDITIONAL(WITH_HEAP_PROFILER_OR_CHECKER,
|
|
|
|
test "$enable_heap_profiler" = yes -o \
|
|
|
|
"$enable_heap_checker" = yes)
|
|
|
|
# If we don't use any profilers, we don't need stack traces (or pprof)
|
|
|
|
AM_CONDITIONAL(WITH_STACK_TRACE, test "$enable_cpu_profiler" = yes -o \
|
|
|
|
"$enable_heap_profiler" = yes -o \
|
|
|
|
"$enable_heap_checker" = yes)
|
2007-11-29 23:39:24 +00:00
|
|
|
|
2014-09-07 20:09:14 +00:00
|
|
|
have_linux_sigev_thread_id=no
|
|
|
|
AC_MSG_CHECKING([for Linux SIGEV_THREAD_ID])
|
|
|
|
AC_COMPILE_IFELSE(
|
|
|
|
[AC_LANG_PROGRAM([[#include <signal.h>
|
|
|
|
#include <time.h>]],
|
|
|
|
[[return SIGEV_THREAD_ID || CLOCK_THREAD_CPUTIME_ID || __linux;]])],
|
|
|
|
[AC_DEFINE(HAVE_LINUX_SIGEV_THREAD_ID, 1,
|
|
|
|
[Define if this is Linux that has SIGEV_THREAD_ID])
|
|
|
|
have_linux_sigev_thread_id=yes
|
|
|
|
AC_MSG_RESULT([yes])],
|
|
|
|
[AC_MSG_RESULT([no])])
|
|
|
|
|
2018-05-20 17:45:32 +00:00
|
|
|
# Disable large allocation report by default.
|
|
|
|
AC_ARG_ENABLE([large-alloc-report],
|
|
|
|
[AS_HELP_STRING([--enable-large-alloc-report],
|
|
|
|
[report very large allocations to stderr])],
|
|
|
|
[enable_large_alloc_report="$enableval"],
|
|
|
|
[enable_large_alloc_report=no])
|
|
|
|
AS_IF([test "x$enable_large_alloc_report" = xyes],
|
|
|
|
[AC_DEFINE([ENABLE_LARGE_ALLOC_REPORT], 1, [report large allocation])])
|
|
|
|
|
2018-10-15 14:56:18 +00:00
|
|
|
# Enable aggressive decommit by default
|
|
|
|
AC_ARG_ENABLE([aggressive-decommit-by-default],
|
|
|
|
[AS_HELP_STRING([--enable-aggressive-decommit-by-default],
|
|
|
|
[enable aggressive decommit by default])],
|
|
|
|
[enable_aggressive_decommit_by_default="$enableval"],
|
|
|
|
[enable_aggressive_decommit_by_default=no])
|
|
|
|
AS_IF([test "x$enable_aggressive_decommit_by_default" = xyes],
|
|
|
|
[AC_DEFINE([ENABLE_AGGRESSIVE_DECOMMIT_BY_DEFAULT],
|
|
|
|
1,
|
|
|
|
[enable aggressive decommit by default])])
|
|
|
|
|
2007-03-22 03:00:33 +00:00
|
|
|
# Write generated configuration file
|
2024-01-30 01:54:47 +00:00
|
|
|
# NOTE: vsprojects/gperftools/tcmalloc.h is checked in
|
2012-02-04 00:07:36 +00:00
|
|
|
AC_CONFIG_FILES([Makefile
|
2024-01-30 01:54:47 +00:00
|
|
|
src/gperftools/tcmalloc.h
|
2024-01-30 20:49:21 +00:00
|
|
|
vsprojects/include/gperftools/tcmalloc.h:src/gperftools/tcmalloc.h.in
|
2024-01-30 01:54:47 +00:00
|
|
|
])
|
2007-03-22 03:00:33 +00:00
|
|
|
AC_OUTPUT
|