1 Copyright 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
4 This file is free documentation; the Free Software Foundation gives
5 unlimited permission to copy, distribute and modify it.
8 Perftools-Specific Install Notes
9 ================================
11 *** NOTE FOR 64-BIT LINUX SYSTEMS
13 The glibc built-in stack-unwinder on 64-bit systems has some problems
14 with the perftools libraries. (In particular, the cpu/heap profiler
15 may be in the middle of malloc, holding some malloc-related locks when
16 they invoke the stack unwinder. The built-in stack unwinder may call
17 malloc recursively, which may require the thread to acquire a lock it
18 already holds: deadlock.)
20 For that reason, if you use a 64-bit system, we strongly recommend you
21 install libunwind before trying to configure or install gperftools.
22 libunwind can be found at
24 http://download.savannah.gnu.org/releases/libunwind/libunwind-0.99-beta.tar.gz
26 Even if you already have libunwind installed, you should check the
27 version. Versions older than this will not work properly; too-new
28 versions introduce new code that does not work well with perftools
29 (because libunwind can call malloc, which will lead to deadlock).
31 There have been reports of crashes with libunwind 0.99 (see
32 http://code.google.com/p/gperftools/issues/detail?id=374).
33 Alternately, you can use a more recent libunwind (e.g. 1.0.1) at the
34 cost of adding a bit of boilerplate to your code. For details, see
35 http://groups.google.com/group/google-perftools/msg/2686d9f24ac4365f
37 CAUTION: if you install libunwind from the url above, be aware that
38 you may have trouble if you try to statically link your binary with
39 perftools: that is, if you link with 'gcc -static -lgcc_eh ...'.
40 This is because both libunwind and libgcc implement the same C++
41 exception handling APIs, but they implement them differently on
42 some platforms. This is not likely to be a problem on ia64, but
45 Also, if you link binaries statically, make sure that you add
46 -Wl,--eh-frame-hdr to your linker options. This is required so that
47 libunwind can find the information generated by the compiler
48 required for stack unwinding.
50 Using -static is rare, though, so unless you know this will affect
51 you it probably won't.
53 If you cannot or do not wish to install libunwind, you can still try
54 to use the built-in stack unwinder. The built-in stack unwinder
55 requires that your application, the tcmalloc library, and system
56 libraries like libc, all be compiled with a frame pointer. This is
57 *not* the default for x86-64.
59 If you are on x86-64 system, know that you have a set of system
60 libraries with frame-pointers enabled, and compile all your
61 applications with -fno-omit-frame-pointer, then you can enable the
62 built-in perftools stack unwinder by passing the
63 --enable-frame-pointers flag to configure.
65 Even with the use of libunwind, there are still known problems with
66 stack unwinding on 64-bit systems, particularly x86-64. See the
67 "64-BIT ISSUES" section in README.
69 If you encounter problems, try compiling perftools with './configure
70 --enable-frame-pointers'. Note you will need to compile your
71 application with frame pointers (via 'gcc -fno-omit-frame-pointer
75 *** TCMALLOC LARGE PAGES: TRADING TIME FOR SPACE
77 You can set a compiler directive that makes tcmalloc faster, at the
78 cost of using more space (due to internal fragmentation).
80 Internally, tcmalloc divides its memory into "pages." The default
81 page size is chosen to minimize memory use by reducing fragmentation.
82 The cost is that keeping track of these pages can cost tcmalloc time.
83 We've added a new, experimental flag to tcmalloc that enables a larger
84 page size. In general, this will increase the memory needs of
85 applications using tcmalloc. However, in many cases it will speed up
86 the applications as well, particularly if they allocate and free a lot
87 of memory. We've seen average speedups of 3-5% on Google
90 This feature is still very experimental; it's not even a configure
91 flag yet. To build libtcmalloc with large pages, run
93 ./configure <normal flags> CXXFLAGS=-DTCMALLOC_LARGE_PAGES
95 (or add -DTCMALLOC_LARGE_PAGES to your existing CXXFLAGS argument).
98 *** SMALL TCMALLOC CACHES: TRADING SPACE FOR TIME
100 You can set a compiler directive that makes tcmalloc use less memory
101 for overhead, at the cost of some time.
103 Internally, tcmalloc keeps information about some of its internal data
104 structures in a cache. This speeds memory operations that need to
105 access this internal data. We've added a new, experimental flag to
106 tcmalloc that reduces the size of this cache, decresaing the memory
107 needs of applications using tcmalloc.
109 This feature is still very experimental; it's not even a configure
110 flag yet. To build libtcmalloc with smaller internal caches, run
112 ./configure <normal flags> CXXFLAGS=-DTCMALLOC_SMALL_BUT_SLOW
114 (or add -DTCMALLOC_SMALL_BUT_SLOW to your existing CXXFLAGS argument).
117 *** NOTE FOR ___tls_get_addr ERROR
119 When compiling perftools on some old systems, like RedHat 8, you may
120 get an error like this:
121 ___tls_get_addr: symbol not found
123 This means that you have a system where some parts are updated enough
124 to support Thread Local Storage, but others are not. The perftools
125 configure script can't always detect this kind of case, leading to
126 that error. To fix it, just comment out the line
128 in your config.h file before building.
131 *** TCMALLOC AND DLOPEN
133 To improve performance, we use the "initial exec" model of Thread
134 Local Storage in tcmalloc. The price for this is the library will not
135 work correctly if it is loaded via dlopen(). This should not be a
136 problem, since loading a malloc-replacement library via dlopen is
137 asking for trouble in any case: some data will be allocated with one
138 malloc, some with another. If, for some reason, you *do* need to use
139 dlopen on tcmalloc, the easiest way is to use a version of tcmalloc
140 with TLS turned off; see the ___tls_get_addr note above.
143 *** COMPILING ON NON-LINUX SYSTEMS
145 Perftools has been tested on the following systems:
148 Linux CentOS 5.5 (x86_64)
149 Linux Debian 4.0 (PPC)
150 Linux Debian 5.0 (x86)
151 Linux Fedora Core 3 (x86)
152 Linux Fedora Core 4 (x86)
153 Linux Fedora Core 5 (x86)
154 Linux Fedora Core 6 (x86)
155 Linux Fedora Core 13 (x86_64)
156 Linux Fedora Core 14 (x86_64)
158 Linux Slackware 13 (x86_64)
159 Linux Ubuntu 6.06.1 (x86)
160 Linux Ubuntu 6.06.1 (x86_64)
161 Linux Ubuntu 10.04 (x86)
162 Linux Ubuntu 10.10 (x86_64)
163 Mac OS X 10.3.9 (Panther) (PowerPC)
164 Mac OS X 10.4.8 (Tiger) (PowerPC)
165 Mac OS X 10.4.8 (Tiger) (x86)
166 Mac OS X 10.5 (Leopard) (x86)
167 Mac OS X 10.6 (Snow Leopard) (x86)
169 Windows XP, Visual Studio 2003 (VC++ 7.1) (x86)
170 Windows XP, Visual Studio 2005 (VC++ 8) (x86)
171 Windows XP, Visual Studio 2005 (VC++ 9) (x86)
172 Windows XP, Visual Studio 2005 (VC++ 10) (x86)
173 Windows XP, MinGW 5.1.3 (x86)
174 Windows XP, Cygwin 5.1 (x86)
176 It works in its full generality on the Linux systems
177 tested (though see 64-bit notes above). Portions of perftools work on
178 the other systems. The basic memory-allocation library,
179 tcmalloc_minimal, works on all systems. The cpu-profiler also works
180 fairly widely. However, the heap-profiler and heap-checker are not
181 yet as widely supported. In general, the 'configure' script will
182 detect what OS you are building for, and only build the components
183 that work on that OS.
185 Note that tcmalloc_minimal is perfectly usable as a malloc/new
186 replacement, so it is possible to use tcmalloc on all the systems
187 above, by linking in libtcmalloc_minimal.
191 The following binaries build and run successfully (creating
192 libtcmalloc_minimal.so and libprofile.so in the process):
194 % make tcmalloc_minimal_unittest tcmalloc_minimal_large_unittest \
195 addressmap_unittest atomicops_unittest frag_unittest \
196 low_level_alloc_unittest markidle_unittest memalign_unittest \
197 packed_cache_test stacktrace_unittest system_alloc_unittest \
198 thread_dealloc_unittest profiler_unittest.sh
199 % ./tcmalloc_minimal_unittest # to run this test
200 % [etc] # to run other tests
202 Three caveats: first, frag_unittest tries to allocate 400M of memory,
203 and if you have less virtual memory on your system, the test may
204 fail with a bad_alloc exception.
206 Second, profiler_unittest.sh sometimes fails in the "fork" test.
207 This is because stray SIGPROF signals from the parent process are
208 making their way into the child process. (This may be a kernel
209 bug that only exists in older kernels.) The profiling code itself
210 is working fine. This only affects programs that call fork(); for
211 most programs, the cpu profiler is entirely safe to use.
213 Third, perftools depends on /proc to get shared library
214 information. If you are running a FreeBSD system without proc,
215 perftools will not be able to map addresses to functions. Some
216 unittests will fail as a result.
218 Finally, the new test introduced in perftools-1.2,
219 profile_handler_unittest, fails on FreeBSD. It has something to do
220 with how the itimer works. The cpu profiler test passes, so I
221 believe the functionality is correct and the issue is with the test
222 somehow. If anybody is an expert on itimers and SIGPROF in
223 FreeBSD, and would like to debug this, I'd be glad to hear the
226 libtcmalloc.so successfully builds, and the "advanced" tcmalloc
227 functionality all works except for the leak-checker, which has
229 % make heap-profiler_unittest.sh maybe_threads_unittest.sh \
230 tcmalloc_unittest tcmalloc_both_unittest \
231 tcmalloc_large_unittest # THESE WORK
232 % make -k heap-checker_unittest.sh \
233 heap-checker-death_unittest.sh # THESE DO NOT
235 Note that unless you specify --enable-heap-checker explicitly,
236 'make' will not build the heap-checker unittests on a FreeBSD
239 I have not tested other *BSD systems, but they are probably similar.
243 I've tested OS X 10.5 [Leopard], OS X 10.4 [Tiger] and OS X 10.3
244 [Panther] on both intel (x86) and PowerPC systems. For Panther
245 systems, perftools does not work at all: it depends on a header
246 file, OSAtomic.h, which is new in 10.4. (It's possible to get the
247 code working for Panther/i386 without too much work; if you're
248 interested in exploring this, drop an e-mail.)
250 For the other seven systems, the binaries and libraries that
251 successfully build are exactly the same as for FreeBSD. See that
252 section for a list of binaries and instructions on building them.
254 In addition, it appears OS X regularly fails profiler_unittest.sh
255 in the "thread" test (in addition to occassionally failing in the
256 "fork" test). It looks like OS X often delivers the profiling
257 signal to the main thread, even when it's sleeping, rather than
258 spawned threads that are doing actual work. If anyone knows
259 details of how OS X handles SIGPROF (via setitimer()) events with
260 threads, and has insight into this problem, please send mail to
261 google-perftools@googlegroups.com.
265 I've only tested using the GNU C++ compiler, not the Sun C++
266 compiler. Using g++ requires setting the PATH appropriately when
269 % PATH=${PATH}:/usr/sfw/bin/:/usr/ccs/bin ./configure
270 % PATH=${PATH}:/usr/sfw/bin/:/usr/ccs/bin make [...]
272 Again, the binaries and libraries that successfully build are
273 exactly the same as for FreeBSD. (However, while libprofiler.so can
274 be used to generate profiles, pprof is not very successful at
275 reading them -- necessary helper programs like nm don't seem
276 to be installed by default on Solaris, or perhaps are only
277 installed as part of the Sun C++ compiler package.) See that
278 section for a list of binaries, and instructions on building them.
280 ** Windows (MSVC, Cygwin, and MinGW):
282 Work on Windows is rather preliminary: we haven't found a good way
283 to get stack traces in release mode on windows (that is, when FPO
284 is enabled), so the heap profiling may not be reliable in that
285 case. Also, heap-checking and CPU profiling do not yet work at
286 all. But as in other ports, the basic tcmalloc library
287 functionality, overriding malloc and new and such (and even
288 windows-specific functions like _aligned_malloc!), is working fine,
289 at least with VC++ 7.1 (Visual Studio 2003) through VC++ 10.0,
290 in both debug and release modes. See README.windows for
291 instructions on how to install on Windows using Visual Studio.
293 Cygwin can compile some but not all of perftools. Furthermore,
294 there is a problem with exception-unwinding in cygwin (it can call
295 malloc, which can call the exception-unwinding-setup code, which
296 can lead to an infinite loop). I've comitted a workaround to the
297 exception unwinding problem, but it only works in debug mode and
298 when statically linking in tcmalloc. I hope to have a more proper
299 fix in a later release. To configure under cygwin, run
301 ./configure --disable-shared CXXFLAGS=-g && make
303 Most of cygwin will compile (cygwin doesn't allow weak symbols, so
304 the heap-checker and a few other pieces of functionality will not
305 compile). 'make' will compile those libraries and tests that can
306 be compiled. You can run 'make check' to make sure the basic
307 functionality is working. I've heard reports that some versions of
308 cygwin fail calls to pthread_join() with EINVAL, causing several
309 tests to fail. If you have any insight into this, please mail
310 google-perftools@googlegroups.com.
312 This Windows functionality is also available using MinGW and Msys,
313 In this case, you can use the regular './configure && make'
314 process. 'make install' should also work. The Makefile will limit
315 itself to those libraries and binaries that work on windows.
321 These are generic installation instructions.
323 The `configure' shell script attempts to guess correct values for
324 various system-dependent variables used during compilation. It uses
325 those values to create a `Makefile' in each directory of the package.
326 It may also create one or more `.h' files containing system-dependent
327 definitions. Finally, it creates a shell script `config.status' that
328 you can run in the future to recreate the current configuration, and a
329 file `config.log' containing compiler output (useful mainly for
330 debugging `configure').
332 It can also use an optional file (typically called `config.cache'
333 and enabled with `--cache-file=config.cache' or simply `-C') that saves
334 the results of its tests to speed up reconfiguring. (Caching is
335 disabled by default to prevent problems with accidental use of stale
338 If you need to do unusual things to compile the package, please try
339 to figure out how `configure' could check whether to do them, and mail
340 diffs or instructions to the address given in the `README' so they can
341 be considered for the next release. If you are using the cache, and at
342 some point `config.cache' contains results you don't want to keep, you
343 may remove or edit it.
345 The file `configure.ac' (or `configure.in') is used to create
346 `configure' by a program called `autoconf'. You only need
347 `configure.ac' if you want to change it or regenerate `configure' using
348 a newer version of `autoconf'.
350 The simplest way to compile this package is:
352 1. `cd' to the directory containing the package's source code and type
353 `./configure' to configure the package for your system. If you're
354 using `csh' on an old version of System V, you might need to type
355 `sh ./configure' instead to prevent `csh' from trying to execute
358 Running `configure' takes awhile. While running, it prints some
359 messages telling which features it is checking for.
361 2. Type `make' to compile the package.
363 3. Optionally, type `make check' to run any self-tests that come with
366 4. Type `make install' to install the programs and any data files and
369 5. You can remove the program binaries and object files from the
370 source code directory by typing `make clean'. To also remove the
371 files that `configure' created (so you can compile the package for
372 a different kind of computer), type `make distclean'. There is
373 also a `make maintainer-clean' target, but that is intended mainly
374 for the package's developers. If you use it, you may have to get
375 all sorts of other programs in order to regenerate files that came
376 with the distribution.
378 Compilers and Options
379 =====================
381 Some systems require unusual options for compilation or linking that
382 the `configure' script does not know about. Run `./configure --help'
383 for details on some of the pertinent environment variables.
385 You can give `configure' initial values for configuration parameters
386 by setting variables in the command line or in the environment. Here
389 ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
391 *Note Defining Variables::, for more details.
393 Compiling For Multiple Architectures
394 ====================================
396 You can compile the package for more than one kind of computer at the
397 same time, by placing the object files for each architecture in their
398 own directory. To do this, you must use a version of `make' that
399 supports the `VPATH' variable, such as GNU `make'. `cd' to the
400 directory where you want the object files and executables to go and run
401 the `configure' script. `configure' automatically checks for the
402 source code in the directory that `configure' is in and in `..'.
404 If you have to use a `make' that does not support the `VPATH'
405 variable, you have to compile the package for one architecture at a
406 time in the source code directory. After you have installed the
407 package for one architecture, use `make distclean' before reconfiguring
408 for another architecture.
413 By default, `make install' will install the package's files in
414 `/usr/local/bin', `/usr/local/man', etc. You can specify an
415 installation prefix other than `/usr/local' by giving `configure' the
416 option `--prefix=PATH'.
418 You can specify separate installation prefixes for
419 architecture-specific files and architecture-independent files. If you
420 give `configure' the option `--exec-prefix=PATH', the package will use
421 PATH as the prefix for installing programs and libraries.
422 Documentation and other data files will still use the regular prefix.
424 In addition, if you use an unusual directory layout you can give
425 options like `--bindir=PATH' to specify different values for particular
426 kinds of files. Run `configure --help' for a list of the directories
427 you can set and what kinds of files go in them.
429 If the package supports it, you can cause programs to be installed
430 with an extra prefix or suffix on their names by giving `configure' the
431 option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
436 Some packages pay attention to `--enable-FEATURE' options to
437 `configure', where FEATURE indicates an optional part of the package.
438 They may also pay attention to `--with-PACKAGE' options, where PACKAGE
439 is something like `gnu-as' or `x' (for the X Window System). The
440 `README' should mention any `--enable-' and `--with-' options that the
443 For packages that use the X Window System, `configure' can usually
444 find the X include and library files automatically, but if it doesn't,
445 you can use the `configure' options `--x-includes=DIR' and
446 `--x-libraries=DIR' to specify their locations.
448 Specifying the System Type
449 ==========================
451 There may be some features `configure' cannot figure out
452 automatically, but needs to determine by the type of machine the package
453 will run on. Usually, assuming the package is built to be run on the
454 _same_ architectures, `configure' can figure that out, but if it prints
455 a message saying it cannot guess the machine type, give it the
456 `--build=TYPE' option. TYPE can either be a short name for the system
457 type, such as `sun4', or a canonical name which has the form:
461 where SYSTEM can have one of these forms:
465 See the file `config.sub' for the possible values of each field. If
466 `config.sub' isn't included in this package, then this package doesn't
467 need to know the machine type.
469 If you are _building_ compiler tools for cross-compiling, you should
470 use the `--target=TYPE' option to select the type of system they will
473 If you want to _use_ a cross compiler, that generates code for a
474 platform different from the build platform, you should specify the
475 "host" platform (i.e., that on which the generated programs will
476 eventually be run) with `--host=TYPE'.
481 If you want to set default values for `configure' scripts to share,
482 you can create a site shell script called `config.site' that gives
483 default values for variables like `CC', `cache_file', and `prefix'.
484 `configure' looks for `PREFIX/share/config.site' if it exists, then
485 `PREFIX/etc/config.site' if it exists. Or, you can set the
486 `CONFIG_SITE' environment variable to the location of the site script.
487 A warning: not all `configure' scripts look for a site script.
492 Variables not defined in a site shell script can be set in the
493 environment passed to `configure'. However, some packages may run
494 configure again during the build, and the customized values of these
495 variables may be lost. In order to avoid this problem, you should set
496 them in the `configure' command line, using `VAR=value'. For example:
498 ./configure CC=/usr/local2/bin/gcc
500 will cause the specified gcc to be used as the C compiler (unless it is
501 overridden in the site shell script).
503 `configure' Invocation
504 ======================
506 `configure' recognizes the following options to control how it
511 Print a summary of the options to `configure', and exit.
515 Print the version of Autoconf used to generate the `configure'
519 Enable the cache: use and save the results of the tests in FILE,
520 traditionally `config.cache'. FILE defaults to `/dev/null' to
525 Alias for `--cache-file=config.cache'.
530 Do not print messages saying which checks are being made. To
531 suppress all normal output, redirect it to `/dev/null' (any error
532 messages will still be shown).
535 Look for the package's source code in directory DIR. Usually
536 `configure' can determine that directory automatically.
538 `configure' also accepts some other, not widely useful, options. Run
539 `configure --help' for more details.