blob: c02e2520a2b66c729f8c023683c6cd7ddf360e4c [file] [log] [blame]
Jason Evanscc00a152009-06-25 18:06:48 -07001Building and installing jemalloc can be as simple as typing the following while
2in the root directory of the source tree:
3
4 ./configure
5 make
6 make install
7
8=== Advanced configuration =====================================================
9
10The 'configure' script supports numerous options that allow control of which
11functionality is enabled, where jemalloc is installed, etc. Optionally, pass
12any 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 Evans6c8b13b2009-12-29 00:09:15 -080026 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 Evanscc00a152009-06-25 18:06:48 -070028
Jason Evans90895cf2009-12-29 00:09:15 -080029--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 Evansb0fd5012010-01-17 01:49:20 -080034--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 Evanscc00a152009-06-25 18:06:48 -070039--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 Evans569432c2009-12-29 00:09:15 -080045 detailed allocation statistics at exit.
Jason Evanscc00a152009-06-25 18:06:48 -070046
Jason Evans6109fe02010-02-10 10:37:56 -080047--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 Evansb27805b2010-02-10 18:15:53 -080051--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 Evans6109fe02010-02-10 10:37:56 -080056--enable-prof-libunwind
57 Use the libunwind library (http://www.nongnu.org/libunwind/) for stack
Jason Evansb27805b2010-02-10 18:15:53 -080058 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 Evans6109fe02010-02-10 10:37:56 -080061
Jason Evanscc00a152009-06-25 18:06:48 -070062--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 Evansa9b01252009-06-26 16:34:13 -070066 practice it never causes any problems if, for example, 4-byte allocations
Jason Evanscc00a152009-06-25 18:06:48 -070067 are 4-byte-aligned.
68
Jason Evans84cbbcb2009-12-29 00:09:15 -080069--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 Evanscc00a152009-06-25 18:06:48 -070073
Jason Evans4201af02010-01-24 02:53:40 -080074--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 Evanscc00a152009-06-25 18:06:48 -070079--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 Evans84cbbcb2009-12-29 00:09:15 -0800110 thread-specific caching is disabled.
Jason Evanscc00a152009-06-25 18:06:48 -0700111
Jason Evans78d815c2010-01-17 14:06:20 -0800112--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 Evanscc00a152009-06-25 18:06:48 -0700118The following environment variables (not a definitive list) impact configure's
119behavior:
120
121CFLAGS="?"
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
125EXTRA_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
134CPPFLAGS="?"
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
139LD_LIBRARY_PATH="?"
140 'ld' uses this colon-separated list to find libraries.
141
142LDFLAGS="?"
143 Pass these flags when linking.
144
145PATH="?"
146 'configure' uses this to find programs.
147
148=== Advanced compilation =======================================================
149
150To run integrated regression tests, type:
151
152 make check
153
154To clean up build results to varying degrees, use the following make targets:
155
156 clean
157 distclean
158 relclean
159
160=== Advanced installation ======================================================
161
162Optionally, define make variables when invoking make, including (not
163exclusively):
164
165INCLUDEDIR="?"
166 Use this as the installation prefix for header files.
167
168LIBDIR="?"
169 Use this as the installation prefix for libraries.
170
171MANDIR="?"
172 Use this as the installation prefix for man pages.
173
174CC="?"
175 Use this to invoke the C compiler.
176
177CFLAGS="?"
178 Pass these flags to the compiler.
179
180CPPFLAGS="?"
181 Pass these flags to the C preprocessor.
182
183LDFLAGS="?"
184 Pass these flags when linking.
185
186PATH="?"
187 Use this to search for programs used during configuration and building.
188
189=== Development ================================================================
190
191If you intend to make non-trivial changes to jemalloc, use the 'autogen.sh'
192script rather than 'configure'. This re-generates 'configure', enables
193configuration dependency rules, and enables re-generation of automatically
194generated source files.
195
196The build system supports using an object directory separate from the source
197tree. For example, you can create an 'obj' directory, and from within that
198directory, issue configuration and build commands:
199
200 autoconf
201 mkdir obj
202 cd obj
203 ../configure --enable-autogen
204 make