Makefile.am 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505
  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.vcproj
  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.vcproj
  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 = src/pprof
  344. ### Unittests
  345. check_SCRIPTS = pprof_unittest
  346. pprof_unittest: $(top_srcdir)/src/pprof
  347. $(top_srcdir)/src/pprof -test
  348. # Let unittests find pprof if they need to run it
  349. TESTS_ENVIRONMENT += PPROF_PATH=$(top_srcdir)/src/pprof
  350. ### Documentation
  351. dist_man_MANS = docs/pprof.1
  352. dist_doc_DATA += docs/pprof_remote_servers.html
  353. # On MSVC, we need our own versions of addr2line and nm to work with pprof.
  354. WINDOWS_PROJECTS += vsprojects/nm-pdb/nm-pdb.vcproj
  355. WINDOWS_PROJECTS += vsprojects/addr2line-pdb/addr2line-pdb.vcproj
  356. # This is a slight abuse of WINDOWS_PROJECTS, but not much
  357. WINDOWS_PROJECTS += src/windows/nm-pdb.c \
  358. src/windows/addr2line-pdb.c
  359. endif WITH_STACK_TRACE
  360. ### ------- tcmalloc_minimal (thread-caching malloc)
  361. ### The header files we use. We divide into categories based on directory
  362. S_TCMALLOC_MINIMAL_INCLUDES = src/common.h \
  363. src/internal_logging.h \
  364. src/system-alloc.h \
  365. src/packed-cache-inl.h \
  366. $(SPINLOCK_INCLUDES) \
  367. src/tcmalloc_guard.h \
  368. src/base/commandlineflags.h \
  369. src/base/basictypes.h \
  370. src/pagemap.h \
  371. src/sampler.h \
  372. src/central_freelist.h \
  373. src/linked_list.h \
  374. src/libc_override.h \
  375. src/libc_override_gcc_and_weak.h \
  376. src/libc_override_glibc.h \
  377. src/libc_override_osx.h \
  378. src/libc_override_redefine.h \
  379. src/page_heap.h \
  380. src/page_heap_allocator.h \
  381. src/span.h \
  382. src/static_vars.h \
  383. src/symbolize.h \
  384. src/thread_cache.h \
  385. src/stack_trace_table.h \
  386. src/base/thread_annotations.h \
  387. src/malloc_hook-inl.h \
  388. src/malloc_hook_mmap_linux.h \
  389. src/malloc_hook_mmap_freebsd.h
  390. SG_TCMALLOC_MINIMAL_INCLUDES = src/gperftools/malloc_hook.h \
  391. src/gperftools/malloc_hook_c.h \
  392. src/gperftools/malloc_extension.h \
  393. src/gperftools/malloc_extension_c.h \
  394. src/gperftools/nallocx.h
  395. TCMALLOC_MINIMAL_INCLUDES = $(S_TCMALLOC_MINIMAL_INCLUDES) $(SG_TCMALLOC_MINIMAL_INCLUDES) $(SG_STACKTRACE_INCLUDES)
  396. perftoolsinclude_HEADERS += $(SG_TCMALLOC_MINIMAL_INCLUDES)
  397. ### Making the library
  398. noinst_LTLIBRARIES += libtcmalloc_minimal_internal.la
  399. libtcmalloc_minimal_internal_la_SOURCES = src/common.cc \
  400. src/internal_logging.cc \
  401. $(SYSTEM_ALLOC_CC) \
  402. src/memfs_malloc.cc \
  403. src/central_freelist.cc \
  404. src/page_heap.cc \
  405. src/sampler.cc \
  406. src/span.cc \
  407. src/stack_trace_table.cc \
  408. src/static_vars.cc \
  409. src/symbolize.cc \
  410. src/thread_cache.cc \
  411. src/malloc_hook.cc \
  412. src/malloc_extension.cc \
  413. $(TCMALLOC_MINIMAL_INCLUDES)
  414. # We #define NO_TCMALLOC_SAMPLES, since sampling is turned off for _minimal.
  415. libtcmalloc_minimal_internal_la_CXXFLAGS = -DNO_TCMALLOC_SAMPLES \
  416. -DNO_HEAP_CHECK \
  417. -DNDEBUG \
  418. $(AM_CXXFLAGS)
  419. libtcmalloc_minimal_internal_la_LDFLAGS = $(AM_LDFLAGS)
  420. libtcmalloc_minimal_internal_la_LIBADD = $(LIBSPINLOCK) libmaybe_threads.la
  421. lib_LTLIBRARIES += libtcmalloc_minimal.la
  422. WINDOWS_PROJECTS += vsprojects/libtcmalloc_minimal/libtcmalloc_minimal.vcproj
  423. libtcmalloc_minimal_la_SOURCES = $(TCMALLOC_CC) $(TCMALLOC_MINIMAL_INCLUDES)
  424. libtcmalloc_minimal_la_CXXFLAGS = -DNO_TCMALLOC_SAMPLES \
  425. $(PTHREAD_CFLAGS) -DNDEBUG $(AM_CXXFLAGS)
  426. # -version-info gets passed to libtool
  427. libtcmalloc_minimal_la_LDFLAGS = -version-info @TCMALLOC_SO_VERSION@ $(AM_LDFLAGS)
  428. libtcmalloc_minimal_la_LIBADD = libtcmalloc_minimal_internal.la
  429. # For windows, we're playing around with trying to do some stacktrace
  430. # support even with libtcmalloc_minimal. For everyone else, though,
  431. # we turn off all stack-trace activity for libtcmalloc_minimal.
  432. # TODO(csilvers): when we're done experimenting, do something principled here
  433. if MINGW
  434. LIBTCMALLOC_MINIMAL = libtcmalloc_minimal.la libstacktrace.la
  435. else !MINGW
  436. LIBTCMALLOC_MINIMAL = libtcmalloc_minimal.la
  437. endif !MINGW
  438. LIBS_TO_WEAKEN += libtcmalloc_minimal.la
  439. ### Unittests
  440. # Commented out for the moment because malloc(very_big_num) is broken in
  441. # standard libc! At least, in some situations, some of the time.
  442. ## TESTS += malloc_unittest
  443. ## MALLOC_UNITEST_INCLUDES = src/gperftools/malloc_extension.h \
  444. ## src/gperftools/malloc_hook.h \
  445. ## src/gperftools/malloc_hook_c.h \
  446. ## src/malloc_hook-inl.h \
  447. ## src/malloc_hook_mmap_linux.h \
  448. ## src/malloc_hook_mmap_freebsd.h \
  449. ## src/base/basictypes.h \
  450. ## src/maybe_threads.h
  451. ## malloc_unittest_SOURCES = src/tests/tcmalloc_unittest.cc \
  452. ## src/malloc_hook.cc \
  453. ## src/malloc_extension.cc \
  454. ## $(MAYBE_THREADS_CC) \
  455. ## $(MALLOC_UNITTEST_INCLUDES)
  456. ## malloc_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  457. ## malloc_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
  458. ## malloc_unittest_LDADD = $(PTHREAD_LIBS)
  459. TESTS += tcmalloc_minimal_unittest
  460. WINDOWS_PROJECTS += vsprojects/tcmalloc_minimal_unittest/tcmalloc_minimal_unittest.vcproj
  461. WINDOWS_PROJECTS += vsprojects/tmu-static/tmu-static.vcproj
  462. tcmalloc_minimal_unittest_SOURCES = src/tests/tcmalloc_unittest.cc \
  463. src/tests/testutil.h src/tests/testutil.cc \
  464. $(TCMALLOC_UNITTEST_INCLUDES)
  465. tcmalloc_minimal_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  466. tcmalloc_minimal_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  467. # We want libtcmalloc last on the link line, but due to a bug in
  468. # libtool involving convenience libs, they need to come last on the
  469. # link line in order to get dependency ordering right. This is ok:
  470. # convenience libraries are .a's, so tcmalloc is still the last .so.
  471. # We also put pthreads after tcmalloc, because some pthread
  472. # implementations define their own malloc, and we need to go on the
  473. # first linkline to make sure our malloc 'wins'.
  474. tcmalloc_minimal_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) \
  475. liblogging.la $(PTHREAD_LIBS)
  476. # lets make sure we exerice ASSERTs in at least in statically linked
  477. # configuration
  478. TESTS += tcm_min_asserts_unittest
  479. tcm_min_asserts_unittest_SOURCES = src/tests/tcmalloc_unittest.cc \
  480. src/tests/testutil.h src/tests/testutil.cc \
  481. $(libtcmalloc_minimal_internal_la_SOURCES) \
  482. $(libtcmalloc_minimal_la_SOURCES) \
  483. $(TCMALLOC_UNITTEST_INCLUDES)
  484. tcm_min_asserts_unittest_CXXFLAGS = -DNO_TCMALLOC_SAMPLES -DNO_HEAP_CHECK \
  485. $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  486. tcm_min_asserts_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  487. tcm_min_asserts_unittest_LDADD = $(LIBSPINLOCK) libmaybe_threads.la \
  488. liblogging.la $(PTHREAD_LIBS)
  489. TESTS += tcmalloc_minimal_large_unittest
  490. WINDOWS_PROJECTS += vsprojects/tcmalloc_minimal_large/tcmalloc_minimal_large_unittest.vcproj
  491. tcmalloc_minimal_large_unittest_SOURCES = src/tests/tcmalloc_large_unittest.cc
  492. tcmalloc_minimal_large_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  493. tcmalloc_minimal_large_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  494. tcmalloc_minimal_large_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  495. TESTS += tcmalloc_minimal_large_heap_fragmentation_unittest
  496. tcmalloc_minimal_large_heap_fragmentation_unittest_SOURCES = src/tests/large_heap_fragmentation_unittest.cc
  497. tcmalloc_minimal_large_heap_fragmentation_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  498. tcmalloc_minimal_large_heap_fragmentation_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  499. tcmalloc_minimal_large_heap_fragmentation_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  500. # This tests it works to LD_PRELOAD libtcmalloc (tests maybe_threads.cc)
  501. # In theory this should work under mingw, but mingw has trouble running
  502. # shell scripts that end in .exe. And it doesn't seem to build shared
  503. # libraries anyway (so can't be LD_PRELOADed) -- in fact, anybody who
  504. # chooses not to build shared libraries won't be able to run this test.
  505. # TODO(csilvers): figure out how to nix ".exe" or otherwise work under mingw
  506. if !MINGW
  507. if !ENABLE_STATIC
  508. TESTS += maybe_threads_unittest.sh$(EXEEXT)
  509. maybe_threads_unittest_sh_SOURCES = src/tests/maybe_threads_unittest.sh
  510. noinst_SCRIPTS += $(maybe_threads_unittest_sh_SOURCES)
  511. # This script preloads libtcmalloc, and calls two other binaries as well
  512. # TODO(csilvers): replace by 'if ! cmp $^ $@ >/dev/null 2>&; then ...; fi'
  513. maybe_threads_unittest.sh$(EXEEXT): $(top_srcdir)/$(maybe_threads_unittest_sh_SOURCES) \
  514. $(LIBTCMALLOC_MINIMAL) \
  515. low_level_alloc_unittest
  516. rm -f $@
  517. cp -p $(top_srcdir)/$(maybe_threads_unittest_sh_SOURCES) $@
  518. endif !ENABLE_STATIC
  519. endif !MINGW
  520. # These all tests components of tcmalloc_minimal
  521. TESTS += addressmap_unittest
  522. WINDOWS_PROJECTS += vsprojects/addressmap_unittest/addressmap_unittest.vcproj
  523. ADDRESSMAP_UNITTEST_INCLUDES = src/addressmap-inl.h \
  524. src/base/commandlineflags.h \
  525. $(LOGGING_INCLUDES)
  526. addressmap_unittest_SOURCES = src/tests/addressmap_unittest.cc \
  527. $(ADDRESSMAP_UNITTEST_INCLUDES)
  528. if MINGW
  529. addressmap_unittest_SOURCES += src/windows/port.h src/windows/port.cc
  530. endif MINGW
  531. addressmap_unittest_CXXFLAGS = -g $(AM_CXXFLAGS)
  532. addressmap_unittest_LDADD = liblogging.la
  533. WINDOWS_PROJECTS += vsprojects/system-alloc_unittest/system-alloc_unittest.vcproj
  534. if !MINGW
  535. TESTS += system_alloc_unittest
  536. system_alloc_unittest_SOURCES = src/config_for_unittests.h \
  537. src/tests/system-alloc_unittest.cc
  538. system_alloc_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  539. system_alloc_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  540. system_alloc_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  541. endif !MINGW
  542. TESTS += packed_cache_test
  543. WINDOWS_PROJECTS += vsprojects/packed-cache_test/packed-cache_test.vcproj
  544. packed_cache_test_SOURCES = src/tests/packed-cache_test.cc
  545. packed_cache_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  546. packed_cache_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  547. packed_cache_test_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  548. TESTS += frag_unittest
  549. WINDOWS_PROJECTS += vsprojects/frag_unittest/frag_unittest.vcproj
  550. frag_unittest_SOURCES = src/tests/frag_unittest.cc src/config_for_unittests.h
  551. frag_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  552. frag_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  553. frag_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  554. TESTS += markidle_unittest
  555. WINDOWS_PROJECTS += vsprojects/markidle_unittest/markidle_unittest.vcproj
  556. markidle_unittest_SOURCES = src/tests/markidle_unittest.cc \
  557. src/config_for_unittests.h \
  558. src/tests/testutil.h src/tests/testutil.cc
  559. markidle_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  560. markidle_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  561. markidle_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  562. TESTS += current_allocated_bytes_test
  563. WINDOWS_PROJECTS += vsprojects/current_allocated_bytes_test/current_allocated_bytes_test.vcproj
  564. current_allocated_bytes_test_SOURCES = src/tests/current_allocated_bytes_test.cc \
  565. src/config_for_unittests.h
  566. current_allocated_bytes_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  567. current_allocated_bytes_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  568. current_allocated_bytes_test_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  569. TESTS += malloc_hook_test
  570. WINDOWS_PROJECTS += vsprojects/malloc_hook_test/malloc_hook_test.vcproj
  571. malloc_hook_test_SOURCES = src/tests/malloc_hook_test.cc \
  572. src/config_for_unittests.h \
  573. src/base/logging.h \
  574. src/gperftools/malloc_hook.h \
  575. src/tests/testutil.h src/tests/testutil.cc
  576. malloc_hook_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  577. malloc_hook_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  578. malloc_hook_test_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  579. TESTS += malloc_extension_test
  580. WINDOWS_PROJECTS += vsprojects/malloc_extension_test/malloc_extension_test.vcproj
  581. malloc_extension_test_SOURCES = src/tests/malloc_extension_test.cc \
  582. src/config_for_unittests.h \
  583. src/base/logging.h \
  584. src/gperftools/malloc_extension.h \
  585. src/gperftools/malloc_extension_c.h
  586. malloc_extension_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  587. malloc_extension_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  588. malloc_extension_test_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  589. # This doesn't work with mingw, which links foo.a even though it
  590. # doesn't set ENABLE_STATIC. TODO(csilvers): set enable_static=true
  591. # in configure.ac:36?
  592. if !MINGW
  593. TESTS += malloc_extension_c_test
  594. malloc_extension_c_test_SOURCES = src/tests/malloc_extension_c_test.c \
  595. src/gperftools/malloc_extension.h \
  596. src/gperftools/malloc_extension_c.h
  597. malloc_extension_c_test_CFLAGS = $(PTHREAD_CFLAGS) $(AM_CFLAGS)
  598. # -ansi here is just to help ensure the code is bog-standard C.
  599. if GCC
  600. malloc_extension_c_test_CFLAGS += -ansi
  601. endif GCC
  602. malloc_extension_c_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  603. malloc_extension_c_test_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS) -lstdc++ -lm
  604. endif !MINGW
  605. if !MINGW
  606. if !OSX
  607. TESTS += memalign_unittest
  608. memalign_unittest_SOURCES = src/tests/memalign_unittest.cc \
  609. src/tcmalloc.h \
  610. src/config_for_unittests.h \
  611. src/tests/testutil.h src/tests/testutil.cc
  612. memalign_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  613. memalign_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  614. memalign_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  615. endif !OSX
  616. endif !MINGW
  617. TESTS += page_heap_test
  618. WINDOWS_PROJECTS += vsprojects/page_heap_test/page_heap_test.vcproj
  619. page_heap_test_SOURCES = src/tests/page_heap_test.cc \
  620. src/config_for_unittests.h \
  621. src/base/logging.h \
  622. src/common.h \
  623. src/page_heap.h
  624. page_heap_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  625. page_heap_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  626. page_heap_test_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  627. TESTS += pagemap_unittest
  628. WINDOWS_PROJECTS += vsprojects/pagemap_unittest/pagemap_unittest.vcproj
  629. pagemap_unittest_SOURCES = src/tests/pagemap_unittest.cc \
  630. src/config_for_unittests.h \
  631. src/base/logging.h \
  632. src/pagemap.h
  633. pagemap_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  634. pagemap_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  635. pagemap_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  636. TESTS += realloc_unittest
  637. WINDOWS_PROJECTS += vsprojects/realloc_unittest/realloc_unittest.vcproj
  638. realloc_unittest_SOURCES = src/tests/realloc_unittest.cc \
  639. src/config_for_unittests.h \
  640. src/base/logging.h
  641. realloc_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  642. realloc_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  643. realloc_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  644. TESTS += stack_trace_table_test
  645. WINDOWS_PROJECTS += vsprojects/stack_trace_table_test/stack_trace_table_test.vcproj
  646. stack_trace_table_test_SOURCES = src/tests/stack_trace_table_test.cc \
  647. src/config_for_unittests.h
  648. stack_trace_table_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  649. stack_trace_table_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  650. stack_trace_table_test_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  651. TESTS += thread_dealloc_unittest
  652. WINDOWS_PROJECTS += vsprojects/thread_dealloc_unittest/thread_dealloc_unittest.vcproj
  653. thread_dealloc_unittest_SOURCES = src/tests/thread_dealloc_unittest.cc \
  654. src/config_for_unittests.h \
  655. src/tests/testutil.h src/tests/testutil.cc
  656. thread_dealloc_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  657. thread_dealloc_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  658. thread_dealloc_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  659. ### Documentation
  660. dist_doc_DATA += docs/tcmalloc.html \
  661. docs/overview.gif \
  662. docs/pageheap.gif \
  663. docs/spanmap.gif \
  664. docs/threadheap.gif \
  665. docs/t-test1.times.txt \
  666. docs/tcmalloc-opspercpusec.vs.threads.1024.bytes.png \
  667. docs/tcmalloc-opspercpusec.vs.threads.128.bytes.png \
  668. docs/tcmalloc-opspercpusec.vs.threads.131072.bytes.png \
  669. docs/tcmalloc-opspercpusec.vs.threads.16384.bytes.png \
  670. docs/tcmalloc-opspercpusec.vs.threads.2048.bytes.png \
  671. docs/tcmalloc-opspercpusec.vs.threads.256.bytes.png \
  672. docs/tcmalloc-opspercpusec.vs.threads.32768.bytes.png \
  673. docs/tcmalloc-opspercpusec.vs.threads.4096.bytes.png \
  674. docs/tcmalloc-opspercpusec.vs.threads.512.bytes.png \
  675. docs/tcmalloc-opspercpusec.vs.threads.64.bytes.png \
  676. docs/tcmalloc-opspercpusec.vs.threads.65536.bytes.png \
  677. docs/tcmalloc-opspercpusec.vs.threads.8192.bytes.png \
  678. docs/tcmalloc-opspersec.vs.size.1.threads.png \
  679. docs/tcmalloc-opspersec.vs.size.12.threads.png \
  680. docs/tcmalloc-opspersec.vs.size.16.threads.png \
  681. docs/tcmalloc-opspersec.vs.size.2.threads.png \
  682. docs/tcmalloc-opspersec.vs.size.20.threads.png \
  683. docs/tcmalloc-opspersec.vs.size.3.threads.png \
  684. docs/tcmalloc-opspersec.vs.size.4.threads.png \
  685. docs/tcmalloc-opspersec.vs.size.5.threads.png \
  686. docs/tcmalloc-opspersec.vs.size.8.threads.png
  687. # I don't know how to say "distribute the .dot files but don't install them";
  688. # noinst doesn't seem to work with data. I separate them out anyway, in case
  689. # one day we figure it out. Regardless, installing the dot files isn't the
  690. # end of the world.
  691. dist_doc_DATA += docs/overview.dot \
  692. docs/pageheap.dot \
  693. docs/spanmap.dot \
  694. docs/threadheap.dot
  695. ### ------- tcmalloc_minimal_debug (thread-caching malloc with debugallocation)
  696. if WITH_DEBUGALLOC
  697. lib_LTLIBRARIES += libtcmalloc_minimal_debug.la
  698. libtcmalloc_minimal_debug_la_SOURCES = src/debugallocation.cc \
  699. $(TCMALLOC_MINIMAL_INCLUDES)
  700. libtcmalloc_minimal_debug_la_CXXFLAGS = $(libtcmalloc_minimal_la_CXXFLAGS) \
  701. -DTCMALLOC_FOR_DEBUGALLOCATION
  702. # version_info gets passed to libtool
  703. libtcmalloc_minimal_debug_la_LDFLAGS = $(libtcmalloc_minimal_la_LDFLAGS) \
  704. -version-info @TCMALLOC_SO_VERSION@
  705. libtcmalloc_minimal_debug_la_LIBADD = $(libtcmalloc_minimal_la_LIBADD)
  706. LIBS_TO_WEAKEN += libtcmalloc_minimal_debug.la
  707. ### Unittests
  708. TESTS += tcmalloc_minimal_debug_unittest
  709. tcmalloc_minimal_debug_unittest_SOURCES = $(tcmalloc_minimal_unittest_SOURCES)
  710. tcmalloc_minimal_debug_unittest_CXXFLAGS = $(tcmalloc_minimal_unittest_CXXFLAGS) \
  711. -DDEBUGALLOCATION
  712. tcmalloc_minimal_debug_unittest_LDFLAGS = $(tcmalloc_minimal_unittest_LDFLAGS)
  713. tcmalloc_minimal_debug_unittest_LDADD = libtcmalloc_minimal_debug.la $(PTHREAD_LIBS)
  714. TESTS += malloc_extension_debug_test
  715. malloc_extension_debug_test_SOURCES = $(malloc_extension_test_SOURCES)
  716. malloc_extension_debug_test_CXXFLAGS = $(malloc_extension_test_CXXFLAGS)
  717. malloc_extension_debug_test_LDFLAGS = $(malloc_extension_test_LDFLAGS)
  718. malloc_extension_debug_test_LDADD = libtcmalloc_minimal_debug.la $(PTHREAD_LIBS)
  719. if !MINGW
  720. if !OSX
  721. TESTS += memalign_debug_unittest
  722. memalign_debug_unittest_SOURCES = $(memalign_unittest_SOURCES)
  723. memalign_debug_unittest_CXXFLAGS = $(memalign_unittest_CXXFLAGS)
  724. memalign_debug_unittest_LDFLAGS = $(memalign_unittest_LDFLAGS)
  725. memalign_debug_unittest_LDADD = libtcmalloc_minimal_debug.la $(PTHREAD_LIBS)
  726. endif !OSX
  727. endif !MINGW
  728. TESTS += realloc_debug_unittest
  729. realloc_debug_unittest_SOURCES = $(realloc_unittest_SOURCES)
  730. realloc_debug_unittest_CXXFLAGS = $(realloc_unittest_CXXFLAGS)
  731. realloc_debug_unittest_LDFLAGS = $(realloc_unittest_LDFLAGS)
  732. realloc_debug_unittest_LDADD = libtcmalloc_minimal_debug.la $(PTHREAD_LIBS)
  733. # debugallocation_test checks that we print a proper stacktrace when
  734. # debug-allocs fail, so we can't run it if we don't have stacktrace info.
  735. if WITH_STACK_TRACE
  736. TESTS += debugallocation_test.sh$(EXEEXT)
  737. debugallocation_test_sh_SOURCES = src/tests/debugallocation_test.sh
  738. noinst_SCRIPTS += $(debugallocation_test_sh_SOURCES)
  739. debugallocation_test.sh$(EXEEXT): $(top_srcdir)/$(debugallocation_test_sh_SOURCES) \
  740. debugallocation_test
  741. rm -f $@
  742. cp -p $(top_srcdir)/$(debugallocation_test_sh_SOURCES) $@
  743. # This is the sub-program used by debugallocation_test.sh
  744. noinst_PROGRAMS += debugallocation_test
  745. debugallocation_test_SOURCES = src/tests/debugallocation_test.cc
  746. debugallocation_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  747. debugallocation_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  748. debugallocation_test_LDADD = libtcmalloc_debug.la $(PTHREAD_LIBS)
  749. endif WITH_STACK_TRACE
  750. endif WITH_DEBUGALLOC
  751. if !MINGW
  752. noinst_LTLIBRARIES += librun_benchmark.la
  753. librun_benchmark_la_SOURCES = \
  754. benchmark/run_benchmark.c benchmark/run_benchmark.h
  755. noinst_PROGRAMS += malloc_bench malloc_bench_shared \
  756. binary_trees binary_trees_shared
  757. malloc_bench_SOURCES = benchmark/malloc_bench.cc
  758. malloc_bench_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  759. malloc_bench_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  760. if ENABLE_STATIC
  761. malloc_bench_LDFLAGS += -static
  762. endif ENABLE_STATIC
  763. malloc_bench_LDADD = librun_benchmark.la libtcmalloc_minimal.la $(PTHREAD_LIBS)
  764. malloc_bench_shared_SOURCES = benchmark/malloc_bench.cc
  765. malloc_bench_shared_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  766. malloc_bench_shared_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  767. malloc_bench_shared_LDADD = librun_benchmark.la libtcmalloc_minimal.la $(PTHREAD_LIBS)
  768. if WITH_HEAP_PROFILER_OR_CHECKER
  769. noinst_PROGRAMS += malloc_bench_shared_full
  770. malloc_bench_shared_full_SOURCES = benchmark/malloc_bench.cc
  771. malloc_bench_shared_full_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  772. malloc_bench_shared_full_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  773. malloc_bench_shared_full_LDADD = librun_benchmark.la libtcmalloc.la $(PTHREAD_LIBS)
  774. if !OSX
  775. noinst_PROGRAMS += unwind_bench
  776. unwind_bench_SOURCES = benchmark/unwind_bench.cc benchmark/getcontext_light.cc
  777. unwind_bench_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  778. unwind_bench_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  779. unwind_bench_LDADD = librun_benchmark.la libtcmalloc.la $(PTHREAD_LIBS)
  780. endif !OSX
  781. endif WITH_HEAP_PROFILER_OR_CHECKER
  782. binary_trees_SOURCES = benchmark/binary_trees.cc
  783. binary_trees_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  784. binary_trees_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  785. if ENABLE_STATIC
  786. binary_trees_LDFLAGS += -static
  787. endif ENABLE_STATIC
  788. binary_trees_LDADD = libtcmalloc_minimal.la $(PTHREAD_LIBS)
  789. binary_trees_shared_SOURCES = benchmark/binary_trees.cc
  790. binary_trees_shared_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  791. binary_trees_shared_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  792. binary_trees_shared_LDADD = libtcmalloc_minimal.la $(PTHREAD_LIBS)
  793. endif !MINGW
  794. ### ------- tcmalloc (thread-caching malloc + heap profiler + heap checker)
  795. if WITH_HEAP_PROFILER_OR_CHECKER
  796. ### The header files we use. We divide into categories based on directory
  797. S_TCMALLOC_INCLUDES = $(S_TCMALLOC_MINIMAL_INCLUDES) \
  798. $(LOGGING_INCLUDES) \
  799. src/addressmap-inl.h \
  800. src/raw_printer.h \
  801. src/base/elfcore.h \
  802. src/base/googleinit.h \
  803. src/base/linux_syscall_support.h \
  804. src/base/linuxthreads.h \
  805. src/base/stl_allocator.h \
  806. src/base/sysinfo.h \
  807. src/base/thread_lister.h \
  808. src/heap-profile-table.h \
  809. src/heap-profile-stats.h \
  810. src/maybe_emergency_malloc.h \
  811. src/emergency_malloc.h
  812. SG_TCMALLOC_INCLUDES = src/gperftools/heap-profiler.h \
  813. src/gperftools/heap-checker.h
  814. TCMALLOC_INCLUDES = $(S_TCMALLOC_INCLUDES) $(SG_TCMALLOC_MINIMAL_INCLUDES) \
  815. $(SG_TCMALLOC_INCLUDES) $(SG_STACKTRACE_INCLUDES)
  816. perftoolsinclude_HEADERS += $(SG_TCMALLOC_INCLUDES)
  817. if BUILD_EMERGENCY_MALLOC
  818. EMERGENCY_MALLOC_CC = src/emergency_malloc.cc src/emergency_malloc_for_stacktrace.cc
  819. EMERGENCY_MALLOC_DEFINE = -DENABLE_EMERGENCY_MALLOC
  820. else !BUILD_EMERGENCY_MALLOC
  821. EMERGENCY_MALLOC_CC = src/fake_stacktrace_scope.cc
  822. EMERGENCY_MALLOC_DEFINE =
  823. endif !BUILD_EMERGENCY_MALLOC
  824. ### Making the library
  825. noinst_LTLIBRARIES += libtcmalloc_internal.la
  826. libtcmalloc_internal_la_SOURCES = $(libtcmalloc_minimal_internal_la_SOURCES) \
  827. $(TCMALLOC_INCLUDES) \
  828. src/base/low_level_alloc.cc \
  829. src/heap-profile-table.cc \
  830. src/heap-profiler.cc \
  831. src/raw_printer.cc \
  832. $(EMERGENCY_MALLOC_CC) \
  833. src/memory_region_map.cc
  834. libtcmalloc_internal_la_CXXFLAGS = $(PTHREAD_CFLAGS) -DNDEBUG \
  835. $(AM_CXXFLAGS) $(EMERGENCY_MALLOC_DEFINE)
  836. libtcmalloc_internal_la_LDFLAGS = $(PTHREAD_CFLAGS)
  837. libtcmalloc_internal_la_LIBADD = libstacktrace.la $(PTHREAD_LIBS)
  838. lib_LTLIBRARIES += libtcmalloc.la
  839. libtcmalloc_la_SOURCES = $(TCMALLOC_CC) $(TCMALLOC_INCLUDES)
  840. libtcmalloc_la_CXXFLAGS = $(PTHREAD_CFLAGS) -DNDEBUG $(AM_CXXFLAGS) $(EMERGENCY_MALLOC_DEFINE)
  841. libtcmalloc_la_LDFLAGS = $(PTHREAD_CFLAGS) -version-info @TCMALLOC_SO_VERSION@
  842. libtcmalloc_la_LIBADD = libtcmalloc_internal.la libmaybe_threads.la $(PTHREAD_LIBS)
  843. if WITH_HEAP_CHECKER
  844. # heap-checker-bcad is last, in hopes its global ctor will run first.
  845. # (Note this is added to libtcmalloc.la, not libtcmalloc_internal.la,
  846. # but that's ok; the internal/external distinction is only useful for
  847. # cygwin, and cygwin doesn't use HEAP_CHECKER anyway.)
  848. HEAP_CHECKER_SOURCES = src/base/thread_lister.c \
  849. src/base/linuxthreads.cc \
  850. src/heap-checker.cc \
  851. src/heap-checker-bcad.cc
  852. libtcmalloc_la_SOURCES += $(HEAP_CHECKER_SOURCES)
  853. else !WITH_HEAP_CHECKER
  854. HEAP_CHECKER_SOURCES =
  855. libtcmalloc_internal_la_CXXFLAGS += -DNO_HEAP_CHECK
  856. libtcmalloc_la_CXXFLAGS += -DNO_HEAP_CHECK
  857. endif !WITH_HEAP_CHECKER
  858. LIBTCMALLOC = libtcmalloc.la
  859. LIBS_TO_WEAKEN += libtcmalloc.la
  860. ### Unittests
  861. TESTS += tcmalloc_unittest.sh$(EXEEXT)
  862. tcmalloc_unittest_sh_SOURCES = src/tests/tcmalloc_unittest.sh
  863. noinst_SCRIPTS += $(tcmalloc_unittest_sh_SOURCES)
  864. tcmalloc_unittest.sh$(EXEEXT): $(top_srcdir)/$(tcmalloc_unittest_sh_SOURCES) \
  865. tcmalloc_unittest
  866. rm -f $@
  867. cp -p $(top_srcdir)/$(tcmalloc_unittest_sh_SOURCES) $@
  868. noinst_PROGRAMS += tcmalloc_unittest
  869. tcmalloc_unittest_INCLUDES = src/config_for_unittests.h \
  870. src/gperftools/malloc_extension.h
  871. tcmalloc_unittest_SOURCES = src/tests/tcmalloc_unittest.cc \
  872. src/tcmalloc.h \
  873. src/tests/testutil.h src/tests/testutil.cc \
  874. $(TCMALLOC_UNITTEST_INCLUDES)
  875. tcmalloc_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  876. tcmalloc_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  877. # We want libtcmalloc last on the link line, but due to a bug in
  878. # libtool involving convenience libs, they need to come last on the
  879. # link line in order to get dependency ordering right. This is ok:
  880. # convenience libraries are .a's, so tcmalloc is still the last .so.
  881. # We also put pthreads after tcmalloc, because some pthread
  882. # implementations define their own malloc, and we need to go on the
  883. # first linkline to make sure our malloc 'wins'.
  884. tcmalloc_unittest_LDADD = $(LIBTCMALLOC) liblogging.la $(PTHREAD_LIBS)
  885. # # lets make sure we exerice ASSERTs in at least in statically linked
  886. # # configuration
  887. # TESTS += tcm_asserts_unittest
  888. # tcm_asserts_unittest_SOURCES = src/tests/tcmalloc_unittest.cc \
  889. # src/tests/testutil.h src/tests/testutil.cc \
  890. # $(libtcmalloc_internal_la_SOURCES) \
  891. # $(libtcmalloc_la_SOURCES) \
  892. # $(TCMALLOC_UNITTEST_INCLUDES)
  893. # tcm_asserts_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  894. # tcm_asserts_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  895. # tcm_asserts_unittest_LDADD = $(LIBSPINLOCK) libmaybe_threads.la libstacktrace.la \
  896. # liblogging.la $(PTHREAD_LIBS)
  897. # This makes sure it's safe to link in both tcmalloc and
  898. # tcmalloc_minimal. (One would never do this on purpose, but perhaps
  899. # by accident...) When we can compile libprofiler, we also link it in
  900. # to make sure that works too. NOTE: On OS X, it's *not* safe to
  901. # link both in (we end up with two copies of every global var, and
  902. # the code tends to pick one arbitrarily), so don't run the test there.
  903. # (We define these outside the 'if' because they're reused below.)
  904. tcmalloc_both_unittest_srcs = src/tests/tcmalloc_unittest.cc \
  905. src/tests/testutil.h src/tests/testutil.cc \
  906. $(TCMALLOC_UNITTEST_INCLUDES)
  907. tcmalloc_both_unittest_cflags = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  908. tcmalloc_both_unittest_lflags = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  909. if WITH_CPU_PROFILER
  910. # We want libtcmalloc last on the link line, but due to a bug in
  911. # libtool involving convenience libs, they need to come last on the
  912. # link line in order to get dependency ordering right. This is ok:
  913. # convenience libraries are .a's, so tcmalloc is still the last .so.
  914. # We also put pthreads after tcmalloc, because some pthread
  915. # implementations define their own malloc, and we need to go on the
  916. # first linkline to make sure our malloc 'wins'.
  917. tcmalloc_both_unittest_ladd = $(LIBTCMALLOC) $(LIBTCMALLOC_MINIMAL) \
  918. libprofiler.la liblogging.la $(PTHREAD_LIBS)
  919. else
  920. tcmalloc_both_unittest_ladd = $(LIBTCMALLOC) $(LIBTCMALLOC_MINIMAL) \
  921. liblogging.la $(PTHREAD_LIBS)
  922. endif !WITH_CPU_PROFILER
  923. if !OSX
  924. TESTS += tcmalloc_both_unittest
  925. tcmalloc_both_unittest_SOURCES = $(tcmalloc_both_unittest_srcs)
  926. tcmalloc_both_unittest_CXXFLAGS = $(tcmalloc_both_unittest_cflags)
  927. tcmalloc_both_unittest_LDFLAGS = $(tcmalloc_both_unittest_lflags)
  928. tcmalloc_both_unittest_LDADD = $(tcmalloc_both_unittest_ladd)
  929. endif !OSX
  930. TESTS += tcmalloc_large_unittest
  931. tcmalloc_large_unittest_SOURCES = src/tests/tcmalloc_large_unittest.cc
  932. tcmalloc_large_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  933. tcmalloc_large_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  934. tcmalloc_large_unittest_LDADD = $(LIBTCMALLOC) $(PTHREAD_LIBS)
  935. TESTS += tcmalloc_large_heap_fragmentation_unittest
  936. tcmalloc_large_heap_fragmentation_unittest_SOURCES = src/tests/large_heap_fragmentation_unittest.cc
  937. tcmalloc_large_heap_fragmentation_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  938. tcmalloc_large_heap_fragmentation_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  939. tcmalloc_large_heap_fragmentation_unittest_LDADD = $(LIBTCMALLOC) $(PTHREAD_LIBS)
  940. TESTS += raw_printer_test
  941. raw_printer_test_SOURCES = src/tests/raw_printer_test.cc
  942. raw_printer_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  943. raw_printer_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  944. raw_printer_test_LDADD = $(LIBTCMALLOC) $(PTHREAD_LIBS)
  945. # sampler_test and sampling_test both require sampling to be turned
  946. # on, which it's not by default. Use the "standard" value of 2^19.
  947. TESTS_ENVIRONMENT += TCMALLOC_SAMPLE_PARAMETER=524288
  948. TESTS += sampler_test
  949. WINDOWS_PROJECTS += vsprojects/sampler_test/sampler_test.vcproj
  950. sampler_test_SOURCES = src/tests/sampler_test.cc \
  951. src/config_for_unittests.h
  952. sampler_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  953. sampler_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  954. sampler_test_LDADD = $(LIBTCMALLOC) $(PTHREAD_LIBS) -lm
  955. # These unittests often need to run binaries. They're in the current dir
  956. TESTS_ENVIRONMENT += BINDIR=.
  957. TESTS_ENVIRONMENT += TMPDIR=/tmp/perftools
  958. TESTS += sampling_test.sh$(EXEEXT)
  959. sampling_test_sh_SOURCES = src/tests/sampling_test.sh
  960. noinst_SCRIPTS += $(sampling_test_sh_SOURCES)
  961. sampling_test.sh$(EXEEXT): $(top_srcdir)/$(sampling_test_sh_SOURCES) \
  962. sampling_test
  963. rm -f $@
  964. cp -p $(top_srcdir)/$(sampling_test_sh_SOURCES) $@
  965. # This is the sub-program used by sampling_test.sh
  966. # The -g is so pprof can get symbol information.
  967. noinst_PROGRAMS += sampling_test
  968. SAMPLING_TEST_INCLUDES = src/config_for_unittests.h \
  969. src/base/logging.h \
  970. src/gperftools/malloc_extension.h
  971. sampling_test_SOURCES = src/tests/sampling_test.cc \
  972. $(SAMPLING_TEST_INCLUDES)
  973. sampling_test_CXXFLAGS = -g $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  974. sampling_test_LDFLAGS = -g $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  975. sampling_test_LDADD = $(LIBTCMALLOC) $(PTHREAD_LIBS)
  976. endif WITH_HEAP_PROFILER_OR_CHECKER
  977. if WITH_HEAP_PROFILER
  978. TESTS += heap-profiler_unittest.sh$(EXEEXT)
  979. heap_profiler_unittest_sh_SOURCES = src/tests/heap-profiler_unittest.sh
  980. noinst_SCRIPTS += $(heap_profiler_unittest_sh_SOURCES)
  981. heap-profiler_unittest.sh$(EXEEXT): $(top_srcdir)/$(heap_profiler_unittest_sh_SOURCES) \
  982. heap-profiler_unittest
  983. rm -f $@
  984. cp -p $(top_srcdir)/$(heap_profiler_unittest_sh_SOURCES) $@
  985. # These are sub-programs used by heap-profiler_unittest.sh
  986. noinst_PROGRAMS += heap-profiler_unittest
  987. HEAP_PROFILER_UNITTEST_INCLUDES = src/config_for_unittests.h \
  988. src/gperftools/heap-profiler.h
  989. heap_profiler_unittest_SOURCES = src/tests/heap-profiler_unittest.cc \
  990. $(HEAP_PROFILER_UNITTEST_INCLUDES)
  991. heap_profiler_unittest_CXXFLAGS = -g $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  992. heap_profiler_unittest_LDFLAGS = -g $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  993. heap_profiler_unittest_LDADD = $(LIBTCMALLOC) $(PTHREAD_LIBS)
  994. # Tests the compatibility include-headers in google/. Requires a function
  995. # defined in the heap-profiler, which is why the test lives here.
  996. TESTS += simple_compat_test
  997. simple_compat_test_SOURCES = src/tests/simple_compat_test.cc \
  998. $(googleinclude_HEADERS)
  999. simple_compat_test_LDFLAGS = $(TCMALLOC_FLAGS)
  1000. simple_compat_test_LDADD = $(LIBTCMALLOC)
  1001. endif WITH_HEAP_PROFILER
  1002. if WITH_HEAP_CHECKER
  1003. TESTS += heap-checker_unittest.sh$(EXEEXT)
  1004. heap_checker_unittest_sh_SOURCES = src/tests/heap-checker_unittest.sh
  1005. noinst_SCRIPTS += $(heap_checker_unittest_sh_SOURCES)
  1006. heap-checker_unittest.sh$(EXEEXT): $(top_srcdir)/$(heap_checker_unittest_sh_SOURCES) \
  1007. heap-checker_unittest
  1008. rm -f $@
  1009. cp -p $(top_srcdir)/$(heap_checker_unittest_sh_SOURCES) $@
  1010. TESTS += heap-checker-death_unittest.sh$(EXEEXT)
  1011. heap_checker_death_unittest_sh_SOURCES = src/tests/heap-checker-death_unittest.sh
  1012. noinst_SCRIPTS += $(top_srcdir)/$(heap_checker_death_unittest_sh_SOURCES)
  1013. heap-checker-death_unittest.sh$(EXEEXT): $(heap_checker_death_unittest_sh_SOURCES) \
  1014. heap-checker_unittest
  1015. rm -f $@
  1016. cp -p $(top_srcdir)/$(heap_checker_death_unittest_sh_SOURCES) $@
  1017. # These are sub-programs used by heap-checker_unittest.sh
  1018. noinst_PROGRAMS += heap-checker_unittest
  1019. HEAP_CHECKER_UNITTEST_INCLUDES = src/config_for_unittests.h \
  1020. src/memory_region_map.h \
  1021. src/base/commandlineflags.h \
  1022. src/base/googleinit.h \
  1023. src/gperftools/heap-checker.h \
  1024. $(LOGGING_INCLUDES)
  1025. heap_checker_unittest_SOURCES = src/tests/heap-checker_unittest.cc \
  1026. $(HEAP_CHECKER_UNITTEST_INCLUDES)
  1027. heap_checker_unittest_CXXFLAGS = -g $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  1028. heap_checker_unittest_LDFLAGS = -g $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  1029. # We want libtcmalloc last on the link line, but due to a bug in
  1030. # libtool involving convenience libs, they need to come last on the
  1031. # link line in order to get dependency ordering right. This is ok:
  1032. # convenience libraries are .a's, so tcmalloc is still the last .so.
  1033. # We also put pthreads after tcmalloc, because some pthread
  1034. # implementations define their own malloc, and we need to go on the
  1035. # first linkline to make sure our malloc 'wins'.
  1036. heap_checker_unittest_LDADD = $(LIBTCMALLOC) liblogging.la $(PTHREAD_LIBS)
  1037. endif WITH_HEAP_CHECKER
  1038. ### Documentation (above and beyond tcmalloc_minimal documentation)
  1039. if WITH_HEAP_PROFILER
  1040. dist_doc_DATA += docs/heapprofile.html docs/heap-example1.png
  1041. endif WITH_HEAP_PROFILER
  1042. if WITH_HEAP_CHECKER
  1043. dist_doc_DATA += docs/heap_checker.html
  1044. endif WITH_HEAP_CHECKER
  1045. ### ------- tcmalloc with debugallocation
  1046. if WITH_DEBUGALLOC
  1047. if WITH_HEAP_PROFILER_OR_CHECKER
  1048. lib_LTLIBRARIES += libtcmalloc_debug.la
  1049. libtcmalloc_debug_la_SOURCES = src/debugallocation.cc $(HEAP_CHECKER_SOURCES) \
  1050. $(TCMALLOC_INCLUDES)
  1051. libtcmalloc_debug_la_CXXFLAGS = $(libtcmalloc_la_CXXFLAGS) \
  1052. -DTCMALLOC_FOR_DEBUGALLOCATION
  1053. libtcmalloc_debug_la_LDFLAGS = $(libtcmalloc_la_LDFLAGS) \
  1054. -version-info @TCMALLOC_SO_VERSION@
  1055. libtcmalloc_debug_la_LIBADD = $(libtcmalloc_la_LIBADD)
  1056. LIBS_TO_WEAKEN += libtcmalloc_debug.la
  1057. ### Unittests
  1058. TESTS += tcmalloc_debug_unittest
  1059. tcmalloc_debug_unittest_SOURCES = $(tcmalloc_unittest_SOURCES)
  1060. tcmalloc_debug_unittest_CXXFLAGS = $(tcmalloc_unittest_CXXFLAGS) \
  1061. -DDEBUGALLOCATION
  1062. tcmalloc_debug_unittest_LDFLAGS = $(tcmalloc_unittest_LDFLAGS)
  1063. tcmalloc_debug_unittest_LDADD = libtcmalloc_debug.la $(PTHREAD_LIBS)
  1064. TESTS += sampler_debug_test
  1065. sampler_debug_test_SOURCES = $(sampler_test_SOURCES)
  1066. sampler_debug_test_CXXFLAGS = $(samples_test_CXXFLAGS)
  1067. sampler_debug_test_LDFLAGS = $(sampler_test_LDFLAGS)
  1068. sampler_debug_test_LDADD = libtcmalloc_debug.la $(PTHREAD_LIBS) -lm
  1069. TESTS += sampling_debug_test.sh$(EXEEXT)
  1070. sampling_debug_test_sh_SOURCES = src/tests/sampling_test.sh
  1071. sampling_debug_test.sh$(EXEEXT): $(top_srcdir)/$(sampling_test_sh_SOURCES) \
  1072. sampling_debug_test
  1073. rm -f $@
  1074. cp -p $(top_srcdir)/$(sampling_test_sh_SOURCES) $@
  1075. # This is the sub-program using by sampling_debug_test.sh
  1076. # The -g is so pprof can get symbol information.
  1077. noinst_PROGRAMS += sampling_debug_test
  1078. sampling_debug_test_SOURCES = $(sampling_test_SOURCES)
  1079. sampling_debug_test_CXXFLAGS = $(sampling_test_CXXFLAGS)
  1080. sampling_debug_test_LDFLAGS = $(sampling_test_LDFLAGS)
  1081. sampling_debug_test_LDADD = libtcmalloc_debug.la $(PTHREAD_LIBS)
  1082. endif WITH_HEAP_PROFILER_OR_CHECKER
  1083. if WITH_HEAP_PROFILER
  1084. TESTS += heap-profiler_debug_unittest.sh$(EXEEXT)
  1085. heap_profiler_debug_unittest_sh_SOURCES = src/tests/heap-profiler_unittest.sh
  1086. heap-profiler_debug_unittest.sh$(EXEEXT): $(top_srcdir)/$(heap_profiler_unittest_sh_SOURCES) \
  1087. heap-profiler_debug_unittest
  1088. rm -f $@
  1089. cp -p $(top_srcdir)/$(heap_profiler_unittest_sh_SOURCES) $@
  1090. # These are sub-programs used by heap-profiler_debug_unittest.sh
  1091. noinst_PROGRAMS += heap-profiler_debug_unittest
  1092. heap_profiler_debug_unittest_SOURCES = $(heap_profiler_unittest_SOURCES)
  1093. heap_profiler_debug_unittest_CXXFLAGS = $(heap_profiler_unittest_CXXFLAGS)
  1094. heap_profiler_debug_unittest_LDFLAGS = $(heap_profiler_unittest_LDFLAGS)
  1095. heap_profiler_debug_unittest_LDADD = libtcmalloc_debug.la $(PTHREAD_LIBS)
  1096. endif WITH_HEAP_PROFILER
  1097. if WITH_HEAP_CHECKER
  1098. TESTS += heap-checker_debug_unittest.sh$(EXEEXT)
  1099. heap_checker_debug_unittest_sh_SOURCES = src/tests/heap-checker_unittest.sh
  1100. heap-checker_debug_unittest.sh$(EXEEXT): $(top_srcdir)/$(heap_checker_unittest_sh_SOURCES) \
  1101. heap-checker_debug_unittest
  1102. rm -f $@
  1103. cp -p $(top_srcdir)/$(heap_checker_unittest_sh_SOURCES) $@
  1104. # These are sub-programs used by heap-checker_debug_unittest.sh
  1105. noinst_PROGRAMS += heap-checker_debug_unittest
  1106. heap_checker_debug_unittest_SOURCES = $(heap_checker_unittest_SOURCES)
  1107. heap_checker_debug_unittest_CXXFLAGS = $(heap_checker_unittest_CXXFLAGS)
  1108. heap_checker_debug_unittest_LDFLAGS = $(heap_checker_unittest_LDFLAGS)
  1109. # We want libtcmalloc last on the link line, but due to a bug in
  1110. # libtool involving convenience libs, they need to come last on the
  1111. # link line in order to get dependency ordering right. This is ok:
  1112. # convenience libraries are .a's, so tcmalloc is still the last .so.
  1113. heap_checker_debug_unittest_LDADD = libtcmalloc_debug.la liblogging.la \
  1114. $(PTHREAD_LIBS)
  1115. endif WITH_HEAP_CHECKER
  1116. endif WITH_DEBUGALLOC
  1117. ### ------- CPU profiler
  1118. if WITH_CPU_PROFILER
  1119. ### The header files we use. We divide into categories based on directory
  1120. S_CPU_PROFILER_INCLUDES = src/profiledata.h \
  1121. src/profile-handler.h \
  1122. src/getpc.h \
  1123. src/base/basictypes.h \
  1124. src/base/commandlineflags.h \
  1125. src/base/googleinit.h \
  1126. src/base/logging.h \
  1127. src/base/simple_mutex.h \
  1128. src/base/sysinfo.h \
  1129. $(SPINLOCK_INCLUDES) \
  1130. $(LOGGING_INCLUDES)
  1131. SG_CPU_PROFILER_INCLUDES = src/gperftools/profiler.h
  1132. CPU_PROFILER_INCLUDES = $(S_CPU_PROFILER_INCLUDES) $(SG_CPU_PROFILER_INCLUDES) \
  1133. $(SG_STACKTRACE_INCLUDES)
  1134. perftoolsinclude_HEADERS += $(SG_CPU_PROFILER_INCLUDES)
  1135. ### Making the library
  1136. lib_LTLIBRARIES += libprofiler.la
  1137. libprofiler_la_SOURCES = src/profiler.cc \
  1138. src/profile-handler.cc \
  1139. src/profiledata.cc \
  1140. $(CPU_PROFILER_INCLUDES)
  1141. libprofiler_la_LIBADD = libstacktrace.la libmaybe_threads.la libfake_stacktrace_scope.la
  1142. # We have to include ProfileData for profiledata_unittest
  1143. CPU_PROFILER_SYMBOLS = '(ProfilerStart|ProfilerStartWithOptions|ProfilerStop|ProfilerFlush|ProfilerEnable|ProfilerDisable|ProfilingIsEnabledForAllThreads|ProfilerRegisterThread|ProfilerGetCurrentState|ProfilerState|ProfileData|ProfileHandler)'
  1144. libprofiler_la_LDFLAGS = -export-symbols-regex $(CPU_PROFILER_SYMBOLS) \
  1145. -version-info @PROFILER_SO_VERSION@
  1146. # See discussion above (under LIBTCMALLOC_MINIMAL) for why we do this.
  1147. # Basically it's to work around systems where --rpath doesn't work right.
  1148. LIBPROFILER = libstacktrace.la libprofiler.la
  1149. ### Unittests
  1150. TESTS += getpc_test
  1151. #WINDOWS_PROJECTS += vsprojects/getpc_test/getpc_test.vcproj
  1152. getpc_test_SOURCES = src/tests/getpc_test.cc src/getpc.h
  1153. TESTS += profiledata_unittest
  1154. #WINDOWS_PROJECTS += vsprojects/profiledata_unittest/profiledata_unittest.vcproj
  1155. profiledata_unittest_SOURCES = src/tests/profiledata_unittest.cc \
  1156. src/profiledata.h \
  1157. src/base/commandlineflags.h \
  1158. src/base/logging.h \
  1159. src/base/basictypes.h
  1160. profiledata_unittest_LDADD = $(LIBPROFILER)
  1161. TESTS += profile_handler_unittest
  1162. profile_handler_unittest_SOURCES = src/tests/profile-handler_unittest.cc \
  1163. src/profile-handler.h
  1164. profile_handler_unittest_CXXFLAGS = $(PTHREAD_CFLAGS)
  1165. profile_handler_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
  1166. profile_handler_unittest_LDADD = $(LIBPROFILER) $(PTHREAD_LIBS)
  1167. TESTS += profiler_unittest.sh$(EXEEXT)
  1168. profiler_unittest_sh_SOURCES = src/tests/profiler_unittest.sh
  1169. noinst_SCRIPTS += $(profiler_unittest_sh_SOURCES)
  1170. profiler_unittest.sh$(EXEEXT): $(top_srcdir)/$(profiler_unittest_sh_SOURCES) \
  1171. profiler1_unittest profiler2_unittest \
  1172. profiler3_unittest profiler4_unittest
  1173. rm -f $@
  1174. cp -p $(top_srcdir)/$(profiler_unittest_sh_SOURCES) $@
  1175. # These are sub-programs used by profiler_unittest.sh
  1176. noinst_PROGRAMS += profiler1_unittest profiler2_unittest profiler3_unittest \
  1177. profiler4_unittest
  1178. PROFILER_UNITTEST_INCLUDES = src/config_for_unittests.h \
  1179. src/gperftools/profiler.h
  1180. PROFILER_UNITTEST_SRCS = src/tests/profiler_unittest.cc \
  1181. src/tests/testutil.h src/tests/testutil.cc \
  1182. $(PROFILER_UNITTEST_INCLUDES)
  1183. profiler1_unittest_SOURCES = $(PROFILER_UNITTEST_SRCS)
  1184. profiler1_unittest_CXXFLAGS = -g -DNO_THREADS $(AM_CXXFLAGS)
  1185. profiler1_unittest_LDADD = $(LIBPROFILER)
  1186. profiler2_unittest_SOURCES = $(PROFILER_UNITTEST_SRCS)
  1187. profiler2_unittest_CXXFLAGS = -g -DNO_THREADS $(AM_CXXFLAGS)
  1188. profiler2_unittest_LDADD = -lstacktrace -lprofiler
  1189. # We depend on -lprofiler but haven't yet said how to build it. Do so now.
  1190. profiler2_unittest_DEPENDENCIES = $(LIBPROFILER)
  1191. profiler3_unittest_SOURCES = $(PROFILER_UNITTEST_SRCS)
  1192. profiler3_unittest_CXXFLAGS = -g $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  1193. profiler3_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
  1194. profiler3_unittest_LDADD = $(LIBPROFILER) $(PTHREAD_LIBS)
  1195. profiler4_unittest_SOURCES = $(PROFILER_UNITTEST_SRCS)
  1196. profiler4_unittest_CXXFLAGS = -g $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  1197. profiler4_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
  1198. profiler4_unittest_LDADD = -lstacktrace -lprofiler $(PTHREAD_LIBS)
  1199. # We depend on -lprofiler but haven't yet said how to build it. Do so now.
  1200. profiler4_unittest_DEPENDENCIES = $(LIBPROFILER)
  1201. ### Documentation
  1202. dist_doc_DATA += docs/cpuprofile.html \
  1203. docs/cpuprofile-fileformat.html \
  1204. docs/pprof-test-big.gif \
  1205. docs/pprof-test.gif \
  1206. docs/pprof-vsnprintf-big.gif \
  1207. docs/pprof-vsnprintf.gif
  1208. endif WITH_CPU_PROFILER
  1209. ### ------- CPU profiler and heap checker, in one!
  1210. # Ideally, folks who wanted to use both tcmalloc and libprofiler,
  1211. # could just link them both into their application. But while this
  1212. # works fine for .so files, it does not for .a files. The easiest way
  1213. # around this -- and I've tried a bunch of the hard ways -- is to just
  1214. # to create another set of libraries that has both functionality in it.
  1215. if WITH_HEAP_PROFILER_OR_CHECKER
  1216. if WITH_CPU_PROFILER
  1217. lib_LTLIBRARIES += libtcmalloc_and_profiler.la
  1218. libtcmalloc_and_profiler_la_SOURCES = $(libtcmalloc_la_SOURCES) $(libprofiler_la_SOURCES)
  1219. libtcmalloc_and_profiler_la_CXXFLAGS = $(libtcmalloc_la_CXXFLAGS) $(libprofiler_la_CXXFLAGS)
  1220. # Since this library is meant to be used as a .a, I don't worry as much
  1221. # about .so versioning. I just give the libtcmalloc version number.
  1222. # TODO(csilvers): use -export-symbols-regex?
  1223. libtcmalloc_and_profiler_la_LDFLAGS = $(PTHREAD_CFLAGS) \
  1224. -version-info @TCMALLOC_SO_VERSION@
  1225. # We don't include libprofiler_la_LIBADD here because all it adds is
  1226. # libstacktrace.la, which we already get via libtcmalloc. Trying to
  1227. # specify it twice causes link-time duplicate-definition errors. :-(
  1228. libtcmalloc_and_profiler_la_LIBADD = $(libtcmalloc_la_LIBADD)
  1229. TESTS += tcmalloc_and_profiler_unittest
  1230. tcmalloc_and_profiler_unittest_SOURCES = $(tcmalloc_both_unittest_srcs)
  1231. tcmalloc_and_profiler_unittest_CXXFLAGS = $(tcmalloc_both_unittest_cflags)
  1232. tcmalloc_and_profiler_unittest_LDFLAGS = $(tcmalloc_both_unittest_lflags)
  1233. tcmalloc_and_profiler_unittest_LDADD = libtcmalloc_and_profiler.la
  1234. LIBS_TO_WEAKEN += libtcmalloc_and_profiler.la
  1235. endif WITH_CPU_PROFILER
  1236. endif WITH_HEAP_PROFILER_OR_CHECKER
  1237. ## ^^^^ END OF RULES TO MAKE YOUR LIBRARIES, BINARIES, AND UNITTESTS
  1238. # Do the weakening on some exported libtcmalloc symbols.
  1239. install-exec-local: all-local
  1240. all-local: $(LIBS_TO_WEAKEN)
  1241. for la in $(LIBS_TO_WEAKEN); do lib=".libs/`basename $$la .la`.a"; [ ! -f "$$lib" ] || $(WEAKEN) "$$lib"; done
  1242. # This should always include $(TESTS), but may also include other
  1243. # binaries that you compile but don't want automatically installed.
  1244. # We'll add to this later, on a library-by-library basis
  1245. noinst_PROGRAMS += $(TESTS)
  1246. rpm: dist-gzip packages/rpm.sh packages/rpm/rpm.spec
  1247. @cd packages && ./rpm.sh ${PACKAGE} ${VERSION}
  1248. deb: dist-gzip packages/deb.sh packages/deb/*
  1249. @cd packages && ./deb.sh ${PACKAGE} ${VERSION}
  1250. # http://linux.die.net/man/1/pkg-config, http://pkg-config.freedesktop.org/wiki
  1251. pkgconfigdir = $(libdir)/pkgconfig
  1252. pkgconfig_DATA = libtcmalloc.pc libtcmalloc_minimal.pc \
  1253. libtcmalloc_debug.pc libtcmalloc_minimal_debug.pc \
  1254. libprofiler.pc
  1255. CLEANFILES = $(pkgconfig_DATA)
  1256. # I get the description and URL lines from the rpm spec. I use sed to
  1257. # try to rewrite exec_prefix, libdir, and includedir in terms of
  1258. # prefix, if possible.
  1259. libtcmalloc.pc: Makefile packages/rpm/rpm.spec
  1260. echo 'prefix=$(prefix)' > "$@".tmp
  1261. echo 'exec_prefix='`echo '$(exec_prefix)' | sed 's@^$(prefix)@$${prefix}@'` >> "$@".tmp
  1262. echo 'libdir='`echo '$(libdir)' | sed 's@^$(exec_prefix)@$${exec_prefix}@'` >> "$@".tmp
  1263. echo 'includedir='`echo '$(includedir)' | sed 's@^$(prefix)@$${prefix}@'` >> "$@".tmp
  1264. echo '' >> "$@".tmp
  1265. echo 'Name: $(PACKAGE)' >> "$@".tmp
  1266. echo 'Version: $(VERSION)' >> "$@".tmp
  1267. -grep '^Summary:' $(top_srcdir)/packages/rpm/rpm.spec | sed s/^Summary:/Description:/ | head -n1 >> "$@".tmp
  1268. -grep '^URL: ' $(top_srcdir)/packages/rpm/rpm.spec >> "$@".tmp
  1269. echo 'Requires:' >> "$@".tmp
  1270. echo 'Libs: -L$${libdir} -ltcmalloc' >> "$@".tmp
  1271. echo 'Libs.private: $(PTHREAD_CFLAGS) $(PTHREAD_LIBS)' >> "$@".tmp
  1272. echo 'Cflags: -I$${includedir}' >> "$@".tmp
  1273. mv -f "$@".tmp "$@"
  1274. # The other versions are mostly the same.
  1275. libtcmalloc_minimal.pc: libtcmalloc.pc
  1276. cat libtcmalloc.pc | sed s/-ltcmalloc/-ltcmalloc_minimal/ > "$@"
  1277. libtcmalloc_debug.pc: libtcmalloc.pc
  1278. cat libtcmalloc.pc | sed s/-ltcmalloc/-ltcmalloc_debug/ > "$@"
  1279. libtcmalloc_minimal_debug.pc: libtcmalloc.pc
  1280. cat libtcmalloc.pc | sed s/-ltcmalloc/-ltcmalloc_minimal_debug/ > "$@"
  1281. libprofiler.pc: libtcmalloc.pc
  1282. cat libtcmalloc.pc | sed s/-ltcmalloc/-lprofiler/ > "$@"
  1283. libtool: $(LIBTOOL_DEPS)
  1284. $(SHELL) ./config.status --recheck
  1285. @GENERATE_CHANGELOG_RULES@
  1286. # Windows wants write permission to .vcproj files and maybe even sln files.
  1287. dist-hook: dist-ChangeLog
  1288. test -e "$(distdir)/vsprojects" \
  1289. && chmod -R u+w $(distdir)/*.sln $(distdir)/vsprojects/
  1290. EXTRA_DIST = packages/rpm.sh packages/rpm/rpm.spec packages/deb.sh packages/deb \
  1291. $(SCRIPTS) libtool \
  1292. src/windows/get_mangled_names.cc src/windows/override_functions.cc \
  1293. src/windows/config.h src/windows/gperftools/tcmalloc.h \
  1294. docs/pprof.see_also src/windows/TODO \
  1295. $(WINDOWS_PROJECTS) \
  1296. src/solaris/libstdc++.la