blob: e8d0b7ab06ecf0cb36996ec852d4c14c1b3cb51a [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 Evansca6bd4f2010-03-02 14:12:58 -080062--with-static-libunwind=<libunwind.a>
63 Statically link against the specified libunwind.a rather than dynamically
64 linking with -lunwind.
65
Jason Evanscc00a152009-06-25 18:06:48 -070066--disable-tiny
67 Disable tiny (sub-quantum-sized) object support. Technically it is not
68 legal for a malloc implementation to allocate objects with less than
69 quantum alignment (8 or 16 bytes, depending on architecture), but in
Jason Evansa9b01252009-06-26 16:34:13 -070070 practice it never causes any problems if, for example, 4-byte allocations
Jason Evanscc00a152009-06-25 18:06:48 -070071 are 4-byte-aligned.
72
Jason Evans84cbbcb2009-12-29 00:09:15 -080073--disable-tcache
74 Disable thread-specific caches for small and medium objects. Objects are
75 cached and released in bulk, thus reducing the total number of mutex
76 operations. Use the 'H' and 'G' options to control thread-specific caching.
Jason Evanscc00a152009-06-25 18:06:48 -070077
Jason Evans4201af02010-01-24 02:53:40 -080078--enable-swap
79 Enable mmap()ed swap file support. When this feature is built in, it is
80 possible to specify one or more files that act as backing store. This
81 effectively allows for per application swap files.
82
Jason Evanscc00a152009-06-25 18:06:48 -070083--enable-dss
84 Enable support for page allocation/deallocation via sbrk(2), in addition to
85 mmap(2).
86
87--enable-fill
88 Enable support for junk/zero filling of memory. Use the 'J' option to
89 control junk filling, or the 'Z' option to control zero filling.
90
91--enable-xmalloc
92 Enable support for optional immediate termination due to out-of-memory
93 errors, as is commonly implemented by "xmalloc" wrapper function for malloc.
94 Use the 'X' option to control termination behavior.
95
96--enable-sysv
97 Enable support for System V semantics, wherein malloc(0) returns NULL
98 rather than a minimal allocation. Use the 'V' option to control System V
99 compatibility.
100
101--enable-dynamic-page-shift
102 Under most conditions, the system page size never changes (usually 4KiB or
103 8KiB, depending on architecture and configuration), and unless this option
104 is enabled, jemalloc assumes that page size can safely be determined during
105 configuration and hard-coded. Enabling dynamic page size determination has
106 a measurable impact on performance, since the compiler is forced to load
107 the page size from memory rather than embedding immediate values.
108
109--disable-lazy-lock
110 Disable code that wraps pthread_create() to detect when an application
111 switches from single-threaded to multi-threaded mode, so that it can avoid
112 mutex locking/unlocking operations while in single-threaded mode. In
113 practice, this feature usually has little impact on performance unless
Jason Evans84cbbcb2009-12-29 00:09:15 -0800114 thread-specific caching is disabled.
Jason Evanscc00a152009-06-25 18:06:48 -0700115
Jason Evans78d815c2010-01-17 14:06:20 -0800116--disable-tls
117 Disable thread-local storage (TLS), which allows for fast access to
118 thread-local variables via the __thread keyword. If TLS is available,
119 jemalloc uses it for several purposes. Not that disabling TLS implies
120 --disable-tcache.
121
Jason Evanscc00a152009-06-25 18:06:48 -0700122The following environment variables (not a definitive list) impact configure's
123behavior:
124
125CFLAGS="?"
126 Pass these flags to the compiler. You probably shouldn't define this unless
127 you know what you are doing. (Use EXTRA_CFLAGS instead.)
128
129EXTRA_CFLAGS="?"
130 Append these flags to CFLAGS. This makes it possible to add flags such as
131 -Werror, while allowing the configure script to determine what other flags
132 are appropriate for the specified configuration.
133
134 The configure script specifically checks whether an optimization flag (-O*)
135 is specified in EXTRA_CFLAGS, and refrains from specifying an optimization
136 level if it finds that one has already been specified.
137
138CPPFLAGS="?"
139 Pass these flags to the C preprocessor. Note that CFLAGS is not passed to
140 'cpp' when 'configure' is looking for include files, so you must use
141 CPPFLAGS instead if you need to help 'configure' find header files.
142
143LD_LIBRARY_PATH="?"
144 'ld' uses this colon-separated list to find libraries.
145
146LDFLAGS="?"
147 Pass these flags when linking.
148
149PATH="?"
150 'configure' uses this to find programs.
151
152=== Advanced compilation =======================================================
153
154To run integrated regression tests, type:
155
156 make check
157
158To clean up build results to varying degrees, use the following make targets:
159
160 clean
161 distclean
162 relclean
163
164=== Advanced installation ======================================================
165
166Optionally, define make variables when invoking make, including (not
167exclusively):
168
169INCLUDEDIR="?"
170 Use this as the installation prefix for header files.
171
172LIBDIR="?"
173 Use this as the installation prefix for libraries.
174
175MANDIR="?"
176 Use this as the installation prefix for man pages.
177
178CC="?"
179 Use this to invoke the C compiler.
180
181CFLAGS="?"
182 Pass these flags to the compiler.
183
184CPPFLAGS="?"
185 Pass these flags to the C preprocessor.
186
187LDFLAGS="?"
188 Pass these flags when linking.
189
190PATH="?"
191 Use this to search for programs used during configuration and building.
192
193=== Development ================================================================
194
195If you intend to make non-trivial changes to jemalloc, use the 'autogen.sh'
196script rather than 'configure'. This re-generates 'configure', enables
197configuration dependency rules, and enables re-generation of automatically
198generated source files.
199
200The build system supports using an object directory separate from the source
201tree. For example, you can create an 'obj' directory, and from within that
202directory, issue configuration and build commands:
203
204 autoconf
205 mkdir obj
206 cd obj
207 ../configure --enable-autogen
208 make