Makefile.am 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504
  1. ## Process this file with automake to produce Makefile.in
  2. # Note: for every library we create, we're explicit about what symbols
  3. # we export. In order to avoid complications with C++ mangling, we always
  4. # use the regexp for of specifying symbols.
  5. # Make sure that when we re-make ./configure, we get the macros we need
  6. ACLOCAL_AMFLAGS = -I m4
  7. AUTOMAKE_OPTIONS = subdir-objects
  8. # This is so we can #include <gperftools/foo>
  9. AM_CPPFLAGS = -I$(top_srcdir)/src
  10. if !WITH_STACK_TRACE
  11. AM_CPPFLAGS += -DNO_TCMALLOC_SAMPLES
  12. endif !WITH_STACK_TRACE
  13. # This is mostly based on configure options
  14. AM_CXXFLAGS =
  15. NO_BUILTIN_CXXFLAGS =
  16. # These are good warnings to turn on by default. We also tell gcc
  17. # that malloc, free, realloc, mmap, etc. are not builtins (these flags
  18. # are supported since gcc 3.1.1). gcc doesn't think most of them are
  19. # builtins now in any case, but it's best to be explicit in case that
  20. # changes one day. gcc ignores functions it doesn't understand.
  21. if GCC
  22. AM_CXXFLAGS += -Wall -Wwrite-strings -Woverloaded-virtual \
  23. -Wno-sign-compare \
  24. -fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc \
  25. -fno-builtin-calloc -fno-builtin-cfree \
  26. -fno-builtin-memalign -fno-builtin-posix_memalign \
  27. -fno-builtin-valloc -fno-builtin-pvalloc
  28. NO_BUILTIN_CXXFLAGS += -fno-builtin
  29. # On i386, -mmmx is needed for the mmx-based instructions in
  30. # atomicops-internal-x86.h. Also as of gcc 4.6, -fomit-frame-pointer
  31. # is the default. Since we must always have frame pointers for I386
  32. # in order to generate backtraces we now specify -fno-omit-frame-pointer
  33. # by default.
  34. if I386
  35. AM_CXXFLAGS += -mmmx
  36. AM_CXXFLAGS += -fno-omit-frame-pointer
  37. endif I386
  38. endif GCC
  39. if HAVE_W_NO_UNUSED_RESULT
  40. AM_CXXFLAGS += -Wno-unused-result
  41. endif HAVE_W_NO_UNUSED_RESULT
  42. if HAVE_SIZED_DEALLOCATION
  43. AM_CXXFLAGS += -fsized-deallocation
  44. endif HAVE_SIZED_DEALLOCATION
  45. if HAVE_F_ALIGNED_NEW
  46. AM_CXXFLAGS += -faligned-new
  47. endif HAVE_F_ALIGNED_NEW
  48. # The -no-undefined flag allows libtool to generate shared libraries for
  49. # Cygwin and MinGW. LIBSTDCXX_LA_LINKER_FLAG is used to fix a Solaris bug.
  50. AM_LDFLAGS = -no-undefined $(LIBSTDCXX_LA_LINKER_FLAG)
  51. # These are x86-specific, having to do with frame-pointers. In
  52. # particular, some x86_64 systems do not insert frame pointers by
  53. # default (all i386 systems that I know of, do. I don't know about
  54. # non-x86 chips). We need to tell perftools what to do about that.
  55. if X86_64_AND_NO_FP_BY_DEFAULT
  56. if ENABLE_FRAME_POINTERS
  57. AM_CXXFLAGS += -fno-omit-frame-pointer
  58. else
  59. # TODO(csilvers): check if -fomit-frame-pointer might be in $(CXXFLAGS),
  60. # before setting this.
  61. AM_CXXFLAGS += -DNO_FRAME_POINTER
  62. endif !ENABLE_FRAME_POINTERS
  63. endif X86_64_AND_NO_FP_BY_DEFAULT
  64. # For windows systems (at least, mingw), we need to tell all our
  65. # tests to link in libtcmalloc using -u. This is because libtcmalloc
  66. # accomplishes its tasks via patching, leaving no work for the linker
  67. # to identify, so the linker will ignore libtcmalloc by default unless
  68. # we explicitly create a dependency via -u.
  69. TCMALLOC_FLAGS =
  70. if MINGW
  71. TCMALLOC_FLAGS += -Wl,-u__tcmalloc
  72. endif MINGW
  73. # If we have objcopy, make malloc/free/etc weak symbols. That way folks
  74. # can override our malloc if they want to (they can still use tc_malloc).
  75. # Note: the weird-looking symbols are the c++ memory functions:
  76. # (in order) new, new(nothrow), new[], new[](nothrow), delete, delete[]
  77. # In theory this will break if mangling changes, but that seems pretty
  78. # unlikely at this point. Just in case, I throw in versions with an
  79. # extra underscore as well, which may help on OS X.
  80. if HAVE_OBJCOPY_WEAKEN
  81. WEAKEN = $(OBJCOPY) -W malloc -W free -W realloc -W calloc -W cfree \
  82. -W memalign -W posix_memalign -W valloc -W pvalloc \
  83. -W aligned_alloc \
  84. -W malloc_stats -W mallopt -W mallinfo -W nallocx \
  85. -W _Znwm -W _ZnwmRKSt9nothrow_t -W _Znam -W _ZnamRKSt9nothrow_t \
  86. -W _ZdlPv -W _ZdaPv \
  87. -W __Znwm -W __ZnwmRKSt9nothrow_t -W __Znam -W __ZnamRKSt9nothrow_t \
  88. -W __ZdlPv -W __ZdaPv
  89. else
  90. WEAKEN = :
  91. endif !HAVE_OBJCOPY_WEAKEN
  92. LIBS_TO_WEAKEN =
  93. perftoolsincludedir = $(includedir)/gperftools
  94. # The .h files you want to install (that is, .h files that people
  95. # who install this package can include in their own applications.)
  96. # We'll add to this later, on a library-by-library basis
  97. perftoolsinclude_HEADERS =
  98. # tcmalloc.h is a special case, because it's a .h.in file
  99. nodist_perftoolsinclude_HEADERS = src/gperftools/tcmalloc.h
  100. noinst_HEADERS = src/gperftools/tcmalloc.h.in
  101. # This is provided for backwards compatibility. It is populated by
  102. # files that just forward to the canonical location in
  103. # perftoolsincludedir.
  104. googleincludedir = $(includedir)/google
  105. googleinclude_HEADERS = \
  106. src/google/heap-checker.h \
  107. src/google/heap-profiler.h \
  108. src/google/malloc_extension.h \
  109. src/google/malloc_extension_c.h \
  110. src/google/malloc_hook.h \
  111. src/google/malloc_hook_c.h \
  112. src/google/profiler.h \
  113. src/google/stacktrace.h \
  114. src/google/tcmalloc.h
  115. # This is for HTML and other documentation you want to install.
  116. # Add your documentation files (in doc/) in addition to these
  117. # top-level boilerplate files. Also add a TODO file if you have one.
  118. # We'll add to this later, on a library-by-library basis
  119. dist_doc_DATA = AUTHORS COPYING ChangeLog INSTALL NEWS README README_windows.txt \
  120. TODO ChangeLog.old
  121. # The libraries (.so's) you want to install
  122. # We'll add to this later, on a library-by-library basis
  123. lib_LTLIBRARIES =
  124. # This is for 'convenience libraries' -- basically just a container for sources
  125. noinst_LTLIBRARIES =
  126. ## The location of the windows project file for each binary we make
  127. WINDOWS_PROJECTS = gperftools.sln
  128. # unittests you want to run when people type 'make check'.
  129. # Note: tests cannot take any arguments!
  130. # In theory, unittests that are scripts should be added to check_SCRIPTS
  131. # instead. But check_SCRIPTS is definitely a second-class testing mechanims:
  132. # it don't get TESTS_ENVIRONMENT, and it doesn't get success/failure counting
  133. # (in fact, a script failure aborts all the rest of the tests, even with -k).
  134. # So, for scripts, we add the script to tests, and also put in an empty
  135. # rule so automake doesn't try to build the script as a C binary.
  136. TESTS =
  137. # TESTS_ENVIRONMENT sets environment variables for when you run unittest.
  138. # We always get "srcdir" set for free.
  139. # We'll add to this later, on a library-by-library basis.
  140. TESTS_ENVIRONMENT =
  141. # All script tests should be added here
  142. noinst_SCRIPTS =
  143. # If your test calls another program that, like the test itself, shouldn't
  144. # be installed, add it here. (Stuff in TESTS is automatically added later).
  145. noinst_PROGRAMS =
  146. # Binaries we might build that should be installed
  147. bin_PROGRAMS =
  148. # This is my own var, used for extra libraries I make that I need installed
  149. EXTRA_INSTALL =
  150. ## vvvv RULES TO MAKE THE LIBRARIES, BINARIES, AND UNITTESTS
  151. dist_doc_DATA += docs/index.html docs/designstyle.css
  152. ### ------- library routines, in src/base
  153. # This is a 'convenience library' -- it's not actually installed or anything
  154. LOGGING_INCLUDES = src/base/logging.h \
  155. src/base/commandlineflags.h \
  156. src/base/basictypes.h \
  157. src/base/dynamic_annotations.h \
  158. src/third_party/valgrind.h
  159. noinst_LTLIBRARIES += liblogging.la
  160. liblogging_la_SOURCES = src/base/logging.cc \
  161. src/base/dynamic_annotations.c \
  162. $(LOGGING_INCLUDES)
  163. SYSINFO_INCLUDES = src/base/sysinfo.h \
  164. src/getenv_safe.h \
  165. src/base/logging.h \
  166. src/base/commandlineflags.h \
  167. src/base/arm_instruction_set_select.h \
  168. src/base/basictypes.h
  169. noinst_LTLIBRARIES += libsysinfo.la
  170. libsysinfo_la_SOURCES = src/base/sysinfo.cc \
  171. $(SYSINFO_INCLUDES)
  172. libsysinfo_la_LIBADD = $(NANOSLEEP_LIBS)
  173. noinst_LTLIBRARIES += libmaybe_threads.la
  174. # .cc is conditionally added below
  175. libmaybe_threads_la_SOURCES = src/maybe_threads.h
  176. # For MinGW, we use also have to use libwindows Luckily, we need the
  177. # windows.a library in exactly the same place we need spinlock.a
  178. # (pretty much everywhere), so we can use the same variable name for
  179. # each. We can also optimize the MinGW rule a bit by leaving out
  180. # files we know aren't used on windows, such as
  181. # atomicops-internals-x86.cc. libwindows also obsoletes the need for
  182. # other files like system_alloc.cc.
  183. if MINGW
  184. WINDOWS_INCLUDES = src/windows/port.h \
  185. src/windows/mingw.h \
  186. src/windows/mini_disassembler.h \
  187. src/windows/mini_disassembler_types.h \
  188. src/windows/preamble_patcher.h
  189. noinst_LTLIBRARIES += libwindows.la
  190. libwindows_la_SOURCES = $(WINDOWS_INCLUDES) \
  191. src/windows/port.cc \
  192. src/windows/system-alloc.cc \
  193. src/windows/ia32_modrm_map.cc \
  194. src/windows/ia32_opcode_map.cc \
  195. src/windows/mini_disassembler.cc \
  196. src/windows/patch_functions.cc \
  197. src/windows/preamble_patcher.cc \
  198. src/windows/preamble_patcher_with_stub.cc
  199. # patch_functions.cc uses Psapi.lib. MSVC has a #pragma for that, but not us.
  200. libwindows_la_LIBADD = -lpsapi
  201. SPINLOCK_INCLUDES = src/base/spinlock.h \
  202. src/base/spinlock_internal.h \
  203. src/base/spinlock_win32-inl.h \
  204. src/base/spinlock_linux-inl.h \
  205. src/base/spinlock_posix-inl.h \
  206. src/base/atomicops-internals-macosx.h \
  207. src/base/atomicops-internals-linuxppc.h \
  208. src/base/atomicops-internals-arm-generic.h \
  209. src/base/atomicops-internals-arm-v6plus.h \
  210. src/base/atomicops-internals-mips.h \
  211. src/base/atomicops-internals-windows.h \
  212. src/base/atomicops-internals-gcc.h \
  213. src/base/atomicops-internals-x86.h
  214. noinst_LTLIBRARIES += libspinlock.la
  215. libspinlock_la_SOURCES = src/base/spinlock.cc \
  216. src/base/spinlock_internal.cc \
  217. src/base/atomicops-internals-x86.cc \
  218. $(SPINLOCK_INCLUDES)
  219. LIBSPINLOCK = libwindows.la libspinlock.la libsysinfo.la liblogging.la
  220. # We also need to tell mingw that sysinfo.cc needs shlwapi.lib.
  221. # (We do this via a #pragma for msvc, but need to do it here for mingw).
  222. libsysinfo_la_LIBADD += -lshlwapi
  223. # There's a windows-specific unittest we can run. Right now it's
  224. # win64-specific, and relies on masm, so we comment it out.
  225. ## TESTS += preamble_patcher_test
  226. ## preamble_patcher_test_SOURCES = src/windows/preamble_patcher_test.cc \
  227. ## src/windows/shortproc.asm \
  228. ## src/windows/auto_testing_hook.h \
  229. ## src/windows/preamble_patcher.h \
  230. ## src/base/basictypes.h \
  231. ## src/base/logging.h
  232. ## preamble_patcher_test_LDFLAGS = $(TCMALLOC_FLAGS)
  233. ## preamble_patcher_test_LDADD = $(LIBTCMALLOC_MINIMAL)
  234. # patch_functions.cc #includes tcmalloc.cc, so no need to link it in.
  235. TCMALLOC_CC =
  236. # windows has its own system for threads and system memory allocation.
  237. if HAVE_PTHREAD_DESPITE_ASKING_FOR
  238. libmaybe_threads_la_SOURCES += src/maybe_threads.cc
  239. endif
  240. SYSTEM_ALLOC_CC =
  241. else !MINGW
  242. # spinlock is the only code that uses atomicops.
  243. SPINLOCK_INCLUDES = src/base/spinlock.h \
  244. src/base/spinlock_internal.h \
  245. src/base/atomicops.h \
  246. src/base/atomicops-internals-macosx.h \
  247. src/base/atomicops-internals-linuxppc.h \
  248. src/base/atomicops-internals-windows.h \
  249. src/base/atomicops-internals-x86.h
  250. noinst_LTLIBRARIES += libspinlock.la
  251. libspinlock_la_SOURCES = src/base/spinlock.cc \
  252. src/base/spinlock_internal.cc \
  253. src/base/atomicops-internals-x86.cc \
  254. $(SPINLOCK_INCLUDES)
  255. libspinlock_la_LIBADD = $(NANOSLEEP_LIBS)
  256. # spinlock also needs NumCPUs, from libsysinfo, which in turn needs liblogging
  257. LIBSPINLOCK = libspinlock.la libsysinfo.la liblogging.la
  258. TCMALLOC_CC = src/tcmalloc.cc
  259. libmaybe_threads_la_SOURCES += src/maybe_threads.cc
  260. SYSTEM_ALLOC_CC = src/system-alloc.cc
  261. endif !MINGW
  262. # Add this whether or not we're under MinGW, to keep the tarball complete.
  263. WINDOWS_PROJECTS += vsprojects/preamble_patcher_test/preamble_patcher_test.vcxproj
  264. # Because we've commented out the test, above, we have to explicitly add
  265. # the test files to the tarball or automake will leave them out.
  266. WINDOWS_PROJECTS += src/windows/preamble_patcher_test.cc \
  267. src/windows/shortproc.asm \
  268. src/windows/auto_testing_hook.h
  269. ### Unittests
  270. TESTS += low_level_alloc_unittest
  271. WINDOWS_PROJECTS += vsprojects/low_level_alloc_unittest/low_level_alloc_unittest.vcxproj
  272. LOW_LEVEL_ALLOC_UNITTEST_INCLUDES = src/base/low_level_alloc.h \
  273. src/base/basictypes.h \
  274. src/gperftools/malloc_hook.h \
  275. src/gperftools/malloc_hook_c.h \
  276. src/malloc_hook-inl.h \
  277. src/malloc_hook_mmap_linux.h \
  278. src/malloc_hook_mmap_freebsd.h \
  279. $(SPINLOCK_INCLUDES) \
  280. $(LOGGING_INCLUDES)
  281. low_level_alloc_unittest_SOURCES = src/base/low_level_alloc.cc \
  282. src/malloc_hook.cc \
  283. src/tests/low_level_alloc_unittest.cc \
  284. $(LOW_LEVEL_ALLOC_UNITTEST_INCLUDES)
  285. # By default, MallocHook takes stack traces for use by the heap-checker.
  286. # We don't need that functionality here, so we turn it off to reduce deps.
  287. low_level_alloc_unittest_CXXFLAGS = -DNO_TCMALLOC_SAMPLES
  288. low_level_alloc_unittest_LDADD = $(LIBSPINLOCK) libmaybe_threads.la
  289. TESTS += atomicops_unittest
  290. ATOMICOPS_UNITTEST_INCLUDES = src/base/atomicops.h \
  291. src/base/atomicops-internals-macosx.h \
  292. src/base/atomicops-internals-windows.h \
  293. src/base/atomicops-internals-x86.h \
  294. $(LOGGING_INCLUDES)
  295. atomicops_unittest_SOURCES = src/tests/atomicops_unittest.cc \
  296. $(ATOMICOPS_UNITTEST_INCLUDES)
  297. atomicops_unittest_LDADD = $(LIBSPINLOCK)
  298. ### ------- stack trace
  299. if WITH_STACK_TRACE
  300. ### The header files we use. We divide into categories based on directory
  301. S_STACKTRACE_INCLUDES = src/stacktrace_impl_setup-inl.h \
  302. src/stacktrace_generic-inl.h \
  303. src/stacktrace_libgcc-inl.h \
  304. src/stacktrace_libunwind-inl.h \
  305. src/stacktrace_arm-inl.h \
  306. src/stacktrace_powerpc-inl.h \
  307. src/stacktrace_powerpc-darwin-inl.h \
  308. src/stacktrace_powerpc-linux-inl.h \
  309. src/stacktrace_x86-inl.h \
  310. src/stacktrace_win32-inl.h \
  311. src/stacktrace_instrument-inl.h \
  312. src/base/elf_mem_image.h \
  313. src/base/vdso_support.h
  314. SG_STACKTRACE_INCLUDES = src/gperftools/stacktrace.h
  315. STACKTRACE_INCLUDES = $(S_STACKTRACE_INCLUDES) $(SG_STACKTRACE_INCLUDES)
  316. perftoolsinclude_HEADERS += $(SG_STACKTRACE_INCLUDES)
  317. ### Making the library
  318. noinst_LTLIBRARIES += libstacktrace.la
  319. libstacktrace_la_SOURCES = src/stacktrace.cc \
  320. src/base/elf_mem_image.cc \
  321. src/base/vdso_support.cc \
  322. $(STACKTRACE_INCLUDES)
  323. libstacktrace_la_LIBADD = $(UNWIND_LIBS) $(LIBSPINLOCK)
  324. STACKTRACE_SYMBOLS = '(GetStackTrace|GetStackFrames|GetStackTraceWithContext|GetStackFramesWithContext)'
  325. libstacktrace_la_LDFLAGS = -export-symbols-regex $(STACKTRACE_SYMBOLS) $(AM_LDFLAGS)
  326. noinst_LTLIBRARIES += libfake_stacktrace_scope.la
  327. libfake_stacktrace_scope_la_SOURCES = src/fake_stacktrace_scope.cc
  328. ### Unittests
  329. TESTS += stacktrace_unittest
  330. STACKTRACE_UNITTEST_INCLUDES = src/config_for_unittests.h \
  331. src/base/commandlineflags.h \
  332. $(STACKTRACE_INCLUDES) \
  333. $(LOGGING_INCLUDES)
  334. stacktrace_unittest_SOURCES = src/tests/stacktrace_unittest.cc \
  335. $(STACKTRACE_UNITTEST_INCLUDES)
  336. stacktrace_unittest_LDADD = libstacktrace.la liblogging.la libfake_stacktrace_scope.la
  337. ### Documentation
  338. dist_doc_DATA +=
  339. endif WITH_STACK_TRACE
  340. ### ------- pprof
  341. # If we are not compiling with stacktrace support, pprof is worthless
  342. if WITH_STACK_TRACE
  343. bin_SCRIPTS = pprof-symbolize
  344. pprof-symbolize : $(top_srcdir)/src/pprof
  345. cp -p $(top_srcdir)/src/pprof $@
  346. ### Unittests
  347. check_SCRIPTS = pprof_unittest
  348. pprof_unittest: $(top_srcdir)/src/pprof
  349. $(top_srcdir)/src/pprof -test
  350. # Let unittests find pprof if they need to run it
  351. TESTS_ENVIRONMENT += PPROF_PATH=$(top_srcdir)/src/pprof
  352. if INSTALL_PPROF
  353. bin_SCRIPTS += src/pprof
  354. dist_man_MANS = docs/pprof.1
  355. dist_doc_DATA += docs/pprof_remote_servers.html
  356. endif INSTALL_PPROF
  357. ### Documentation
  358. # On MSVC, we need our own versions of addr2line and nm to work with pprof.
  359. WINDOWS_PROJECTS += vsprojects/nm-pdb/nm-pdb.vcxproj
  360. WINDOWS_PROJECTS += vsprojects/addr2line-pdb/addr2line-pdb.vcxproj
  361. # This is a slight abuse of WINDOWS_PROJECTS, but not much
  362. WINDOWS_PROJECTS += src/windows/nm-pdb.c \
  363. src/windows/addr2line-pdb.c
  364. endif WITH_STACK_TRACE
  365. ### ------- tcmalloc_minimal (thread-caching malloc)
  366. ### The header files we use. We divide into categories based on directory
  367. S_TCMALLOC_MINIMAL_INCLUDES = src/common.h \
  368. src/internal_logging.h \
  369. src/system-alloc.h \
  370. src/packed-cache-inl.h \
  371. $(SPINLOCK_INCLUDES) \
  372. src/tcmalloc_guard.h \
  373. src/base/commandlineflags.h \
  374. src/base/basictypes.h \
  375. src/pagemap.h \
  376. src/sampler.h \
  377. src/central_freelist.h \
  378. src/linked_list.h \
  379. src/libc_override.h \
  380. src/libc_override_gcc_and_weak.h \
  381. src/libc_override_glibc.h \
  382. src/libc_override_osx.h \
  383. src/libc_override_redefine.h \
  384. src/page_heap.h \
  385. src/page_heap_allocator.h \
  386. src/span.h \
  387. src/static_vars.h \
  388. src/symbolize.h \
  389. src/thread_cache.h \
  390. src/stack_trace_table.h \
  391. src/base/thread_annotations.h \
  392. src/malloc_hook-inl.h \
  393. src/malloc_hook_mmap_linux.h \
  394. src/malloc_hook_mmap_freebsd.h
  395. SG_TCMALLOC_MINIMAL_INCLUDES = src/gperftools/malloc_hook.h \
  396. src/gperftools/malloc_hook_c.h \
  397. src/gperftools/malloc_extension.h \
  398. src/gperftools/malloc_extension_c.h \
  399. src/gperftools/nallocx.h
  400. TCMALLOC_MINIMAL_INCLUDES = $(S_TCMALLOC_MINIMAL_INCLUDES) $(SG_TCMALLOC_MINIMAL_INCLUDES) $(SG_STACKTRACE_INCLUDES)
  401. perftoolsinclude_HEADERS += $(SG_TCMALLOC_MINIMAL_INCLUDES)
  402. ### Making the library
  403. noinst_LTLIBRARIES += libtcmalloc_minimal_internal.la
  404. libtcmalloc_minimal_internal_la_SOURCES = src/common.cc \
  405. src/internal_logging.cc \
  406. $(SYSTEM_ALLOC_CC) \
  407. src/memfs_malloc.cc \
  408. src/central_freelist.cc \
  409. src/page_heap.cc \
  410. src/sampler.cc \
  411. src/span.cc \
  412. src/stack_trace_table.cc \
  413. src/static_vars.cc \
  414. src/symbolize.cc \
  415. src/thread_cache.cc \
  416. src/malloc_hook.cc \
  417. src/malloc_extension.cc \
  418. $(TCMALLOC_MINIMAL_INCLUDES)
  419. # We #define NO_TCMALLOC_SAMPLES, since sampling is turned off for _minimal.
  420. libtcmalloc_minimal_internal_la_CXXFLAGS = -DNO_TCMALLOC_SAMPLES \
  421. -DNO_HEAP_CHECK \
  422. -DNDEBUG \
  423. $(AM_CXXFLAGS)
  424. libtcmalloc_minimal_internal_la_LDFLAGS = $(AM_LDFLAGS)
  425. libtcmalloc_minimal_internal_la_LIBADD = $(LIBSPINLOCK) libmaybe_threads.la
  426. lib_LTLIBRARIES += libtcmalloc_minimal.la
  427. WINDOWS_PROJECTS += vsprojects/libtcmalloc_minimal/libtcmalloc_minimal.vcxproj
  428. libtcmalloc_minimal_la_SOURCES = $(TCMALLOC_CC) $(TCMALLOC_MINIMAL_INCLUDES)
  429. libtcmalloc_minimal_la_CXXFLAGS = -DNO_TCMALLOC_SAMPLES \
  430. $(PTHREAD_CFLAGS) -DNDEBUG $(AM_CXXFLAGS)
  431. # -version-info gets passed to libtool
  432. libtcmalloc_minimal_la_LDFLAGS = -version-info @TCMALLOC_SO_VERSION@ $(AM_LDFLAGS)
  433. libtcmalloc_minimal_la_LIBADD = libtcmalloc_minimal_internal.la
  434. # For windows, we're playing around with trying to do some stacktrace
  435. # support even with libtcmalloc_minimal. For everyone else, though,
  436. # we turn off all stack-trace activity for libtcmalloc_minimal.
  437. # TODO(csilvers): when we're done experimenting, do something principled here
  438. if MINGW
  439. LIBTCMALLOC_MINIMAL = libtcmalloc_minimal.la libstacktrace.la
  440. else !MINGW
  441. LIBTCMALLOC_MINIMAL = libtcmalloc_minimal.la
  442. endif !MINGW
  443. LIBS_TO_WEAKEN += libtcmalloc_minimal.la
  444. ### Unittests
  445. # Commented out for the moment because malloc(very_big_num) is broken in
  446. # standard libc! At least, in some situations, some of the time.
  447. ## TESTS += malloc_unittest
  448. ## MALLOC_UNITEST_INCLUDES = src/gperftools/malloc_extension.h \
  449. ## src/gperftools/malloc_hook.h \
  450. ## src/gperftools/malloc_hook_c.h \
  451. ## src/malloc_hook-inl.h \
  452. ## src/malloc_hook_mmap_linux.h \
  453. ## src/malloc_hook_mmap_freebsd.h \
  454. ## src/base/basictypes.h \
  455. ## src/maybe_threads.h
  456. ## malloc_unittest_SOURCES = src/tests/tcmalloc_unittest.cc \
  457. ## src/malloc_hook.cc \
  458. ## src/malloc_extension.cc \
  459. ## $(MAYBE_THREADS_CC) \
  460. ## $(MALLOC_UNITTEST_INCLUDES)
  461. ## malloc_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  462. ## malloc_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
  463. ## malloc_unittest_LDADD = $(PTHREAD_LIBS)
  464. TESTS += tcmalloc_minimal_unittest
  465. WINDOWS_PROJECTS += vsprojects/tcmalloc_minimal_unittest/tcmalloc_minimal_unittest.vcxproj
  466. tcmalloc_minimal_unittest_SOURCES = src/tests/tcmalloc_unittest.cc \
  467. src/tests/testutil.h src/tests/testutil.cc \
  468. $(TCMALLOC_UNITTEST_INCLUDES)
  469. tcmalloc_minimal_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  470. tcmalloc_minimal_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  471. # We want libtcmalloc last on the link line, but due to a bug in
  472. # libtool involving convenience libs, they need to come last on the
  473. # link line in order to get dependency ordering right. This is ok:
  474. # convenience libraries are .a's, so tcmalloc is still the last .so.
  475. # We also put pthreads after tcmalloc, because some pthread
  476. # implementations define their own malloc, and we need to go on the
  477. # first linkline to make sure our malloc 'wins'.
  478. tcmalloc_minimal_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) \
  479. liblogging.la $(PTHREAD_LIBS)
  480. # lets make sure we exerice ASSERTs in at least in statically linked
  481. # configuration
  482. TESTS += tcm_min_asserts_unittest
  483. tcm_min_asserts_unittest_SOURCES = src/tests/tcmalloc_unittest.cc \
  484. src/tests/testutil.h src/tests/testutil.cc \
  485. $(libtcmalloc_minimal_internal_la_SOURCES) \
  486. $(libtcmalloc_minimal_la_SOURCES) \
  487. $(TCMALLOC_UNITTEST_INCLUDES)
  488. tcm_min_asserts_unittest_CXXFLAGS = -DNO_TCMALLOC_SAMPLES -DNO_HEAP_CHECK \
  489. $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  490. tcm_min_asserts_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  491. tcm_min_asserts_unittest_LDADD = $(LIBSPINLOCK) libmaybe_threads.la \
  492. liblogging.la $(PTHREAD_LIBS)
  493. TESTS += tcmalloc_minimal_large_unittest
  494. WINDOWS_PROJECTS += vsprojects/tcmalloc_minimal_large/tcmalloc_minimal_large_unittest.vcxproj
  495. tcmalloc_minimal_large_unittest_SOURCES = src/tests/tcmalloc_large_unittest.cc
  496. tcmalloc_minimal_large_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  497. tcmalloc_minimal_large_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  498. tcmalloc_minimal_large_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  499. TESTS += tcmalloc_minimal_large_heap_fragmentation_unittest
  500. tcmalloc_minimal_large_heap_fragmentation_unittest_SOURCES = src/tests/large_heap_fragmentation_unittest.cc
  501. tcmalloc_minimal_large_heap_fragmentation_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  502. tcmalloc_minimal_large_heap_fragmentation_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  503. tcmalloc_minimal_large_heap_fragmentation_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  504. # This tests it works to LD_PRELOAD libtcmalloc (tests maybe_threads.cc)
  505. # In theory this should work under mingw, but mingw has trouble running
  506. # shell scripts that end in .exe. And it doesn't seem to build shared
  507. # libraries anyway (so can't be LD_PRELOADed) -- in fact, anybody who
  508. # chooses not to build shared libraries won't be able to run this test.
  509. # TODO(csilvers): figure out how to nix ".exe" or otherwise work under mingw
  510. if !MINGW
  511. if !ENABLE_STATIC
  512. TESTS += maybe_threads_unittest.sh$(EXEEXT)
  513. maybe_threads_unittest_sh_SOURCES = src/tests/maybe_threads_unittest.sh
  514. noinst_SCRIPTS += $(maybe_threads_unittest_sh_SOURCES)
  515. # This script preloads libtcmalloc, and calls two other binaries as well
  516. # TODO(csilvers): replace by 'if ! cmp $^ $@ >/dev/null 2>&; then ...; fi'
  517. maybe_threads_unittest.sh$(EXEEXT): $(top_srcdir)/$(maybe_threads_unittest_sh_SOURCES) \
  518. $(LIBTCMALLOC_MINIMAL) \
  519. low_level_alloc_unittest
  520. rm -f $@
  521. cp -p $(top_srcdir)/$(maybe_threads_unittest_sh_SOURCES) $@
  522. endif !ENABLE_STATIC
  523. endif !MINGW
  524. # These all tests components of tcmalloc_minimal
  525. TESTS += addressmap_unittest
  526. WINDOWS_PROJECTS += vsprojects/addressmap_unittest/addressmap_unittest.vcxproj
  527. ADDRESSMAP_UNITTEST_INCLUDES = src/addressmap-inl.h \
  528. src/base/commandlineflags.h \
  529. $(LOGGING_INCLUDES)
  530. addressmap_unittest_SOURCES = src/tests/addressmap_unittest.cc \
  531. $(ADDRESSMAP_UNITTEST_INCLUDES)
  532. if MINGW
  533. addressmap_unittest_SOURCES += src/windows/port.h src/windows/port.cc
  534. endif MINGW
  535. addressmap_unittest_CXXFLAGS = -g $(AM_CXXFLAGS)
  536. addressmap_unittest_LDADD = liblogging.la
  537. WINDOWS_PROJECTS += vsprojects/system-alloc_unittest/system-alloc_unittest.vcxproj
  538. if !MINGW
  539. TESTS += system_alloc_unittest
  540. system_alloc_unittest_SOURCES = src/config_for_unittests.h \
  541. src/tests/system-alloc_unittest.cc
  542. system_alloc_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  543. system_alloc_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  544. system_alloc_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  545. endif !MINGW
  546. TESTS += packed_cache_test
  547. WINDOWS_PROJECTS += vsprojects/packed-cache_test/packed-cache_test.vcxproj
  548. packed_cache_test_SOURCES = src/tests/packed-cache_test.cc
  549. packed_cache_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  550. packed_cache_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  551. packed_cache_test_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  552. TESTS += frag_unittest
  553. WINDOWS_PROJECTS += vsprojects/frag_unittest/frag_unittest.vcxproj
  554. frag_unittest_SOURCES = src/tests/frag_unittest.cc src/config_for_unittests.h
  555. frag_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  556. frag_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  557. frag_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  558. TESTS += markidle_unittest
  559. WINDOWS_PROJECTS += vsprojects/markidle_unittest/markidle_unittest.vcxproj
  560. markidle_unittest_SOURCES = src/tests/markidle_unittest.cc \
  561. src/config_for_unittests.h \
  562. src/tests/testutil.h src/tests/testutil.cc
  563. markidle_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  564. markidle_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  565. markidle_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  566. TESTS += current_allocated_bytes_test
  567. WINDOWS_PROJECTS += vsprojects/current_allocated_bytes_test/current_allocated_bytes_test.vcxproj
  568. current_allocated_bytes_test_SOURCES = src/tests/current_allocated_bytes_test.cc \
  569. src/config_for_unittests.h
  570. current_allocated_bytes_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  571. current_allocated_bytes_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  572. current_allocated_bytes_test_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  573. TESTS += malloc_hook_test
  574. WINDOWS_PROJECTS += vsprojects/malloc_hook_test/malloc_hook_test.vcxproj
  575. malloc_hook_test_SOURCES = src/tests/malloc_hook_test.cc \
  576. src/config_for_unittests.h \
  577. src/base/logging.h \
  578. src/gperftools/malloc_hook.h \
  579. src/tests/testutil.h src/tests/testutil.cc
  580. malloc_hook_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  581. malloc_hook_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  582. malloc_hook_test_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  583. TESTS += malloc_extension_test
  584. WINDOWS_PROJECTS += vsprojects/malloc_extension_test/malloc_extension_test.vcxproj
  585. malloc_extension_test_SOURCES = src/tests/malloc_extension_test.cc \
  586. src/config_for_unittests.h \
  587. src/base/logging.h \
  588. src/gperftools/malloc_extension.h \
  589. src/gperftools/malloc_extension_c.h
  590. malloc_extension_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  591. malloc_extension_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  592. malloc_extension_test_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  593. # This doesn't work with mingw, which links foo.a even though it
  594. # doesn't set ENABLE_STATIC. TODO(csilvers): set enable_static=true
  595. # in configure.ac:36?
  596. if !MINGW
  597. TESTS += malloc_extension_c_test
  598. malloc_extension_c_test_SOURCES = src/tests/malloc_extension_c_test.c \
  599. src/gperftools/malloc_extension.h \
  600. src/gperftools/malloc_extension_c.h
  601. malloc_extension_c_test_CFLAGS = $(PTHREAD_CFLAGS) $(AM_CFLAGS)
  602. # -ansi here is just to help ensure the code is bog-standard C.
  603. if GCC
  604. malloc_extension_c_test_CFLAGS += -ansi
  605. endif GCC
  606. malloc_extension_c_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  607. malloc_extension_c_test_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS) -lstdc++ -lm
  608. endif !MINGW
  609. if !MINGW
  610. if !OSX
  611. TESTS += memalign_unittest
  612. memalign_unittest_SOURCES = src/tests/memalign_unittest.cc \
  613. src/tcmalloc.h \
  614. src/config_for_unittests.h \
  615. src/tests/testutil.h src/tests/testutil.cc
  616. memalign_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  617. memalign_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  618. memalign_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  619. endif !OSX
  620. endif !MINGW
  621. TESTS += page_heap_test
  622. WINDOWS_PROJECTS += vsprojects/page_heap_test/page_heap_test.vcxproj
  623. page_heap_test_SOURCES = src/tests/page_heap_test.cc \
  624. src/config_for_unittests.h \
  625. src/base/logging.h \
  626. src/common.h \
  627. src/page_heap.h
  628. page_heap_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  629. page_heap_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  630. page_heap_test_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  631. TESTS += pagemap_unittest
  632. WINDOWS_PROJECTS += vsprojects/pagemap_unittest/pagemap_unittest.vcxproj
  633. pagemap_unittest_SOURCES = src/tests/pagemap_unittest.cc \
  634. src/config_for_unittests.h \
  635. src/base/logging.h \
  636. src/pagemap.h
  637. pagemap_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  638. pagemap_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  639. pagemap_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  640. TESTS += realloc_unittest
  641. WINDOWS_PROJECTS += vsprojects/realloc_unittest/realloc_unittest.vcxproj
  642. realloc_unittest_SOURCES = src/tests/realloc_unittest.cc \
  643. src/config_for_unittests.h \
  644. src/base/logging.h
  645. realloc_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  646. realloc_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  647. realloc_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  648. TESTS += stack_trace_table_test
  649. WINDOWS_PROJECTS += vsprojects/stack_trace_table_test/stack_trace_table_test.vcxproj
  650. stack_trace_table_test_SOURCES = src/tests/stack_trace_table_test.cc \
  651. src/config_for_unittests.h
  652. stack_trace_table_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  653. stack_trace_table_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  654. stack_trace_table_test_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  655. TESTS += thread_dealloc_unittest
  656. WINDOWS_PROJECTS += vsprojects/thread_dealloc_unittest/thread_dealloc_unittest.vcxproj
  657. thread_dealloc_unittest_SOURCES = src/tests/thread_dealloc_unittest.cc \
  658. src/config_for_unittests.h \
  659. src/tests/testutil.h src/tests/testutil.cc
  660. thread_dealloc_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  661. thread_dealloc_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  662. thread_dealloc_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  663. ### Documentation
  664. dist_doc_DATA += docs/tcmalloc.html \
  665. docs/overview.gif \
  666. docs/pageheap.gif \
  667. docs/spanmap.gif \
  668. docs/threadheap.gif \
  669. docs/t-test1.times.txt \
  670. docs/tcmalloc-opspercpusec.vs.threads.1024.bytes.png \
  671. docs/tcmalloc-opspercpusec.vs.threads.128.bytes.png \
  672. docs/tcmalloc-opspercpusec.vs.threads.131072.bytes.png \
  673. docs/tcmalloc-opspercpusec.vs.threads.16384.bytes.png \
  674. docs/tcmalloc-opspercpusec.vs.threads.2048.bytes.png \
  675. docs/tcmalloc-opspercpusec.vs.threads.256.bytes.png \
  676. docs/tcmalloc-opspercpusec.vs.threads.32768.bytes.png \
  677. docs/tcmalloc-opspercpusec.vs.threads.4096.bytes.png \
  678. docs/tcmalloc-opspercpusec.vs.threads.512.bytes.png \
  679. docs/tcmalloc-opspercpusec.vs.threads.64.bytes.png \
  680. docs/tcmalloc-opspercpusec.vs.threads.65536.bytes.png \
  681. docs/tcmalloc-opspercpusec.vs.threads.8192.bytes.png \
  682. docs/tcmalloc-opspersec.vs.size.1.threads.png \
  683. docs/tcmalloc-opspersec.vs.size.12.threads.png \
  684. docs/tcmalloc-opspersec.vs.size.16.threads.png \
  685. docs/tcmalloc-opspersec.vs.size.2.threads.png \
  686. docs/tcmalloc-opspersec.vs.size.20.threads.png \
  687. docs/tcmalloc-opspersec.vs.size.3.threads.png \
  688. docs/tcmalloc-opspersec.vs.size.4.threads.png \
  689. docs/tcmalloc-opspersec.vs.size.5.threads.png \
  690. docs/tcmalloc-opspersec.vs.size.8.threads.png
  691. # I don't know how to say "distribute the .dot files but don't install them";
  692. # noinst doesn't seem to work with data. I separate them out anyway, in case
  693. # one day we figure it out. Regardless, installing the dot files isn't the
  694. # end of the world.
  695. dist_doc_DATA += docs/overview.dot \
  696. docs/pageheap.dot \
  697. docs/spanmap.dot \
  698. docs/threadheap.dot
  699. ### ------- tcmalloc_minimal_debug (thread-caching malloc with debugallocation)
  700. if WITH_DEBUGALLOC
  701. lib_LTLIBRARIES += libtcmalloc_minimal_debug.la
  702. libtcmalloc_minimal_debug_la_SOURCES = src/debugallocation.cc \
  703. $(TCMALLOC_MINIMAL_INCLUDES)
  704. libtcmalloc_minimal_debug_la_CXXFLAGS = $(libtcmalloc_minimal_la_CXXFLAGS) \
  705. -DTCMALLOC_FOR_DEBUGALLOCATION
  706. # version_info gets passed to libtool
  707. libtcmalloc_minimal_debug_la_LDFLAGS = $(libtcmalloc_minimal_la_LDFLAGS) \
  708. -version-info @TCMALLOC_SO_VERSION@
  709. libtcmalloc_minimal_debug_la_LIBADD = $(libtcmalloc_minimal_la_LIBADD)
  710. LIBS_TO_WEAKEN += libtcmalloc_minimal_debug.la
  711. ### Unittests
  712. TESTS += tcmalloc_minimal_debug_unittest
  713. tcmalloc_minimal_debug_unittest_SOURCES = $(tcmalloc_minimal_unittest_SOURCES)
  714. tcmalloc_minimal_debug_unittest_CXXFLAGS = $(tcmalloc_minimal_unittest_CXXFLAGS) \
  715. -DDEBUGALLOCATION
  716. tcmalloc_minimal_debug_unittest_LDFLAGS = $(tcmalloc_minimal_unittest_LDFLAGS)
  717. tcmalloc_minimal_debug_unittest_LDADD = libtcmalloc_minimal_debug.la $(PTHREAD_LIBS)
  718. TESTS += malloc_extension_debug_test
  719. malloc_extension_debug_test_SOURCES = $(malloc_extension_test_SOURCES)
  720. malloc_extension_debug_test_CXXFLAGS = $(malloc_extension_test_CXXFLAGS)
  721. malloc_extension_debug_test_LDFLAGS = $(malloc_extension_test_LDFLAGS)
  722. malloc_extension_debug_test_LDADD = libtcmalloc_minimal_debug.la $(PTHREAD_LIBS)
  723. if !MINGW
  724. if !OSX
  725. TESTS += memalign_debug_unittest
  726. memalign_debug_unittest_SOURCES = $(memalign_unittest_SOURCES)
  727. memalign_debug_unittest_CXXFLAGS = $(memalign_unittest_CXXFLAGS)
  728. memalign_debug_unittest_LDFLAGS = $(memalign_unittest_LDFLAGS)
  729. memalign_debug_unittest_LDADD = libtcmalloc_minimal_debug.la $(PTHREAD_LIBS)
  730. endif !OSX
  731. endif !MINGW
  732. TESTS += realloc_debug_unittest
  733. realloc_debug_unittest_SOURCES = $(realloc_unittest_SOURCES)
  734. realloc_debug_unittest_CXXFLAGS = $(realloc_unittest_CXXFLAGS)
  735. realloc_debug_unittest_LDFLAGS = $(realloc_unittest_LDFLAGS)
  736. realloc_debug_unittest_LDADD = libtcmalloc_minimal_debug.la $(PTHREAD_LIBS)
  737. # debugallocation_test checks that we print a proper stacktrace when
  738. # debug-allocs fail, so we can't run it if we don't have stacktrace info.
  739. if WITH_STACK_TRACE
  740. TESTS += debugallocation_test.sh$(EXEEXT)
  741. debugallocation_test_sh_SOURCES = src/tests/debugallocation_test.sh
  742. noinst_SCRIPTS += $(debugallocation_test_sh_SOURCES)
  743. debugallocation_test.sh$(EXEEXT): $(top_srcdir)/$(debugallocation_test_sh_SOURCES) \
  744. debugallocation_test
  745. rm -f $@
  746. cp -p $(top_srcdir)/$(debugallocation_test_sh_SOURCES) $@
  747. # This is the sub-program used by debugallocation_test.sh
  748. noinst_PROGRAMS += debugallocation_test
  749. debugallocation_test_SOURCES = src/tests/debugallocation_test.cc
  750. debugallocation_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  751. debugallocation_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  752. debugallocation_test_LDADD = libtcmalloc_debug.la $(PTHREAD_LIBS)
  753. endif WITH_STACK_TRACE
  754. endif WITH_DEBUGALLOC
  755. if !MINGW
  756. noinst_LTLIBRARIES += librun_benchmark.la
  757. librun_benchmark_la_SOURCES = \
  758. benchmark/run_benchmark.c benchmark/run_benchmark.h
  759. noinst_PROGRAMS += malloc_bench malloc_bench_shared \
  760. binary_trees binary_trees_shared
  761. malloc_bench_SOURCES = benchmark/malloc_bench.cc
  762. malloc_bench_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  763. malloc_bench_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  764. if ENABLE_STATIC
  765. malloc_bench_LDFLAGS += -static
  766. endif ENABLE_STATIC
  767. malloc_bench_LDADD = librun_benchmark.la libtcmalloc_minimal.la $(PTHREAD_LIBS)
  768. malloc_bench_shared_SOURCES = benchmark/malloc_bench.cc
  769. malloc_bench_shared_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  770. malloc_bench_shared_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  771. malloc_bench_shared_LDADD = librun_benchmark.la libtcmalloc_minimal.la $(PTHREAD_LIBS)
  772. if WITH_HEAP_PROFILER_OR_CHECKER
  773. noinst_PROGRAMS += malloc_bench_shared_full
  774. malloc_bench_shared_full_SOURCES = benchmark/malloc_bench.cc
  775. malloc_bench_shared_full_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  776. malloc_bench_shared_full_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  777. malloc_bench_shared_full_LDADD = librun_benchmark.la libtcmalloc.la $(PTHREAD_LIBS)
  778. endif WITH_HEAP_PROFILER_OR_CHECKER
  779. binary_trees_SOURCES = benchmark/binary_trees.cc
  780. binary_trees_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  781. binary_trees_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  782. if ENABLE_STATIC
  783. binary_trees_LDFLAGS += -static
  784. endif ENABLE_STATIC
  785. binary_trees_LDADD = libtcmalloc_minimal.la $(PTHREAD_LIBS)
  786. binary_trees_shared_SOURCES = benchmark/binary_trees.cc
  787. binary_trees_shared_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  788. binary_trees_shared_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  789. binary_trees_shared_LDADD = libtcmalloc_minimal.la $(PTHREAD_LIBS)
  790. endif !MINGW
  791. ### ------- tcmalloc (thread-caching malloc + heap profiler + heap checker)
  792. if WITH_HEAP_PROFILER_OR_CHECKER
  793. ### The header files we use. We divide into categories based on directory
  794. S_TCMALLOC_INCLUDES = $(S_TCMALLOC_MINIMAL_INCLUDES) \
  795. $(LOGGING_INCLUDES) \
  796. src/addressmap-inl.h \
  797. src/raw_printer.h \
  798. src/base/elfcore.h \
  799. src/base/googleinit.h \
  800. src/base/linux_syscall_support.h \
  801. src/base/linuxthreads.h \
  802. src/base/stl_allocator.h \
  803. src/base/sysinfo.h \
  804. src/base/thread_lister.h \
  805. src/heap-profile-table.h \
  806. src/heap-profile-stats.h \
  807. src/maybe_emergency_malloc.h \
  808. src/emergency_malloc.h
  809. SG_TCMALLOC_INCLUDES = src/gperftools/heap-profiler.h \
  810. src/gperftools/heap-checker.h
  811. TCMALLOC_INCLUDES = $(S_TCMALLOC_INCLUDES) $(SG_TCMALLOC_MINIMAL_INCLUDES) \
  812. $(SG_TCMALLOC_INCLUDES) $(SG_STACKTRACE_INCLUDES)
  813. perftoolsinclude_HEADERS += $(SG_TCMALLOC_INCLUDES)
  814. if BUILD_EMERGENCY_MALLOC
  815. EMERGENCY_MALLOC_CC = src/emergency_malloc.cc src/emergency_malloc_for_stacktrace.cc
  816. EMERGENCY_MALLOC_DEFINE = -DENABLE_EMERGENCY_MALLOC
  817. else !BUILD_EMERGENCY_MALLOC
  818. EMERGENCY_MALLOC_CC = src/fake_stacktrace_scope.cc
  819. EMERGENCY_MALLOC_DEFINE =
  820. endif !BUILD_EMERGENCY_MALLOC
  821. ### Making the library
  822. noinst_LTLIBRARIES += libtcmalloc_internal.la
  823. libtcmalloc_internal_la_SOURCES = $(libtcmalloc_minimal_internal_la_SOURCES) \
  824. $(TCMALLOC_INCLUDES) \
  825. src/base/low_level_alloc.cc \
  826. src/heap-profile-table.cc \
  827. src/heap-profiler.cc \
  828. src/raw_printer.cc \
  829. $(EMERGENCY_MALLOC_CC) \
  830. src/memory_region_map.cc
  831. libtcmalloc_internal_la_CXXFLAGS = $(PTHREAD_CFLAGS) -DNDEBUG \
  832. $(AM_CXXFLAGS) $(EMERGENCY_MALLOC_DEFINE)
  833. libtcmalloc_internal_la_LDFLAGS = $(PTHREAD_CFLAGS)
  834. libtcmalloc_internal_la_LIBADD = libstacktrace.la $(PTHREAD_LIBS)
  835. lib_LTLIBRARIES += libtcmalloc.la
  836. libtcmalloc_la_SOURCES = $(TCMALLOC_CC) $(TCMALLOC_INCLUDES)
  837. libtcmalloc_la_CXXFLAGS = $(PTHREAD_CFLAGS) -DNDEBUG $(AM_CXXFLAGS) $(EMERGENCY_MALLOC_DEFINE)
  838. libtcmalloc_la_LDFLAGS = $(PTHREAD_CFLAGS) -version-info @TCMALLOC_SO_VERSION@
  839. libtcmalloc_la_LIBADD = libtcmalloc_internal.la libmaybe_threads.la $(PTHREAD_LIBS)
  840. if WITH_HEAP_CHECKER
  841. # heap-checker-bcad is last, in hopes its global ctor will run first.
  842. # (Note this is added to libtcmalloc.la, not libtcmalloc_internal.la,
  843. # but that's ok; the internal/external distinction is only useful for
  844. # cygwin, and cygwin doesn't use HEAP_CHECKER anyway.)
  845. HEAP_CHECKER_SOURCES = src/base/thread_lister.c \
  846. src/base/linuxthreads.cc \
  847. src/heap-checker.cc \
  848. src/heap-checker-bcad.cc
  849. libtcmalloc_la_SOURCES += $(HEAP_CHECKER_SOURCES)
  850. else !WITH_HEAP_CHECKER
  851. HEAP_CHECKER_SOURCES =
  852. libtcmalloc_internal_la_CXXFLAGS += -DNO_HEAP_CHECK
  853. libtcmalloc_la_CXXFLAGS += -DNO_HEAP_CHECK
  854. endif !WITH_HEAP_CHECKER
  855. LIBTCMALLOC = libtcmalloc.la
  856. LIBS_TO_WEAKEN += libtcmalloc.la
  857. ### Unittests
  858. TESTS += tcmalloc_unittest.sh$(EXEEXT)
  859. tcmalloc_unittest_sh_SOURCES = src/tests/tcmalloc_unittest.sh
  860. noinst_SCRIPTS += $(tcmalloc_unittest_sh_SOURCES)
  861. tcmalloc_unittest.sh$(EXEEXT): $(top_srcdir)/$(tcmalloc_unittest_sh_SOURCES) \
  862. tcmalloc_unittest
  863. rm -f $@
  864. cp -p $(top_srcdir)/$(tcmalloc_unittest_sh_SOURCES) $@
  865. noinst_PROGRAMS += tcmalloc_unittest
  866. tcmalloc_unittest_INCLUDES = src/config_for_unittests.h \
  867. src/gperftools/malloc_extension.h
  868. tcmalloc_unittest_SOURCES = src/tests/tcmalloc_unittest.cc \
  869. src/tcmalloc.h \
  870. src/tests/testutil.h src/tests/testutil.cc \
  871. $(TCMALLOC_UNITTEST_INCLUDES)
  872. tcmalloc_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  873. tcmalloc_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  874. # We want libtcmalloc last on the link line, but due to a bug in
  875. # libtool involving convenience libs, they need to come last on the
  876. # link line in order to get dependency ordering right. This is ok:
  877. # convenience libraries are .a's, so tcmalloc is still the last .so.
  878. # We also put pthreads after tcmalloc, because some pthread
  879. # implementations define their own malloc, and we need to go on the
  880. # first linkline to make sure our malloc 'wins'.
  881. tcmalloc_unittest_LDADD = $(LIBTCMALLOC) liblogging.la $(PTHREAD_LIBS)
  882. # # lets make sure we exerice ASSERTs in at least in statically linked
  883. # # configuration
  884. # TESTS += tcm_asserts_unittest
  885. # tcm_asserts_unittest_SOURCES = src/tests/tcmalloc_unittest.cc \
  886. # src/tests/testutil.h src/tests/testutil.cc \
  887. # $(libtcmalloc_internal_la_SOURCES) \
  888. # $(libtcmalloc_la_SOURCES) \
  889. # $(TCMALLOC_UNITTEST_INCLUDES)
  890. # tcm_asserts_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  891. # tcm_asserts_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  892. # tcm_asserts_unittest_LDADD = $(LIBSPINLOCK) libmaybe_threads.la libstacktrace.la \
  893. # liblogging.la $(PTHREAD_LIBS)
  894. # This makes sure it's safe to link in both tcmalloc and
  895. # tcmalloc_minimal. (One would never do this on purpose, but perhaps
  896. # by accident...) When we can compile libprofiler, we also link it in
  897. # to make sure that works too. NOTE: On OS X, it's *not* safe to
  898. # link both in (we end up with two copies of every global var, and
  899. # the code tends to pick one arbitrarily), so don't run the test there.
  900. # (We define these outside the 'if' because they're reused below.)
  901. tcmalloc_both_unittest_srcs = src/tests/tcmalloc_unittest.cc \
  902. src/tests/testutil.h src/tests/testutil.cc \
  903. $(TCMALLOC_UNITTEST_INCLUDES)
  904. tcmalloc_both_unittest_cflags = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  905. tcmalloc_both_unittest_lflags = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  906. if WITH_CPU_PROFILER
  907. # We want libtcmalloc last on the link line, but due to a bug in
  908. # libtool involving convenience libs, they need to come last on the
  909. # link line in order to get dependency ordering right. This is ok:
  910. # convenience libraries are .a's, so tcmalloc is still the last .so.
  911. # We also put pthreads after tcmalloc, because some pthread
  912. # implementations define their own malloc, and we need to go on the
  913. # first linkline to make sure our malloc 'wins'.
  914. tcmalloc_both_unittest_ladd = $(LIBTCMALLOC) $(LIBTCMALLOC_MINIMAL) \
  915. libprofiler.la liblogging.la $(PTHREAD_LIBS)
  916. else
  917. tcmalloc_both_unittest_ladd = $(LIBTCMALLOC) $(LIBTCMALLOC_MINIMAL) \
  918. liblogging.la $(PTHREAD_LIBS)
  919. endif !WITH_CPU_PROFILER
  920. if !OSX
  921. TESTS += tcmalloc_both_unittest
  922. tcmalloc_both_unittest_SOURCES = $(tcmalloc_both_unittest_srcs)
  923. tcmalloc_both_unittest_CXXFLAGS = $(tcmalloc_both_unittest_cflags)
  924. tcmalloc_both_unittest_LDFLAGS = $(tcmalloc_both_unittest_lflags)
  925. tcmalloc_both_unittest_LDADD = $(tcmalloc_both_unittest_ladd)
  926. endif !OSX
  927. TESTS += tcmalloc_large_unittest
  928. tcmalloc_large_unittest_SOURCES = src/tests/tcmalloc_large_unittest.cc
  929. tcmalloc_large_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  930. tcmalloc_large_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  931. tcmalloc_large_unittest_LDADD = $(LIBTCMALLOC) $(PTHREAD_LIBS)
  932. TESTS += tcmalloc_large_heap_fragmentation_unittest
  933. tcmalloc_large_heap_fragmentation_unittest_SOURCES = src/tests/large_heap_fragmentation_unittest.cc
  934. tcmalloc_large_heap_fragmentation_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  935. tcmalloc_large_heap_fragmentation_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  936. tcmalloc_large_heap_fragmentation_unittest_LDADD = $(LIBTCMALLOC) $(PTHREAD_LIBS)
  937. TESTS += raw_printer_test
  938. raw_printer_test_SOURCES = src/tests/raw_printer_test.cc
  939. raw_printer_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  940. raw_printer_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  941. raw_printer_test_LDADD = $(LIBTCMALLOC) $(PTHREAD_LIBS)
  942. # sampler_test and sampling_test both require sampling to be turned
  943. # on, which it's not by default. Use the "standard" value of 2^19.
  944. TESTS_ENVIRONMENT += TCMALLOC_SAMPLE_PARAMETER=524288
  945. TESTS += sampler_test
  946. WINDOWS_PROJECTS += vsprojects/sampler_test/sampler_test.vcxproj
  947. sampler_test_SOURCES = src/tests/sampler_test.cc \
  948. src/config_for_unittests.h
  949. sampler_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  950. sampler_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  951. sampler_test_LDADD = $(LIBTCMALLOC) $(PTHREAD_LIBS) -lm
  952. # These unittests often need to run binaries. They're in the current dir
  953. TESTS_ENVIRONMENT += BINDIR=.
  954. TESTS_ENVIRONMENT += TMPDIR=/tmp/perftools
  955. TESTS += sampling_test.sh$(EXEEXT)
  956. sampling_test_sh_SOURCES = src/tests/sampling_test.sh
  957. noinst_SCRIPTS += $(sampling_test_sh_SOURCES)
  958. sampling_test.sh$(EXEEXT): $(top_srcdir)/$(sampling_test_sh_SOURCES) \
  959. sampling_test
  960. rm -f $@
  961. cp -p $(top_srcdir)/$(sampling_test_sh_SOURCES) $@
  962. # This is the sub-program used by sampling_test.sh
  963. # The -g is so pprof can get symbol information.
  964. noinst_PROGRAMS += sampling_test
  965. SAMPLING_TEST_INCLUDES = src/config_for_unittests.h \
  966. src/base/logging.h \
  967. src/gperftools/malloc_extension.h
  968. sampling_test_SOURCES = src/tests/sampling_test.cc \
  969. $(SAMPLING_TEST_INCLUDES)
  970. sampling_test_CXXFLAGS = -g $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  971. sampling_test_LDFLAGS = -g $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  972. sampling_test_LDADD = $(LIBTCMALLOC) $(PTHREAD_LIBS)
  973. endif WITH_HEAP_PROFILER_OR_CHECKER
  974. if WITH_HEAP_PROFILER
  975. TESTS += heap-profiler_unittest.sh$(EXEEXT)
  976. heap_profiler_unittest_sh_SOURCES = src/tests/heap-profiler_unittest.sh
  977. noinst_SCRIPTS += $(heap_profiler_unittest_sh_SOURCES)
  978. heap-profiler_unittest.sh$(EXEEXT): $(top_srcdir)/$(heap_profiler_unittest_sh_SOURCES) \
  979. heap-profiler_unittest
  980. rm -f $@
  981. cp -p $(top_srcdir)/$(heap_profiler_unittest_sh_SOURCES) $@
  982. # These are sub-programs used by heap-profiler_unittest.sh
  983. noinst_PROGRAMS += heap-profiler_unittest
  984. HEAP_PROFILER_UNITTEST_INCLUDES = src/config_for_unittests.h \
  985. src/gperftools/heap-profiler.h
  986. heap_profiler_unittest_SOURCES = src/tests/heap-profiler_unittest.cc \
  987. $(HEAP_PROFILER_UNITTEST_INCLUDES)
  988. heap_profiler_unittest_CXXFLAGS = -g $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  989. heap_profiler_unittest_LDFLAGS = -g $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  990. heap_profiler_unittest_LDADD = $(LIBTCMALLOC) $(PTHREAD_LIBS)
  991. # Tests the compatibility include-headers in google/. Requires a function
  992. # defined in the heap-profiler, which is why the test lives here.
  993. TESTS += simple_compat_test
  994. simple_compat_test_SOURCES = src/tests/simple_compat_test.cc \
  995. $(googleinclude_HEADERS)
  996. simple_compat_test_LDFLAGS = $(TCMALLOC_FLAGS)
  997. simple_compat_test_LDADD = $(LIBTCMALLOC)
  998. endif WITH_HEAP_PROFILER
  999. if WITH_HEAP_CHECKER
  1000. TESTS += heap-checker_unittest.sh$(EXEEXT)
  1001. heap_checker_unittest_sh_SOURCES = src/tests/heap-checker_unittest.sh
  1002. noinst_SCRIPTS += $(heap_checker_unittest_sh_SOURCES)
  1003. heap-checker_unittest.sh$(EXEEXT): $(top_srcdir)/$(heap_checker_unittest_sh_SOURCES) \
  1004. heap-checker_unittest
  1005. rm -f $@
  1006. cp -p $(top_srcdir)/$(heap_checker_unittest_sh_SOURCES) $@
  1007. TESTS += heap-checker-death_unittest.sh$(EXEEXT)
  1008. heap_checker_death_unittest_sh_SOURCES = src/tests/heap-checker-death_unittest.sh
  1009. noinst_SCRIPTS += $(top_srcdir)/$(heap_checker_death_unittest_sh_SOURCES)
  1010. heap-checker-death_unittest.sh$(EXEEXT): $(heap_checker_death_unittest_sh_SOURCES) \
  1011. heap-checker_unittest
  1012. rm -f $@
  1013. cp -p $(top_srcdir)/$(heap_checker_death_unittest_sh_SOURCES) $@
  1014. # These are sub-programs used by heap-checker_unittest.sh
  1015. noinst_PROGRAMS += heap-checker_unittest
  1016. HEAP_CHECKER_UNITTEST_INCLUDES = src/config_for_unittests.h \
  1017. src/memory_region_map.h \
  1018. src/base/commandlineflags.h \
  1019. src/base/googleinit.h \
  1020. src/gperftools/heap-checker.h \
  1021. $(LOGGING_INCLUDES)
  1022. heap_checker_unittest_SOURCES = src/tests/heap-checker_unittest.cc \
  1023. $(HEAP_CHECKER_UNITTEST_INCLUDES)
  1024. heap_checker_unittest_CXXFLAGS = -g $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  1025. heap_checker_unittest_LDFLAGS = -g $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  1026. # We want libtcmalloc last on the link line, but due to a bug in
  1027. # libtool involving convenience libs, they need to come last on the
  1028. # link line in order to get dependency ordering right. This is ok:
  1029. # convenience libraries are .a's, so tcmalloc is still the last .so.
  1030. # We also put pthreads after tcmalloc, because some pthread
  1031. # implementations define their own malloc, and we need to go on the
  1032. # first linkline to make sure our malloc 'wins'.
  1033. heap_checker_unittest_LDADD = $(LIBTCMALLOC) liblogging.la $(PTHREAD_LIBS)
  1034. endif WITH_HEAP_CHECKER
  1035. ### Documentation (above and beyond tcmalloc_minimal documentation)
  1036. if WITH_HEAP_PROFILER
  1037. dist_doc_DATA += docs/heapprofile.html docs/heap-example1.png
  1038. endif WITH_HEAP_PROFILER
  1039. if WITH_HEAP_CHECKER
  1040. dist_doc_DATA += docs/heap_checker.html
  1041. endif WITH_HEAP_CHECKER
  1042. ### ------- tcmalloc with debugallocation
  1043. if WITH_DEBUGALLOC
  1044. if WITH_HEAP_PROFILER_OR_CHECKER
  1045. lib_LTLIBRARIES += libtcmalloc_debug.la
  1046. libtcmalloc_debug_la_SOURCES = src/debugallocation.cc $(HEAP_CHECKER_SOURCES) \
  1047. $(TCMALLOC_INCLUDES)
  1048. libtcmalloc_debug_la_CXXFLAGS = $(libtcmalloc_la_CXXFLAGS) \
  1049. -DTCMALLOC_FOR_DEBUGALLOCATION
  1050. libtcmalloc_debug_la_LDFLAGS = $(libtcmalloc_la_LDFLAGS) \
  1051. -version-info @TCMALLOC_SO_VERSION@
  1052. libtcmalloc_debug_la_LIBADD = $(libtcmalloc_la_LIBADD)
  1053. LIBS_TO_WEAKEN += libtcmalloc_debug.la
  1054. ### Unittests
  1055. TESTS += tcmalloc_debug_unittest
  1056. tcmalloc_debug_unittest_SOURCES = $(tcmalloc_unittest_SOURCES)
  1057. tcmalloc_debug_unittest_CXXFLAGS = $(tcmalloc_unittest_CXXFLAGS) \
  1058. -DDEBUGALLOCATION
  1059. tcmalloc_debug_unittest_LDFLAGS = $(tcmalloc_unittest_LDFLAGS)
  1060. tcmalloc_debug_unittest_LDADD = libtcmalloc_debug.la $(PTHREAD_LIBS)
  1061. TESTS += sampler_debug_test
  1062. sampler_debug_test_SOURCES = $(sampler_test_SOURCES)
  1063. sampler_debug_test_CXXFLAGS = $(samples_test_CXXFLAGS)
  1064. sampler_debug_test_LDFLAGS = $(sampler_test_LDFLAGS)
  1065. sampler_debug_test_LDADD = libtcmalloc_debug.la $(PTHREAD_LIBS) -lm
  1066. TESTS += sampling_debug_test.sh$(EXEEXT)
  1067. sampling_debug_test_sh_SOURCES = src/tests/sampling_test.sh
  1068. sampling_debug_test.sh$(EXEEXT): $(top_srcdir)/$(sampling_test_sh_SOURCES) \
  1069. sampling_debug_test
  1070. rm -f $@
  1071. cp -p $(top_srcdir)/$(sampling_test_sh_SOURCES) $@
  1072. # This is the sub-program using by sampling_debug_test.sh
  1073. # The -g is so pprof can get symbol information.
  1074. noinst_PROGRAMS += sampling_debug_test
  1075. sampling_debug_test_SOURCES = $(sampling_test_SOURCES)
  1076. sampling_debug_test_CXXFLAGS = $(sampling_test_CXXFLAGS)
  1077. sampling_debug_test_LDFLAGS = $(sampling_test_LDFLAGS)
  1078. sampling_debug_test_LDADD = libtcmalloc_debug.la $(PTHREAD_LIBS)
  1079. endif WITH_HEAP_PROFILER_OR_CHECKER
  1080. if WITH_HEAP_PROFILER
  1081. TESTS += heap-profiler_debug_unittest.sh$(EXEEXT)
  1082. heap_profiler_debug_unittest_sh_SOURCES = src/tests/heap-profiler_unittest.sh
  1083. heap-profiler_debug_unittest.sh$(EXEEXT): $(top_srcdir)/$(heap_profiler_unittest_sh_SOURCES) \
  1084. heap-profiler_debug_unittest
  1085. rm -f $@
  1086. cp -p $(top_srcdir)/$(heap_profiler_unittest_sh_SOURCES) $@
  1087. # These are sub-programs used by heap-profiler_debug_unittest.sh
  1088. noinst_PROGRAMS += heap-profiler_debug_unittest
  1089. heap_profiler_debug_unittest_SOURCES = $(heap_profiler_unittest_SOURCES)
  1090. heap_profiler_debug_unittest_CXXFLAGS = $(heap_profiler_unittest_CXXFLAGS)
  1091. heap_profiler_debug_unittest_LDFLAGS = $(heap_profiler_unittest_LDFLAGS)
  1092. heap_profiler_debug_unittest_LDADD = libtcmalloc_debug.la $(PTHREAD_LIBS)
  1093. endif WITH_HEAP_PROFILER
  1094. if WITH_HEAP_CHECKER
  1095. TESTS += heap-checker_debug_unittest.sh$(EXEEXT)
  1096. heap_checker_debug_unittest_sh_SOURCES = src/tests/heap-checker_unittest.sh
  1097. heap-checker_debug_unittest.sh$(EXEEXT): $(top_srcdir)/$(heap_checker_unittest_sh_SOURCES) \
  1098. heap-checker_debug_unittest
  1099. rm -f $@
  1100. cp -p $(top_srcdir)/$(heap_checker_unittest_sh_SOURCES) $@
  1101. # These are sub-programs used by heap-checker_debug_unittest.sh
  1102. noinst_PROGRAMS += heap-checker_debug_unittest
  1103. heap_checker_debug_unittest_SOURCES = $(heap_checker_unittest_SOURCES)
  1104. heap_checker_debug_unittest_CXXFLAGS = $(heap_checker_unittest_CXXFLAGS)
  1105. heap_checker_debug_unittest_LDFLAGS = $(heap_checker_unittest_LDFLAGS)
  1106. # We want libtcmalloc last on the link line, but due to a bug in
  1107. # libtool involving convenience libs, they need to come last on the
  1108. # link line in order to get dependency ordering right. This is ok:
  1109. # convenience libraries are .a's, so tcmalloc is still the last .so.
  1110. heap_checker_debug_unittest_LDADD = libtcmalloc_debug.la liblogging.la \
  1111. $(PTHREAD_LIBS)
  1112. endif WITH_HEAP_CHECKER
  1113. endif WITH_DEBUGALLOC
  1114. ### ------- CPU profiler
  1115. if WITH_CPU_PROFILER
  1116. ### The header files we use. We divide into categories based on directory
  1117. S_CPU_PROFILER_INCLUDES = src/profiledata.h \
  1118. src/profile-handler.h \
  1119. src/getpc.h \
  1120. src/base/basictypes.h \
  1121. src/base/commandlineflags.h \
  1122. src/base/googleinit.h \
  1123. src/base/logging.h \
  1124. src/base/simple_mutex.h \
  1125. src/base/sysinfo.h \
  1126. $(SPINLOCK_INCLUDES) \
  1127. $(LOGGING_INCLUDES)
  1128. SG_CPU_PROFILER_INCLUDES = src/gperftools/profiler.h
  1129. CPU_PROFILER_INCLUDES = $(S_CPU_PROFILER_INCLUDES) $(SG_CPU_PROFILER_INCLUDES) \
  1130. $(SG_STACKTRACE_INCLUDES)
  1131. perftoolsinclude_HEADERS += $(SG_CPU_PROFILER_INCLUDES)
  1132. ### Making the library
  1133. lib_LTLIBRARIES += libprofiler.la
  1134. libprofiler_la_SOURCES = src/profiler.cc \
  1135. src/profile-handler.cc \
  1136. src/profiledata.cc \
  1137. $(CPU_PROFILER_INCLUDES)
  1138. libprofiler_la_LIBADD = libstacktrace.la libmaybe_threads.la libfake_stacktrace_scope.la
  1139. # We have to include ProfileData for profiledata_unittest
  1140. CPU_PROFILER_SYMBOLS = '(ProfilerStart|ProfilerStartWithOptions|ProfilerStop|ProfilerFlush|ProfilerEnable|ProfilerDisable|ProfilingIsEnabledForAllThreads|ProfilerRegisterThread|ProfilerGetCurrentState|ProfilerState|ProfileData|ProfileHandler)'
  1141. libprofiler_la_LDFLAGS = -export-symbols-regex $(CPU_PROFILER_SYMBOLS) \
  1142. -version-info @PROFILER_SO_VERSION@
  1143. # See discussion above (under LIBTCMALLOC_MINIMAL) for why we do this.
  1144. # Basically it's to work around systems where --rpath doesn't work right.
  1145. LIBPROFILER = libstacktrace.la libprofiler.la
  1146. ### Unittests
  1147. TESTS += getpc_test
  1148. #WINDOWS_PROJECTS += vsprojects/getpc_test/getpc_test.vcxproj
  1149. getpc_test_SOURCES = src/tests/getpc_test.cc src/getpc.h
  1150. TESTS += profiledata_unittest
  1151. #WINDOWS_PROJECTS += vsprojects/profiledata_unittest/profiledata_unittest.vcxproj
  1152. profiledata_unittest_SOURCES = src/tests/profiledata_unittest.cc \
  1153. src/profiledata.h \
  1154. src/base/commandlineflags.h \
  1155. src/base/logging.h \
  1156. src/base/basictypes.h
  1157. profiledata_unittest_LDADD = $(LIBPROFILER)
  1158. TESTS += profile_handler_unittest
  1159. profile_handler_unittest_SOURCES = src/tests/profile-handler_unittest.cc \
  1160. src/profile-handler.h
  1161. profile_handler_unittest_CXXFLAGS = $(PTHREAD_CFLAGS)
  1162. profile_handler_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
  1163. profile_handler_unittest_LDADD = $(LIBPROFILER) $(PTHREAD_LIBS)
  1164. TESTS += profiler_unittest.sh$(EXEEXT)
  1165. profiler_unittest_sh_SOURCES = src/tests/profiler_unittest.sh
  1166. noinst_SCRIPTS += $(profiler_unittest_sh_SOURCES)
  1167. profiler_unittest.sh$(EXEEXT): $(top_srcdir)/$(profiler_unittest_sh_SOURCES) \
  1168. profiler1_unittest profiler2_unittest \
  1169. profiler3_unittest profiler4_unittest
  1170. rm -f $@
  1171. cp -p $(top_srcdir)/$(profiler_unittest_sh_SOURCES) $@
  1172. # These are sub-programs used by profiler_unittest.sh
  1173. noinst_PROGRAMS += profiler1_unittest profiler2_unittest profiler3_unittest \
  1174. profiler4_unittest
  1175. PROFILER_UNITTEST_INCLUDES = src/config_for_unittests.h \
  1176. src/gperftools/profiler.h
  1177. PROFILER_UNITTEST_SRCS = src/tests/profiler_unittest.cc \
  1178. src/tests/testutil.h src/tests/testutil.cc \
  1179. $(PROFILER_UNITTEST_INCLUDES)
  1180. profiler1_unittest_SOURCES = $(PROFILER_UNITTEST_SRCS)
  1181. profiler1_unittest_CXXFLAGS = -g -DNO_THREADS $(AM_CXXFLAGS)
  1182. profiler1_unittest_LDADD = $(LIBPROFILER)
  1183. profiler2_unittest_SOURCES = $(PROFILER_UNITTEST_SRCS)
  1184. profiler2_unittest_CXXFLAGS = -g -DNO_THREADS $(AM_CXXFLAGS)
  1185. profiler2_unittest_LDADD = -lstacktrace -lprofiler
  1186. # We depend on -lprofiler but haven't yet said how to build it. Do so now.
  1187. profiler2_unittest_DEPENDENCIES = $(LIBPROFILER)
  1188. profiler3_unittest_SOURCES = $(PROFILER_UNITTEST_SRCS)
  1189. profiler3_unittest_CXXFLAGS = -g $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  1190. profiler3_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
  1191. profiler3_unittest_LDADD = $(LIBPROFILER) $(PTHREAD_LIBS)
  1192. profiler4_unittest_SOURCES = $(PROFILER_UNITTEST_SRCS)
  1193. profiler4_unittest_CXXFLAGS = -g $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  1194. profiler4_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
  1195. profiler4_unittest_LDADD = -lstacktrace -lprofiler $(PTHREAD_LIBS)
  1196. # We depend on -lprofiler but haven't yet said how to build it. Do so now.
  1197. profiler4_unittest_DEPENDENCIES = $(LIBPROFILER)
  1198. ### Documentation
  1199. dist_doc_DATA += docs/cpuprofile.html \
  1200. docs/cpuprofile-fileformat.html \
  1201. docs/pprof-test-big.gif \
  1202. docs/pprof-test.gif \
  1203. docs/pprof-vsnprintf-big.gif \
  1204. docs/pprof-vsnprintf.gif
  1205. endif WITH_CPU_PROFILER
  1206. ### ------- CPU profiler and heap checker, in one!
  1207. # Ideally, folks who wanted to use both tcmalloc and libprofiler,
  1208. # could just link them both into their application. But while this
  1209. # works fine for .so files, it does not for .a files. The easiest way
  1210. # around this -- and I've tried a bunch of the hard ways -- is to just
  1211. # to create another set of libraries that has both functionality in it.
  1212. if WITH_HEAP_PROFILER_OR_CHECKER
  1213. if WITH_CPU_PROFILER
  1214. lib_LTLIBRARIES += libtcmalloc_and_profiler.la
  1215. libtcmalloc_and_profiler_la_SOURCES = $(libtcmalloc_la_SOURCES) $(libprofiler_la_SOURCES)
  1216. libtcmalloc_and_profiler_la_CXXFLAGS = $(libtcmalloc_la_CXXFLAGS) $(libprofiler_la_CXXFLAGS)
  1217. # Since this library is meant to be used as a .a, I don't worry as much
  1218. # about .so versioning. I just give the libtcmalloc version number.
  1219. # TODO(csilvers): use -export-symbols-regex?
  1220. libtcmalloc_and_profiler_la_LDFLAGS = $(PTHREAD_CFLAGS) \
  1221. -version-info @TCMALLOC_SO_VERSION@
  1222. # We don't include libprofiler_la_LIBADD here because all it adds is
  1223. # libstacktrace.la, which we already get via libtcmalloc. Trying to
  1224. # specify it twice causes link-time duplicate-definition errors. :-(
  1225. libtcmalloc_and_profiler_la_LIBADD = $(libtcmalloc_la_LIBADD)
  1226. TESTS += tcmalloc_and_profiler_unittest
  1227. tcmalloc_and_profiler_unittest_SOURCES = $(tcmalloc_both_unittest_srcs)
  1228. tcmalloc_and_profiler_unittest_CXXFLAGS = $(tcmalloc_both_unittest_cflags)
  1229. tcmalloc_and_profiler_unittest_LDFLAGS = $(tcmalloc_both_unittest_lflags)
  1230. tcmalloc_and_profiler_unittest_LDADD = libtcmalloc_and_profiler.la
  1231. LIBS_TO_WEAKEN += libtcmalloc_and_profiler.la
  1232. endif WITH_CPU_PROFILER
  1233. endif WITH_HEAP_PROFILER_OR_CHECKER
  1234. ## ^^^^ END OF RULES TO MAKE YOUR LIBRARIES, BINARIES, AND UNITTESTS
  1235. # Do the weakening on some exported libtcmalloc symbols.
  1236. install-exec-local: all-local
  1237. all-local: $(LIBS_TO_WEAKEN)
  1238. for la in $(LIBS_TO_WEAKEN); do lib=".libs/`basename $$la .la`.a"; [ ! -f "$$lib" ] || $(WEAKEN) "$$lib"; done
  1239. # This should always include $(TESTS), but may also include other
  1240. # binaries that you compile but don't want automatically installed.
  1241. # We'll add to this later, on a library-by-library basis
  1242. noinst_PROGRAMS += $(TESTS)
  1243. rpm: dist-gzip packages/rpm.sh packages/rpm/rpm.spec
  1244. @cd packages && ./rpm.sh ${PACKAGE} ${VERSION}
  1245. deb: dist-gzip packages/deb.sh packages/deb/*
  1246. @cd packages && ./deb.sh ${PACKAGE} ${VERSION}
  1247. # http://linux.die.net/man/1/pkg-config, http://pkg-config.freedesktop.org/wiki
  1248. pkgconfigdir = $(libdir)/pkgconfig
  1249. pkgconfig_DATA = libtcmalloc.pc libtcmalloc_minimal.pc \
  1250. libtcmalloc_debug.pc libtcmalloc_minimal_debug.pc \
  1251. libprofiler.pc
  1252. CLEANFILES = $(pkgconfig_DATA)
  1253. # I get the description and URL lines from the rpm spec. I use sed to
  1254. # try to rewrite exec_prefix, libdir, and includedir in terms of
  1255. # prefix, if possible.
  1256. libtcmalloc.pc: Makefile packages/rpm/rpm.spec
  1257. echo 'prefix=$(prefix)' > "$@".tmp
  1258. echo 'exec_prefix='`echo '$(exec_prefix)' | sed 's@^$(prefix)@$${prefix}@'` >> "$@".tmp
  1259. echo 'libdir='`echo '$(libdir)' | sed 's@^$(exec_prefix)@$${exec_prefix}@'` >> "$@".tmp
  1260. echo 'includedir='`echo '$(includedir)' | sed 's@^$(prefix)@$${prefix}@'` >> "$@".tmp
  1261. echo '' >> "$@".tmp
  1262. echo 'Name: $(PACKAGE)' >> "$@".tmp
  1263. echo 'Version: $(VERSION)' >> "$@".tmp
  1264. -grep '^Summary:' $(top_srcdir)/packages/rpm/rpm.spec | sed s/^Summary:/Description:/ | head -n1 >> "$@".tmp
  1265. -grep '^URL: ' $(top_srcdir)/packages/rpm/rpm.spec >> "$@".tmp
  1266. echo 'Requires:' >> "$@".tmp
  1267. echo 'Libs: -L$${libdir} -ltcmalloc' >> "$@".tmp
  1268. echo 'Libs.private: $(PTHREAD_CFLAGS) $(PTHREAD_LIBS)' >> "$@".tmp
  1269. echo 'Cflags: -I$${includedir}' >> "$@".tmp
  1270. mv -f "$@".tmp "$@"
  1271. # The other versions are mostly the same.
  1272. libtcmalloc_minimal.pc: libtcmalloc.pc
  1273. cat libtcmalloc.pc | sed s/-ltcmalloc/-ltcmalloc_minimal/ > "$@"
  1274. libtcmalloc_debug.pc: libtcmalloc.pc
  1275. cat libtcmalloc.pc | sed s/-ltcmalloc/-ltcmalloc_debug/ > "$@"
  1276. libtcmalloc_minimal_debug.pc: libtcmalloc.pc
  1277. cat libtcmalloc.pc | sed s/-ltcmalloc/-ltcmalloc_minimal_debug/ > "$@"
  1278. libprofiler.pc: libtcmalloc.pc
  1279. cat libtcmalloc.pc | sed s/-ltcmalloc/-lprofiler/ > "$@"
  1280. libtool: $(LIBTOOL_DEPS)
  1281. $(SHELL) ./config.status --recheck
  1282. @GENERATE_CHANGELOG_RULES@
  1283. # Windows wants write permission to .vcxproj files and maybe even sln files.
  1284. dist-hook: dist-ChangeLog
  1285. test -e "$(distdir)/vsprojects" \
  1286. && chmod -R u+w $(distdir)/*.sln $(distdir)/vsprojects/
  1287. EXTRA_DIST = packages/rpm.sh packages/rpm/rpm.spec packages/deb.sh packages/deb \
  1288. $(SCRIPTS) libtool \
  1289. src/windows/get_mangled_names.cc src/windows/override_functions.cc \
  1290. src/windows/config.h src/windows/gperftools/tcmalloc.h \
  1291. docs/pprof.see_also src/windows/TODO \
  1292. $(WINDOWS_PROJECTS) \
  1293. src/solaris/libstdc++.la