1Copyright 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*** NOTE FOR 64-BIT LINUX SYSTEMS 12 13The glibc built-in stack-unwinder on 64-bit systems has some problems 14with the perftools libraries. (In particular, the cpu/heap profiler 15may be in the middle of malloc, holding some malloc-related locks when 16they invoke the stack unwinder. The built-in stack unwinder may call 17malloc recursively, which may require the thread to acquire a lock it 18already holds: deadlock.) 19 20For that reason, if you use a 64-bit system, we strongly recommend you 21install libunwind before trying to configure or install gperftools. 22libunwind can be found at 23 24 http://download.savannah.gnu.org/releases/libunwind/libunwind-0.99-beta.tar.gz 25 26Even if you already have libunwind installed, you should check the 27version. Versions older than this will not work properly; too-new 28versions introduce new code that does not work well with perftools 29(because libunwind can call malloc, which will lead to deadlock). 30 31There have been reports of crashes with libunwind 0.99 (see 32http://code.google.com/p/gperftools/issues/detail?id=374). 33Alternately, you can use a more recent libunwind (e.g. 1.0.1) at the 34cost of adding a bit of boilerplate to your code. For details, see 35http://groups.google.com/group/google-perftools/msg/2686d9f24ac4365f 36 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 43 may be on x86-64. 44 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. 49 50 Using -static is rare, though, so unless you know this will affect 51 you it probably won't. 52 53If you cannot or do not wish to install libunwind, you can still try 54to use the built-in stack unwinder. The built-in stack unwinder 55requires that your application, the tcmalloc library, and system 56libraries like libc, all be compiled with a frame pointer. This is 57*not* the default for x86-64. 58 59If you are on x86-64 system, know that you have a set of system 60libraries with frame-pointers enabled, and compile all your 61applications with -fno-omit-frame-pointer, then you can enable the 62built-in perftools stack unwinder by passing the 63--enable-frame-pointers flag to configure. 64 65Even with the use of libunwind, there are still known problems with 66stack unwinding on 64-bit systems, particularly x86-64. See the 67"64-BIT ISSUES" section in README. 68 69If you encounter problems, try compiling perftools with './configure 70--enable-frame-pointers'. Note you will need to compile your 71application with frame pointers (via 'gcc -fno-omit-frame-pointer 72...') in this case. 73 74 75*** TCMALLOC LARGE PAGES: TRADING TIME FOR SPACE 76 77You can set a compiler directive that makes tcmalloc faster, at the 78cost of using more space (due to internal fragmentation). 79 80Internally, tcmalloc divides its memory into "pages." The default 81page size is chosen to minimize memory use by reducing fragmentation. 82The cost is that keeping track of these pages can cost tcmalloc time. 83We've added a new, experimental flag to tcmalloc that enables a larger 84page size. In general, this will increase the memory needs of 85applications using tcmalloc. However, in many cases it will speed up 86the applications as well, particularly if they allocate and free a lot 87of memory. We've seen average speedups of 3-5% on Google 88applications. 89 90This feature is still very experimental; it's not even a configure 91flag yet. To build libtcmalloc with large pages, run 92 93 ./configure <normal flags> CXXFLAGS=-DTCMALLOC_LARGE_PAGES 94 95(or add -DTCMALLOC_LARGE_PAGES to your existing CXXFLAGS argument). 96 97 98*** SMALL TCMALLOC CACHES: TRADING SPACE FOR TIME 99 100You can set a compiler directive that makes tcmalloc use less memory 101for overhead, at the cost of some time. 102 103Internally, tcmalloc keeps information about some of its internal data 104structures in a cache. This speeds memory operations that need to 105access this internal data. We've added a new, experimental flag to 106tcmalloc that reduces the size of this cache, decresaing the memory 107needs of applications using tcmalloc. 108 109This feature is still very experimental; it's not even a configure 110flag yet. To build libtcmalloc with smaller internal caches, run 111 112 ./configure <normal flags> CXXFLAGS=-DTCMALLOC_SMALL_BUT_SLOW 113 114(or add -DTCMALLOC_SMALL_BUT_SLOW to your existing CXXFLAGS argument). 115 116 117*** NOTE FOR ___tls_get_addr ERROR 118 119When compiling perftools on some old systems, like RedHat 8, you may 120get an error like this: 121 ___tls_get_addr: symbol not found 122 123This means that you have a system where some parts are updated enough 124to support Thread Local Storage, but others are not. The perftools 125configure script can't always detect this kind of case, leading to 126that error. To fix it, just comment out the line 127 #define HAVE_TLS 1 128in your config.h file before building. 129 130 131*** TCMALLOC AND DLOPEN 132 133To improve performance, we use the "initial exec" model of Thread 134Local Storage in tcmalloc. The price for this is the library will not 135work correctly if it is loaded via dlopen(). This should not be a 136problem, since loading a malloc-replacement library via dlopen is 137asking for trouble in any case: some data will be allocated with one 138malloc, some with another. If, for some reason, you *do* need to use 139dlopen on tcmalloc, the easiest way is to use a version of tcmalloc 140with TLS turned off; see the ___tls_get_addr note above. 141 142 143*** COMPILING ON NON-LINUX SYSTEMS 144 145Perftools has been tested on the following systems: 146 FreeBSD 6.0 (x86) 147 FreeBSD 8.1 (x86_64) 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) 157 Linux RedHat 9 (x86) 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) 168 Solaris 10 (x86_64) 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) 175 176It works in its full generality on the Linux systems 177tested (though see 64-bit notes above). Portions of perftools work on 178the other systems. The basic memory-allocation library, 179tcmalloc_minimal, works on all systems. The cpu-profiler also works 180fairly widely. However, the heap-profiler and heap-checker are not 181yet as widely supported. In general, the 'configure' script will 182detect what OS you are building for, and only build the components 183that work on that OS. 184 185Note that tcmalloc_minimal is perfectly usable as a malloc/new 186replacement, so it is possible to use tcmalloc on all the systems 187above, by linking in libtcmalloc_minimal. 188 189** FreeBSD: 190 191 The following binaries build and run successfully (creating 192 libtcmalloc_minimal.so and libprofile.so in the process): 193 % ./configure 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 201 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. 205 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. 212 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. 217 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 224 results! 225 226 libtcmalloc.so successfully builds, and the "advanced" tcmalloc 227 functionality all works except for the leak-checker, which has 228 Linux-specific code: 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 234 235 Note that unless you specify --enable-heap-checker explicitly, 236 'make' will not build the heap-checker unittests on a FreeBSD 237 system. 238 239 I have not tested other *BSD systems, but they are probably similar. 240 241** Mac OS X: 242 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.) 249 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. 253 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. 262 263** Solaris 10 x86: 264 265 I've only tested using the GNU C++ compiler, not the Sun C++ 266 compiler. Using g++ requires setting the PATH appropriately when 267 configuring. 268 269 % PATH=${PATH}:/usr/sfw/bin/:/usr/ccs/bin ./configure 270 % PATH=${PATH}:/usr/sfw/bin/:/usr/ccs/bin make [...] 271 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. 279 280** Windows (MSVC, Cygwin, and MinGW): 281 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. 292 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 300 301 ./configure --disable-shared CXXFLAGS=-g && make 302 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. 311 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. 316 317 318Basic Installation 319================== 320 321 These are generic installation instructions. 322 323 The `configure' shell script attempts to guess correct values for 324various system-dependent variables used during compilation. It uses 325those values to create a `Makefile' in each directory of the package. 326It may also create one or more `.h' files containing system-dependent 327definitions. Finally, it creates a shell script `config.status' that 328you can run in the future to recreate the current configuration, and a 329file `config.log' containing compiler output (useful mainly for 330debugging `configure'). 331 332 It can also use an optional file (typically called `config.cache' 333and enabled with `--cache-file=config.cache' or simply `-C') that saves 334the results of its tests to speed up reconfiguring. (Caching is 335disabled by default to prevent problems with accidental use of stale 336cache files.) 337 338 If you need to do unusual things to compile the package, please try 339to figure out how `configure' could check whether to do them, and mail 340diffs or instructions to the address given in the `README' so they can 341be considered for the next release. If you are using the cache, and at 342some point `config.cache' contains results you don't want to keep, you 343may remove or edit it. 344 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 348a newer version of `autoconf'. 349 350The simplest way to compile this package is: 351 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 356 `configure' itself. 357 358 Running `configure' takes awhile. While running, it prints some 359 messages telling which features it is checking for. 360 361 2. Type `make' to compile the package. 362 363 3. Optionally, type `make check' to run any self-tests that come with 364 the package. 365 366 4. Type `make install' to install the programs and any data files and 367 documentation. 368 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. 377 378Compilers and Options 379===================== 380 381 Some systems require unusual options for compilation or linking that 382the `configure' script does not know about. Run `./configure --help' 383for details on some of the pertinent environment variables. 384 385 You can give `configure' initial values for configuration parameters 386by setting variables in the command line or in the environment. Here 387is an example: 388 389 ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix 390 391 *Note Defining Variables::, for more details. 392 393Compiling For Multiple Architectures 394==================================== 395 396 You can compile the package for more than one kind of computer at the 397same time, by placing the object files for each architecture in their 398own directory. To do this, you must use a version of `make' that 399supports the `VPATH' variable, such as GNU `make'. `cd' to the 400directory where you want the object files and executables to go and run 401the `configure' script. `configure' automatically checks for the 402source code in the directory that `configure' is in and in `..'. 403 404 If you have to use a `make' that does not support the `VPATH' 405variable, you have to compile the package for one architecture at a 406time in the source code directory. After you have installed the 407package for one architecture, use `make distclean' before reconfiguring 408for another architecture. 409 410Installation Names 411================== 412 413 By default, `make install' will install the package's files in 414`/usr/local/bin', `/usr/local/man', etc. You can specify an 415installation prefix other than `/usr/local' by giving `configure' the 416option `--prefix=PATH'. 417 418 You can specify separate installation prefixes for 419architecture-specific files and architecture-independent files. If you 420give `configure' the option `--exec-prefix=PATH', the package will use 421PATH as the prefix for installing programs and libraries. 422Documentation and other data files will still use the regular prefix. 423 424 In addition, if you use an unusual directory layout you can give 425options like `--bindir=PATH' to specify different values for particular 426kinds of files. Run `configure --help' for a list of the directories 427you can set and what kinds of files go in them. 428 429 If the package supports it, you can cause programs to be installed 430with an extra prefix or suffix on their names by giving `configure' the 431option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. 432 433Optional Features 434================= 435 436 Some packages pay attention to `--enable-FEATURE' options to 437`configure', where FEATURE indicates an optional part of the package. 438They may also pay attention to `--with-PACKAGE' options, where PACKAGE 439is something like `gnu-as' or `x' (for the X Window System). The 440`README' should mention any `--enable-' and `--with-' options that the 441package recognizes. 442 443 For packages that use the X Window System, `configure' can usually 444find the X include and library files automatically, but if it doesn't, 445you can use the `configure' options `--x-includes=DIR' and 446`--x-libraries=DIR' to specify their locations. 447 448Specifying the System Type 449========================== 450 451 There may be some features `configure' cannot figure out 452automatically, but needs to determine by the type of machine the package 453will 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 455a 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 457type, such as `sun4', or a canonical name which has the form: 458 459 CPU-COMPANY-SYSTEM 460 461where SYSTEM can have one of these forms: 462 463 OS KERNEL-OS 464 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 467need to know the machine type. 468 469 If you are _building_ compiler tools for cross-compiling, you should 470use the `--target=TYPE' option to select the type of system they will 471produce code for. 472 473 If you want to _use_ a cross compiler, that generates code for a 474platform different from the build platform, you should specify the 475"host" platform (i.e., that on which the generated programs will 476eventually be run) with `--host=TYPE'. 477 478Sharing Defaults 479================ 480 481 If you want to set default values for `configure' scripts to share, 482you can create a site shell script called `config.site' that gives 483default 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. 487A warning: not all `configure' scripts look for a site script. 488 489Defining Variables 490================== 491 492 Variables not defined in a site shell script can be set in the 493environment passed to `configure'. However, some packages may run 494configure again during the build, and the customized values of these 495variables may be lost. In order to avoid this problem, you should set 496them in the `configure' command line, using `VAR=value'. For example: 497 498 ./configure CC=/usr/local2/bin/gcc 499 500will cause the specified gcc to be used as the C compiler (unless it is 501overridden in the site shell script). 502 503`configure' Invocation 504====================== 505 506 `configure' recognizes the following options to control how it 507operates. 508 509`--help' 510`-h' 511 Print a summary of the options to `configure', and exit. 512 513`--version' 514`-V' 515 Print the version of Autoconf used to generate the `configure' 516 script, and exit. 517 518`--cache-file=FILE' 519 Enable the cache: use and save the results of the tests in FILE, 520 traditionally `config.cache'. FILE defaults to `/dev/null' to 521 disable caching. 522 523`--config-cache' 524`-C' 525 Alias for `--cache-file=config.cache'. 526 527`--quiet' 528`--silent' 529`-q' 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). 533 534`--srcdir=DIR' 535 Look for the package's source code in directory DIR. Usually 536 `configure' can determine that directory automatically. 537 538`configure' also accepts some other, not widely useful, options. Run 539`configure --help' for more details. 540