Makefile.am 68 KB

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