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