INSTALL 24 KB

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