2
0

INSTALL 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. Building and installing a packaged release of jemalloc can be as simple as
  2. typing the following while in the root directory of the source tree:
  3. ./configure
  4. make
  5. make install
  6. If building from unpackaged developer sources, the simplest command sequence
  7. that might work is:
  8. ./autogen.sh
  9. make dist
  10. make
  11. make install
  12. Note that documentation is not built by the default target because doing so
  13. would create a dependency on xsltproc in packaged releases, hence the
  14. requirement to either run 'make dist' or avoid installing docs via the various
  15. install_* targets documented below.
  16. === Advanced configuration =====================================================
  17. The 'configure' script supports numerous options that allow control of which
  18. functionality is enabled, where jemalloc is installed, etc. Optionally, pass
  19. any of the following arguments (not a definitive list) to 'configure':
  20. --help
  21. Print a definitive list of options.
  22. --prefix=<install-root-dir>
  23. Set the base directory in which to install. For example:
  24. ./configure --prefix=/usr/local
  25. will cause files to be installed into /usr/local/include, /usr/local/lib,
  26. and /usr/local/man.
  27. --with-rpath=<colon-separated-rpath>
  28. Embed one or more library paths, so that libjemalloc can find the libraries
  29. it is linked to. This works only on ELF-based systems.
  30. --with-mangling=<map>
  31. Mangle public symbols specified in <map> which is a comma-separated list of
  32. name:mangled pairs.
  33. For example, to use ld's --wrap option as an alternative method for
  34. overriding libc's malloc implementation, specify something like:
  35. --with-mangling=malloc:__wrap_malloc,free:__wrap_free[...]
  36. Note that mangling happens prior to application of the prefix specified by
  37. --with-jemalloc-prefix, and mangled symbols are then ignored when applying
  38. the prefix.
  39. --with-jemalloc-prefix=<prefix>
  40. Prefix all public APIs with <prefix>. For example, if <prefix> is
  41. "prefix_", API changes like the following occur:
  42. malloc() --> prefix_malloc()
  43. malloc_conf --> prefix_malloc_conf
  44. /etc/malloc.conf --> /etc/prefix_malloc.conf
  45. MALLOC_CONF --> PREFIX_MALLOC_CONF
  46. This makes it possible to use jemalloc at the same time as the system
  47. allocator, or even to use multiple copies of jemalloc simultaneously.
  48. By default, the prefix is "", except on OS X, where it is "je_". On OS X,
  49. jemalloc overlays the default malloc zone, but makes no attempt to actually
  50. replace the "malloc", "calloc", etc. symbols.
  51. --without-export
  52. Don't export public APIs. This can be useful when building jemalloc as a
  53. static library, or to avoid exporting public APIs when using the zone
  54. allocator on OSX.
  55. --with-private-namespace=<prefix>
  56. Prefix all library-private APIs with <prefix>je_. For shared libraries,
  57. symbol visibility mechanisms prevent these symbols from being exported, but
  58. for static libraries, naming collisions are a real possibility. By
  59. default, <prefix> is empty, which results in a symbol prefix of je_ .
  60. --with-install-suffix=<suffix>
  61. Append <suffix> to the base name of all installed files, such that multiple
  62. versions of jemalloc can coexist in the same installation directory. For
  63. example, libjemalloc.so.0 becomes libjemalloc<suffix>.so.0.
  64. --disable-cc-silence
  65. Disable code that silences non-useful compiler warnings. This is mainly
  66. useful during development when auditing the set of warnings that are being
  67. silenced.
  68. --enable-debug
  69. Enable assertions and validation code. This incurs a substantial
  70. performance hit, but is very useful during application development.
  71. Implies --enable-ivsalloc.
  72. --enable-code-coverage
  73. Enable code coverage support, for use during jemalloc test development.
  74. Additional testing targets are available if this option is enabled:
  75. coverage
  76. coverage_unit
  77. coverage_integration
  78. coverage_stress
  79. These targets do not clear code coverage results from previous runs, and
  80. there are interactions between the various coverage targets, so it is
  81. usually advisable to run 'make clean' between repeated code coverage runs.
  82. --disable-stats
  83. Disable statistics gathering functionality. See the "opt.stats_print"
  84. option documentation for usage details.
  85. --enable-ivsalloc
  86. Enable validation code, which verifies that pointers reside within
  87. jemalloc-owned chunks before dereferencing them. This incurs a minor
  88. performance hit.
  89. --enable-prof
  90. Enable heap profiling and leak detection functionality. See the "opt.prof"
  91. option documentation for usage details. When enabled, there are several
  92. approaches to backtracing, and the configure script chooses the first one
  93. in the following list that appears to function correctly:
  94. + libunwind (requires --enable-prof-libunwind)
  95. + libgcc (unless --disable-prof-libgcc)
  96. + gcc intrinsics (unless --disable-prof-gcc)
  97. --enable-prof-libunwind
  98. Use the libunwind library (http://www.nongnu.org/libunwind/) for stack
  99. backtracing.
  100. --disable-prof-libgcc
  101. Disable the use of libgcc's backtracing functionality.
  102. --disable-prof-gcc
  103. Disable the use of gcc intrinsics for backtracing.
  104. --with-static-libunwind=<libunwind.a>
  105. Statically link against the specified libunwind.a rather than dynamically
  106. linking with -lunwind.
  107. --disable-tcache
  108. Disable thread-specific caches for small objects. Objects are cached and
  109. released in bulk, thus reducing the total number of mutex operations. See
  110. the "opt.tcache" option for usage details.
  111. --disable-munmap
  112. Disable virtual memory deallocation via munmap(2); instead keep track of
  113. the virtual memory for later use. munmap() is disabled by default (i.e.
  114. --disable-munmap is implied) on Linux, which has a quirk in its virtual
  115. memory allocation algorithm that causes semi-permanent VM map holes under
  116. normal jemalloc operation.
  117. --disable-fill
  118. Disable support for junk/zero filling of memory, quarantine, and redzones.
  119. See the "opt.junk", "opt.zero", "opt.quarantine", and "opt.redzone" option
  120. documentation for usage details.
  121. --disable-valgrind
  122. Disable support for Valgrind.
  123. --disable-zone-allocator
  124. Disable zone allocator for Darwin. This means jemalloc won't be hooked as
  125. the default allocator on OSX/iOS.
  126. --enable-utrace
  127. Enable utrace(2)-based allocation tracing. This feature is not broadly
  128. portable (FreeBSD has it, but Linux and OS X do not).
  129. --enable-xmalloc
  130. Enable support for optional immediate termination due to out-of-memory
  131. errors, as is commonly implemented by "xmalloc" wrapper function for malloc.
  132. See the "opt.xmalloc" option documentation for usage details.
  133. --enable-lazy-lock
  134. Enable code that wraps pthread_create() to detect when an application
  135. switches from single-threaded to multi-threaded mode, so that it can avoid
  136. mutex locking/unlocking operations while in single-threaded mode. In
  137. practice, this feature usually has little impact on performance unless
  138. thread-specific caching is disabled.
  139. --disable-tls
  140. Disable thread-local storage (TLS), which allows for fast access to
  141. thread-local variables via the __thread keyword. If TLS is available,
  142. jemalloc uses it for several purposes.
  143. --disable-cache-oblivious
  144. Disable cache-oblivious large allocation alignment for large allocation
  145. requests with no alignment constraints. If this feature is disabled, all
  146. large allocations are page-aligned as an implementation artifact, which can
  147. severely harm CPU cache utilization. However, the cache-oblivious layout
  148. comes at the cost of one extra page per large allocation, which in the
  149. most extreme case increases physical memory usage for the 16 KiB size class
  150. to 20 KiB.
  151. --with-xslroot=<path>
  152. Specify where to find DocBook XSL stylesheets when building the
  153. documentation.
  154. --with-lg-page=<lg-page>
  155. Specify the base 2 log of the system page size. This option is only useful
  156. when cross compiling, since the configure script automatically determines
  157. the host's page size by default.
  158. --with-lg-page-sizes=<lg-page-sizes>
  159. Specify the comma-separated base 2 logs of the page sizes to support. This
  160. option may be useful when cross-compiling in combination with
  161. --with-lg-page, but its primary use case is for integration with FreeBSD's
  162. libc, wherein jemalloc is embedded.
  163. --with-lg-size-class-group=<lg-size-class-group>
  164. Specify the base 2 log of how many size classes to use for each doubling in
  165. size. By default jemalloc uses <lg-size-class-group>=2, which results in
  166. e.g. the following size classes:
  167. [...], 64,
  168. 80, 96, 112, 128,
  169. 160, [...]
  170. <lg-size-class-group>=3 results in e.g. the following size classes:
  171. [...], 64,
  172. 72, 80, 88, 96, 104, 112, 120, 128,
  173. 144, [...]
  174. The minimal <lg-size-class-group>=0 causes jemalloc to only provide size
  175. classes that are powers of 2:
  176. [...],
  177. 64,
  178. 128,
  179. 256,
  180. [...]
  181. An implementation detail currently limits the total number of small size
  182. classes to 255, and a compilation error will result if the
  183. <lg-size-class-group> you specify cannot be supported. The limit is
  184. roughly <lg-size-class-group>=4, depending on page size.
  185. --with-lg-quantum=<lg-quantum>
  186. Specify the base 2 log of the minimum allocation alignment. jemalloc needs
  187. to know the minimum alignment that meets the following C standard
  188. requirement (quoted from the April 12, 2011 draft of the C11 standard):
  189. The pointer returned if the allocation succeeds is suitably aligned so
  190. that it may be assigned to a pointer to any type of object with a
  191. fundamental alignment requirement and then used to access such an object
  192. or an array of such objects in the space allocated [...]
  193. This setting is architecture-specific, and although jemalloc includes known
  194. safe values for the most commonly used modern architectures, there is a
  195. wrinkle related to GNU libc (glibc) that may impact your choice of
  196. <lg-quantum>. On most modern architectures, this mandates 16-byte alignment
  197. (<lg-quantum>=4), but the glibc developers chose not to meet this
  198. requirement for performance reasons. An old discussion can be found at
  199. https://sourceware.org/bugzilla/show_bug.cgi?id=206 . Unlike glibc,
  200. jemalloc does follow the C standard by default (caveat: jemalloc
  201. technically cheats if --with-lg-tiny-min is smaller than
  202. --with-lg-quantum), but the fact that Linux systems already work around
  203. this allocator noncompliance means that it is generally safe in practice to
  204. let jemalloc's minimum alignment follow glibc's lead. If you specify
  205. --with-lg-quantum=3 during configuration, jemalloc will provide additional
  206. size classes that are not 16-byte-aligned (24, 40, and 56, assuming
  207. --with-lg-size-class-group=2).
  208. --with-lg-tiny-min=<lg-tiny-min>
  209. Specify the base 2 log of the minimum tiny size class to support. Tiny
  210. size classes are powers of 2 less than the quantum, and are only
  211. incorporated if <lg-tiny-min> is less than <lg-quantum> (see
  212. --with-lg-quantum). Tiny size classes technically violate the C standard
  213. requirement for minimum alignment, and crashes could conceivably result if
  214. the compiler were to generate instructions that made alignment assumptions,
  215. both because illegal instruction traps could result, and because accesses
  216. could straddle page boundaries and cause segmentation faults due to
  217. accessing unmapped addresses.
  218. The default of <lg-tiny-min>=3 works well in practice even on architectures
  219. that technically require 16-byte alignment, probably for the same reason
  220. --with-lg-quantum=3 works. Smaller tiny size classes can, and will, cause
  221. crashes (see https://bugzilla.mozilla.org/show_bug.cgi?id=691003 for an
  222. example).
  223. This option is rarely useful, and is mainly provided as documentation of a
  224. subtle implementation detail. If you do use this option, specify a
  225. value in [3, ..., <lg-quantum>].
  226. The following environment variables (not a definitive list) impact configure's
  227. behavior:
  228. CFLAGS="?"
  229. Pass these flags to the compiler. You probably shouldn't define this unless
  230. you know what you are doing. (Use EXTRA_CFLAGS instead.)
  231. EXTRA_CFLAGS="?"
  232. Append these flags to CFLAGS. This makes it possible to add flags such as
  233. -Werror, while allowing the configure script to determine what other flags
  234. are appropriate for the specified configuration.
  235. The configure script specifically checks whether an optimization flag (-O*)
  236. is specified in EXTRA_CFLAGS, and refrains from specifying an optimization
  237. level if it finds that one has already been specified.
  238. CPPFLAGS="?"
  239. Pass these flags to the C preprocessor. Note that CFLAGS is not passed to
  240. 'cpp' when 'configure' is looking for include files, so you must use
  241. CPPFLAGS instead if you need to help 'configure' find header files.
  242. LD_LIBRARY_PATH="?"
  243. 'ld' uses this colon-separated list to find libraries.
  244. LDFLAGS="?"
  245. Pass these flags when linking.
  246. PATH="?"
  247. 'configure' uses this to find programs.
  248. === Advanced compilation =======================================================
  249. To build only parts of jemalloc, use the following targets:
  250. build_lib_shared
  251. build_lib_static
  252. build_lib
  253. build_doc_html
  254. build_doc_man
  255. build_doc
  256. To install only parts of jemalloc, use the following targets:
  257. install_bin
  258. install_include
  259. install_lib_shared
  260. install_lib_static
  261. install_lib
  262. install_doc_html
  263. install_doc_man
  264. install_doc
  265. To clean up build results to varying degrees, use the following make targets:
  266. clean
  267. distclean
  268. relclean
  269. === Advanced installation ======================================================
  270. Optionally, define make variables when invoking make, including (not
  271. exclusively):
  272. INCLUDEDIR="?"
  273. Use this as the installation prefix for header files.
  274. LIBDIR="?"
  275. Use this as the installation prefix for libraries.
  276. MANDIR="?"
  277. Use this as the installation prefix for man pages.
  278. DESTDIR="?"
  279. Prepend DESTDIR to INCLUDEDIR, LIBDIR, DATADIR, and MANDIR. This is useful
  280. when installing to a different path than was specified via --prefix.
  281. CC="?"
  282. Use this to invoke the C compiler.
  283. CFLAGS="?"
  284. Pass these flags to the compiler.
  285. CPPFLAGS="?"
  286. Pass these flags to the C preprocessor.
  287. LDFLAGS="?"
  288. Pass these flags when linking.
  289. PATH="?"
  290. Use this to search for programs used during configuration and building.
  291. === Development ================================================================
  292. If you intend to make non-trivial changes to jemalloc, use the 'autogen.sh'
  293. script rather than 'configure'. This re-generates 'configure', enables
  294. configuration dependency rules, and enables re-generation of automatically
  295. generated source files.
  296. The build system supports using an object directory separate from the source
  297. tree. For example, you can create an 'obj' directory, and from within that
  298. directory, issue configuration and build commands:
  299. autoconf
  300. mkdir obj
  301. cd obj
  302. ../configure --enable-autogen
  303. make
  304. === Documentation ==============================================================
  305. The manual page is generated in both html and roff formats. Any web browser
  306. can be used to view the html manual. The roff manual page can be formatted
  307. prior to installation via the following command:
  308. nroff -man -t doc/jemalloc.3