Jason Evans | cc00a15 | 2009-06-25 18:06:48 -0700 | [diff] [blame] | 1 | Building and installing jemalloc can be as simple as typing the following while |
| 2 | in the root directory of the source tree: |
| 3 | |
| 4 | ./configure |
| 5 | make |
| 6 | make install |
| 7 | |
| 8 | === Advanced configuration ===================================================== |
| 9 | |
| 10 | The 'configure' script supports numerous options that allow control of which |
| 11 | functionality is enabled, where jemalloc is installed, etc. Optionally, pass |
| 12 | any of the following arguments (not a definitive list) to 'configure': |
| 13 | |
| 14 | --help |
| 15 | Print a definitive list of options. |
| 16 | |
| 17 | --prefix=<install-root-dir> |
| 18 | Set the base directory in which to install. For example: |
| 19 | |
| 20 | ./configure --prefix=/usr/local |
| 21 | |
| 22 | will cause files to be installed into /usr/local/include, /usr/local/lib, |
| 23 | and /usr/local/man. |
| 24 | |
| 25 | --with-rpath=<colon-separated-rpath> |
Jason Evans | 6c8b13b | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 26 | Embed one or more library paths, so that libjemalloc can find the libraries |
| 27 | it is linked to. This works only on ELF-based systems. |
Jason Evans | cc00a15 | 2009-06-25 18:06:48 -0700 | [diff] [blame] | 28 | |
Jason Evans | 90895cf | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 29 | --with-jemalloc-prefix=<prefix> |
| 30 | Prefix all public APIs with <prefix>, so that, for example, malloc() |
| 31 | becomes <prefix>malloc(). This makes it possible to use jemalloc at the |
| 32 | same time as the system allocator. |
| 33 | |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 34 | --with-install-suffix=<suffix> |
| 35 | Append <suffix> to the base name of all installed files, such that multiple |
| 36 | versions of jemalloc can coexist in the same installation directory. For |
| 37 | example, libjemalloc.so.0 becomes libjemalloc<suffix>.so.0. |
| 38 | |
Jason Evans | cc00a15 | 2009-06-25 18:06:48 -0700 | [diff] [blame] | 39 | --enable-debug |
| 40 | Enable assertions and validation code. This incurs a substantial |
| 41 | performance hit, but is very useful during application development. |
| 42 | |
| 43 | --enable-stats |
| 44 | Enable statistics gathering functionality. Use the 'P' option to print |
Jason Evans | 569432c | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 45 | detailed allocation statistics at exit. |
Jason Evans | cc00a15 | 2009-06-25 18:06:48 -0700 | [diff] [blame] | 46 | |
Jason Evans | 6109fe0 | 2010-02-10 10:37:56 -0800 | [diff] [blame] | 47 | --enable-prof |
| 48 | Enable heap profiling and leak detection functionality. Use the 'B', 'F', |
| 49 | 'I', 'L', and 'U' options to control these features. |
| 50 | |
Jason Evans | b27805b | 2010-02-10 18:15:53 -0800 | [diff] [blame^] | 51 | --disable-prof-libgcc |
| 52 | Disable the use of libgcc's backtracing functionality. Ordinarily, libgcc's |
| 53 | backtracing functionality is superior to the alternatives, but it may fail |
| 54 | to capture backtraces on some systems. |
| 55 | |
Jason Evans | 6109fe0 | 2010-02-10 10:37:56 -0800 | [diff] [blame] | 56 | --enable-prof-libunwind |
| 57 | Use the libunwind library (http://www.nongnu.org/libunwind/) for stack |
Jason Evans | b27805b | 2010-02-10 18:15:53 -0800 | [diff] [blame^] | 58 | backtracing. libunwind is quite slow, but it tends to work across a wider |
| 59 | variety of system configurations than the default backtracing code, which is |
| 60 | based on libgcc functionality or gcc intrinsics. |
Jason Evans | 6109fe0 | 2010-02-10 10:37:56 -0800 | [diff] [blame] | 61 | |
Jason Evans | cc00a15 | 2009-06-25 18:06:48 -0700 | [diff] [blame] | 62 | --disable-tiny |
| 63 | Disable tiny (sub-quantum-sized) object support. Technically it is not |
| 64 | legal for a malloc implementation to allocate objects with less than |
| 65 | quantum alignment (8 or 16 bytes, depending on architecture), but in |
Jason Evans | a9b0125 | 2009-06-26 16:34:13 -0700 | [diff] [blame] | 66 | practice it never causes any problems if, for example, 4-byte allocations |
Jason Evans | cc00a15 | 2009-06-25 18:06:48 -0700 | [diff] [blame] | 67 | are 4-byte-aligned. |
| 68 | |
Jason Evans | 84cbbcb | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 69 | --disable-tcache |
| 70 | Disable thread-specific caches for small and medium objects. Objects are |
| 71 | cached and released in bulk, thus reducing the total number of mutex |
| 72 | operations. Use the 'H' and 'G' options to control thread-specific caching. |
Jason Evans | cc00a15 | 2009-06-25 18:06:48 -0700 | [diff] [blame] | 73 | |
Jason Evans | 4201af0 | 2010-01-24 02:53:40 -0800 | [diff] [blame] | 74 | --enable-swap |
| 75 | Enable mmap()ed swap file support. When this feature is built in, it is |
| 76 | possible to specify one or more files that act as backing store. This |
| 77 | effectively allows for per application swap files. |
| 78 | |
Jason Evans | cc00a15 | 2009-06-25 18:06:48 -0700 | [diff] [blame] | 79 | --enable-dss |
| 80 | Enable support for page allocation/deallocation via sbrk(2), in addition to |
| 81 | mmap(2). |
| 82 | |
| 83 | --enable-fill |
| 84 | Enable support for junk/zero filling of memory. Use the 'J' option to |
| 85 | control junk filling, or the 'Z' option to control zero filling. |
| 86 | |
| 87 | --enable-xmalloc |
| 88 | Enable support for optional immediate termination due to out-of-memory |
| 89 | errors, as is commonly implemented by "xmalloc" wrapper function for malloc. |
| 90 | Use the 'X' option to control termination behavior. |
| 91 | |
| 92 | --enable-sysv |
| 93 | Enable support for System V semantics, wherein malloc(0) returns NULL |
| 94 | rather than a minimal allocation. Use the 'V' option to control System V |
| 95 | compatibility. |
| 96 | |
| 97 | --enable-dynamic-page-shift |
| 98 | Under most conditions, the system page size never changes (usually 4KiB or |
| 99 | 8KiB, depending on architecture and configuration), and unless this option |
| 100 | is enabled, jemalloc assumes that page size can safely be determined during |
| 101 | configuration and hard-coded. Enabling dynamic page size determination has |
| 102 | a measurable impact on performance, since the compiler is forced to load |
| 103 | the page size from memory rather than embedding immediate values. |
| 104 | |
| 105 | --disable-lazy-lock |
| 106 | Disable code that wraps pthread_create() to detect when an application |
| 107 | switches from single-threaded to multi-threaded mode, so that it can avoid |
| 108 | mutex locking/unlocking operations while in single-threaded mode. In |
| 109 | practice, this feature usually has little impact on performance unless |
Jason Evans | 84cbbcb | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 110 | thread-specific caching is disabled. |
Jason Evans | cc00a15 | 2009-06-25 18:06:48 -0700 | [diff] [blame] | 111 | |
Jason Evans | 78d815c | 2010-01-17 14:06:20 -0800 | [diff] [blame] | 112 | --disable-tls |
| 113 | Disable thread-local storage (TLS), which allows for fast access to |
| 114 | thread-local variables via the __thread keyword. If TLS is available, |
| 115 | jemalloc uses it for several purposes. Not that disabling TLS implies |
| 116 | --disable-tcache. |
| 117 | |
Jason Evans | cc00a15 | 2009-06-25 18:06:48 -0700 | [diff] [blame] | 118 | The following environment variables (not a definitive list) impact configure's |
| 119 | behavior: |
| 120 | |
| 121 | CFLAGS="?" |
| 122 | Pass these flags to the compiler. You probably shouldn't define this unless |
| 123 | you know what you are doing. (Use EXTRA_CFLAGS instead.) |
| 124 | |
| 125 | EXTRA_CFLAGS="?" |
| 126 | Append these flags to CFLAGS. This makes it possible to add flags such as |
| 127 | -Werror, while allowing the configure script to determine what other flags |
| 128 | are appropriate for the specified configuration. |
| 129 | |
| 130 | The configure script specifically checks whether an optimization flag (-O*) |
| 131 | is specified in EXTRA_CFLAGS, and refrains from specifying an optimization |
| 132 | level if it finds that one has already been specified. |
| 133 | |
| 134 | CPPFLAGS="?" |
| 135 | Pass these flags to the C preprocessor. Note that CFLAGS is not passed to |
| 136 | 'cpp' when 'configure' is looking for include files, so you must use |
| 137 | CPPFLAGS instead if you need to help 'configure' find header files. |
| 138 | |
| 139 | LD_LIBRARY_PATH="?" |
| 140 | 'ld' uses this colon-separated list to find libraries. |
| 141 | |
| 142 | LDFLAGS="?" |
| 143 | Pass these flags when linking. |
| 144 | |
| 145 | PATH="?" |
| 146 | 'configure' uses this to find programs. |
| 147 | |
| 148 | === Advanced compilation ======================================================= |
| 149 | |
| 150 | To run integrated regression tests, type: |
| 151 | |
| 152 | make check |
| 153 | |
| 154 | To clean up build results to varying degrees, use the following make targets: |
| 155 | |
| 156 | clean |
| 157 | distclean |
| 158 | relclean |
| 159 | |
| 160 | === Advanced installation ====================================================== |
| 161 | |
| 162 | Optionally, define make variables when invoking make, including (not |
| 163 | exclusively): |
| 164 | |
| 165 | INCLUDEDIR="?" |
| 166 | Use this as the installation prefix for header files. |
| 167 | |
| 168 | LIBDIR="?" |
| 169 | Use this as the installation prefix for libraries. |
| 170 | |
| 171 | MANDIR="?" |
| 172 | Use this as the installation prefix for man pages. |
| 173 | |
| 174 | CC="?" |
| 175 | Use this to invoke the C compiler. |
| 176 | |
| 177 | CFLAGS="?" |
| 178 | Pass these flags to the compiler. |
| 179 | |
| 180 | CPPFLAGS="?" |
| 181 | Pass these flags to the C preprocessor. |
| 182 | |
| 183 | LDFLAGS="?" |
| 184 | Pass these flags when linking. |
| 185 | |
| 186 | PATH="?" |
| 187 | Use this to search for programs used during configuration and building. |
| 188 | |
| 189 | === Development ================================================================ |
| 190 | |
| 191 | If you intend to make non-trivial changes to jemalloc, use the 'autogen.sh' |
| 192 | script rather than 'configure'. This re-generates 'configure', enables |
| 193 | configuration dependency rules, and enables re-generation of automatically |
| 194 | generated source files. |
| 195 | |
| 196 | The build system supports using an object directory separate from the source |
| 197 | tree. For example, you can create an 'obj' directory, and from within that |
| 198 | directory, issue configuration and build commands: |
| 199 | |
| 200 | autoconf |
| 201 | mkdir obj |
| 202 | cd obj |
| 203 | ../configure --enable-autogen |
| 204 | make |