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