xref: /freebsd/contrib/jemalloc/INSTALL.md (revision c43cad87172039ccf38172129c79755ea79e6102)
1*c43cad87SWarner Losh<<<<<<< HEAD
2*c43cad87SWarner LoshBuilding and installing a packaged release of jemalloc can be as simple as
3*c43cad87SWarner Loshtyping the following while in the root directory of the source tree:
4*c43cad87SWarner Losh
5*c43cad87SWarner Losh    ./configure
6*c43cad87SWarner Losh    make
7*c43cad87SWarner Losh    make install
8*c43cad87SWarner Losh
9*c43cad87SWarner LoshIf building from unpackaged developer sources, the simplest command sequence
10*c43cad87SWarner Loshthat might work is:
11*c43cad87SWarner Losh
12*c43cad87SWarner Losh    ./autogen.sh
13*c43cad87SWarner Losh    make
14*c43cad87SWarner Losh    make install
15*c43cad87SWarner Losh
16*c43cad87SWarner LoshYou can uninstall the installed build artifacts like this:
17*c43cad87SWarner Losh
18*c43cad87SWarner Losh    make uninstall
19*c43cad87SWarner Losh
20*c43cad87SWarner LoshNotes:
21*c43cad87SWarner Losh - "autoconf" needs to be installed
22*c43cad87SWarner Losh - Documentation is built by the default target only when xsltproc is
23*c43cad87SWarner Loshavailable.  Build will warn but not stop if the dependency is missing.
24*c43cad87SWarner Losh
25*c43cad87SWarner Losh
26*c43cad87SWarner Losh## Advanced configuration
27*c43cad87SWarner Losh
28*c43cad87SWarner LoshThe 'configure' script supports numerous options that allow control of which
29*c43cad87SWarner Loshfunctionality is enabled, where jemalloc is installed, etc.  Optionally, pass
30*c43cad87SWarner Loshany of the following arguments (not a definitive list) to 'configure':
31*c43cad87SWarner Losh
32*c43cad87SWarner Losh* `--help`
33*c43cad87SWarner Losh
34*c43cad87SWarner Losh    Print a definitive list of options.
35*c43cad87SWarner Losh
36*c43cad87SWarner Losh* `--prefix=<install-root-dir>`
37*c43cad87SWarner Losh
38*c43cad87SWarner Losh    Set the base directory in which to install.  For example:
39*c43cad87SWarner Losh
40*c43cad87SWarner Losh        ./configure --prefix=/usr/local
41*c43cad87SWarner Losh
42*c43cad87SWarner Losh    will cause files to be installed into /usr/local/include, /usr/local/lib,
43*c43cad87SWarner Losh    and /usr/local/man.
44*c43cad87SWarner Losh
45*c43cad87SWarner Losh* `--with-version=(<major>.<minor>.<bugfix>-<nrev>-g<gid>|VERSION)`
46*c43cad87SWarner Losh
47*c43cad87SWarner Losh    The VERSION file is mandatory for successful configuration, and the
48*c43cad87SWarner Losh    following steps are taken to assure its presence:
49*c43cad87SWarner Losh    1) If --with-version=<major>.<minor>.<bugfix>-<nrev>-g<gid> is specified,
50*c43cad87SWarner Losh       generate VERSION using the specified value.
51*c43cad87SWarner Losh    2) If --with-version is not specified in either form and the source
52*c43cad87SWarner Losh       directory is inside a git repository, try to generate VERSION via 'git
53*c43cad87SWarner Losh       describe' invocations that pattern-match release tags.
54*c43cad87SWarner Losh    3) If VERSION is missing, generate it with a bogus version:
55*c43cad87SWarner Losh       0.0.0-0-g0000000000000000000000000000000000000000
56*c43cad87SWarner Losh
57*c43cad87SWarner Losh    Note that --with-version=VERSION bypasses (1) and (2), which simplifies
58*c43cad87SWarner Losh    VERSION configuration when embedding a jemalloc release into another
59*c43cad87SWarner Losh    project's git repository.
60*c43cad87SWarner Losh
61*c43cad87SWarner Losh* `--with-rpath=<colon-separated-rpath>`
62*c43cad87SWarner Losh
63*c43cad87SWarner Losh    Embed one or more library paths, so that libjemalloc can find the libraries
64*c43cad87SWarner Losh    it is linked to.  This works only on ELF-based systems.
65*c43cad87SWarner Losh
66*c43cad87SWarner Losh* `--with-mangling=<map>`
67*c43cad87SWarner Losh
68*c43cad87SWarner Losh    Mangle public symbols specified in <map> which is a comma-separated list of
69*c43cad87SWarner Losh    name:mangled pairs.
70*c43cad87SWarner Losh
71*c43cad87SWarner Losh    For example, to use ld's --wrap option as an alternative method for
72*c43cad87SWarner Losh    overriding libc's malloc implementation, specify something like:
73*c43cad87SWarner Losh
74*c43cad87SWarner Losh      --with-mangling=malloc:__wrap_malloc,free:__wrap_free[...]
75*c43cad87SWarner Losh
76*c43cad87SWarner Losh    Note that mangling happens prior to application of the prefix specified by
77*c43cad87SWarner Losh    --with-jemalloc-prefix, and mangled symbols are then ignored when applying
78*c43cad87SWarner Losh    the prefix.
79*c43cad87SWarner Losh
80*c43cad87SWarner Losh* `--with-jemalloc-prefix=<prefix>`
81*c43cad87SWarner Losh
82*c43cad87SWarner Losh    Prefix all public APIs with <prefix>.  For example, if <prefix> is
83*c43cad87SWarner Losh    "prefix_", API changes like the following occur:
84*c43cad87SWarner Losh
85*c43cad87SWarner Losh      malloc()         --> prefix_malloc()
86*c43cad87SWarner Losh      malloc_conf      --> prefix_malloc_conf
87*c43cad87SWarner Losh      /etc/malloc.conf --> /etc/prefix_malloc.conf
88*c43cad87SWarner Losh      MALLOC_CONF      --> PREFIX_MALLOC_CONF
89*c43cad87SWarner Losh
90*c43cad87SWarner Losh    This makes it possible to use jemalloc at the same time as the system
91*c43cad87SWarner Losh    allocator, or even to use multiple copies of jemalloc simultaneously.
92*c43cad87SWarner Losh
93*c43cad87SWarner Losh    By default, the prefix is "", except on OS X, where it is "je_".  On OS X,
94*c43cad87SWarner Losh    jemalloc overlays the default malloc zone, but makes no attempt to actually
95*c43cad87SWarner Losh    replace the "malloc", "calloc", etc. symbols.
96*c43cad87SWarner Losh
97*c43cad87SWarner Losh* `--without-export`
98*c43cad87SWarner Losh
99*c43cad87SWarner Losh    Don't export public APIs.  This can be useful when building jemalloc as a
100*c43cad87SWarner Losh    static library, or to avoid exporting public APIs when using the zone
101*c43cad87SWarner Losh    allocator on OSX.
102*c43cad87SWarner Losh
103*c43cad87SWarner Losh* `--with-private-namespace=<prefix>`
104*c43cad87SWarner Losh
105*c43cad87SWarner Losh    Prefix all library-private APIs with <prefix>je_.  For shared libraries,
106*c43cad87SWarner Losh    symbol visibility mechanisms prevent these symbols from being exported, but
107*c43cad87SWarner Losh    for static libraries, naming collisions are a real possibility.  By
108*c43cad87SWarner Losh    default, <prefix> is empty, which results in a symbol prefix of je_ .
109*c43cad87SWarner Losh
110*c43cad87SWarner Losh* `--with-install-suffix=<suffix>`
111*c43cad87SWarner Losh
112*c43cad87SWarner Losh    Append <suffix> to the base name of all installed files, such that multiple
113*c43cad87SWarner Losh    versions of jemalloc can coexist in the same installation directory.  For
114*c43cad87SWarner Losh    example, libjemalloc.so.0 becomes libjemalloc<suffix>.so.0.
115*c43cad87SWarner Losh
116*c43cad87SWarner Losh* `--with-malloc-conf=<malloc_conf>`
117*c43cad87SWarner Losh
118*c43cad87SWarner Losh    Embed `<malloc_conf>` as a run-time options string that is processed prior to
119*c43cad87SWarner Losh    the malloc_conf global variable, the /etc/malloc.conf symlink, and the
120*c43cad87SWarner Losh    MALLOC_CONF environment variable.  For example, to change the default decay
121*c43cad87SWarner Losh    time to 30 seconds:
122*c43cad87SWarner Losh
123*c43cad87SWarner Losh      --with-malloc-conf=decay_ms:30000
124*c43cad87SWarner Losh
125*c43cad87SWarner Losh* `--enable-debug`
126*c43cad87SWarner Losh
127*c43cad87SWarner Losh    Enable assertions and validation code.  This incurs a substantial
128*c43cad87SWarner Losh    performance hit, but is very useful during application development.
129*c43cad87SWarner Losh
130*c43cad87SWarner Losh* `--disable-stats`
131*c43cad87SWarner Losh
132*c43cad87SWarner Losh    Disable statistics gathering functionality.  See the "opt.stats_print"
133*c43cad87SWarner Losh    option documentation for usage details.
134*c43cad87SWarner Losh
135*c43cad87SWarner Losh* `--enable-prof`
136*c43cad87SWarner Losh
137*c43cad87SWarner Losh    Enable heap profiling and leak detection functionality.  See the "opt.prof"
138*c43cad87SWarner Losh    option documentation for usage details.  When enabled, there are several
139*c43cad87SWarner Losh    approaches to backtracing, and the configure script chooses the first one
140*c43cad87SWarner Losh    in the following list that appears to function correctly:
141*c43cad87SWarner Losh
142*c43cad87SWarner Losh    + libunwind      (requires --enable-prof-libunwind)
143*c43cad87SWarner Losh    + libgcc         (unless --disable-prof-libgcc)
144*c43cad87SWarner Losh    + gcc intrinsics (unless --disable-prof-gcc)
145*c43cad87SWarner Losh
146*c43cad87SWarner Losh* `--enable-prof-libunwind`
147*c43cad87SWarner Losh
148*c43cad87SWarner Losh    Use the libunwind library (http://www.nongnu.org/libunwind/) for stack
149*c43cad87SWarner Losh    backtracing.
150*c43cad87SWarner Losh
151*c43cad87SWarner Losh* `--disable-prof-libgcc`
152*c43cad87SWarner Losh
153*c43cad87SWarner Losh    Disable the use of libgcc's backtracing functionality.
154*c43cad87SWarner Losh
155*c43cad87SWarner Losh* `--disable-prof-gcc`
156*c43cad87SWarner Losh
157*c43cad87SWarner Losh    Disable the use of gcc intrinsics for backtracing.
158*c43cad87SWarner Losh
159*c43cad87SWarner Losh* `--with-static-libunwind=<libunwind.a>`
160*c43cad87SWarner Losh
161*c43cad87SWarner Losh    Statically link against the specified libunwind.a rather than dynamically
162*c43cad87SWarner Losh    linking with -lunwind.
163*c43cad87SWarner Losh
164*c43cad87SWarner Losh* `--disable-fill`
165*c43cad87SWarner Losh
166*c43cad87SWarner Losh    Disable support for junk/zero filling of memory.  See the "opt.junk" and
167*c43cad87SWarner Losh    "opt.zero" option documentation for usage details.
168*c43cad87SWarner Losh
169*c43cad87SWarner Losh* `--disable-zone-allocator`
170*c43cad87SWarner Losh
171*c43cad87SWarner Losh    Disable zone allocator for Darwin.  This means jemalloc won't be hooked as
172*c43cad87SWarner Losh    the default allocator on OSX/iOS.
173*c43cad87SWarner Losh
174*c43cad87SWarner Losh* `--enable-utrace`
175*c43cad87SWarner Losh
176*c43cad87SWarner Losh    Enable utrace(2)-based allocation tracing.  This feature is not broadly
177*c43cad87SWarner Losh    portable (FreeBSD has it, but Linux and OS X do not).
178*c43cad87SWarner Losh
179*c43cad87SWarner Losh* `--enable-xmalloc`
180*c43cad87SWarner Losh
181*c43cad87SWarner Losh    Enable support for optional immediate termination due to out-of-memory
182*c43cad87SWarner Losh    errors, as is commonly implemented by "xmalloc" wrapper function for malloc.
183*c43cad87SWarner Losh    See the "opt.xmalloc" option documentation for usage details.
184*c43cad87SWarner Losh
185*c43cad87SWarner Losh* `--enable-lazy-lock`
186*c43cad87SWarner Losh
187*c43cad87SWarner Losh    Enable code that wraps pthread_create() to detect when an application
188*c43cad87SWarner Losh    switches from single-threaded to multi-threaded mode, so that it can avoid
189*c43cad87SWarner Losh    mutex locking/unlocking operations while in single-threaded mode.  In
190*c43cad87SWarner Losh    practice, this feature usually has little impact on performance unless
191*c43cad87SWarner Losh    thread-specific caching is disabled.
192*c43cad87SWarner Losh
193*c43cad87SWarner Losh* `--disable-cache-oblivious`
194*c43cad87SWarner Losh
195*c43cad87SWarner Losh    Disable cache-oblivious large allocation alignment by default, for large
196*c43cad87SWarner Losh    allocation requests with no alignment constraints.  If this feature is
197*c43cad87SWarner Losh    disabled, all large allocations are page-aligned as an implementation
198*c43cad87SWarner Losh    artifact, which can severely harm CPU cache utilization.  However, the
199*c43cad87SWarner Losh    cache-oblivious layout comes at the cost of one extra page per large
200*c43cad87SWarner Losh    allocation, which in the most extreme case increases physical memory usage
201*c43cad87SWarner Losh    for the 16 KiB size class to 20 KiB.
202*c43cad87SWarner Losh
203*c43cad87SWarner Losh* `--disable-syscall`
204*c43cad87SWarner Losh
205*c43cad87SWarner Losh    Disable use of syscall(2) rather than {open,read,write,close}(2).  This is
206*c43cad87SWarner Losh    intended as a workaround for systems that place security limitations on
207*c43cad87SWarner Losh    syscall(2).
208*c43cad87SWarner Losh
209*c43cad87SWarner Losh* `--disable-cxx`
210*c43cad87SWarner Losh
211*c43cad87SWarner Losh    Disable C++ integration.  This will cause new and delete operator
212*c43cad87SWarner Losh    implementations to be omitted.
213*c43cad87SWarner Losh
214*c43cad87SWarner Losh* `--with-xslroot=<path>`
215*c43cad87SWarner Losh
216*c43cad87SWarner Losh    Specify where to find DocBook XSL stylesheets when building the
217*c43cad87SWarner Losh    documentation.
218*c43cad87SWarner Losh
219*c43cad87SWarner Losh* `--with-lg-page=<lg-page>`
220*c43cad87SWarner Losh
221*c43cad87SWarner Losh    Specify the base 2 log of the allocator page size, which must in turn be at
222*c43cad87SWarner Losh    least as large as the system page size.  By default the configure script
223*c43cad87SWarner Losh    determines the host's page size and sets the allocator page size equal to
224*c43cad87SWarner Losh    the system page size, so this option need not be specified unless the
225*c43cad87SWarner Losh    system page size may change between configuration and execution, e.g. when
226*c43cad87SWarner Losh    cross compiling.
227*c43cad87SWarner Losh
228*c43cad87SWarner Losh* `--with-lg-hugepage=<lg-hugepage>`
229*c43cad87SWarner Losh
230*c43cad87SWarner Losh    Specify the base 2 log of the system huge page size.  This option is useful
231*c43cad87SWarner Losh    when cross compiling, or when overriding the default for systems that do
232*c43cad87SWarner Losh    not explicitly support huge pages.
233*c43cad87SWarner Losh
234*c43cad87SWarner Losh* `--with-lg-quantum=<lg-quantum>`
235*c43cad87SWarner Losh
236*c43cad87SWarner Losh    Specify the base 2 log of the minimum allocation alignment.  jemalloc needs
237*c43cad87SWarner Losh    to know the minimum alignment that meets the following C standard
238*c43cad87SWarner Losh    requirement (quoted from the April 12, 2011 draft of the C11 standard):
239*c43cad87SWarner Losh
240*c43cad87SWarner Losh    >  The pointer returned if the allocation succeeds is suitably aligned so
241*c43cad87SWarner Losh      that it may be assigned to a pointer to any type of object with a
242*c43cad87SWarner Losh      fundamental alignment requirement and then used to access such an object
243*c43cad87SWarner Losh      or an array of such objects in the space allocated [...]
244*c43cad87SWarner Losh
245*c43cad87SWarner Losh    This setting is architecture-specific, and although jemalloc includes known
246*c43cad87SWarner Losh    safe values for the most commonly used modern architectures, there is a
247*c43cad87SWarner Losh    wrinkle related to GNU libc (glibc) that may impact your choice of
248*c43cad87SWarner Losh    <lg-quantum>.  On most modern architectures, this mandates 16-byte
249*c43cad87SWarner Losh    alignment (<lg-quantum>=4), but the glibc developers chose not to meet this
250*c43cad87SWarner Losh    requirement for performance reasons.  An old discussion can be found at
251*c43cad87SWarner Losh    <https://sourceware.org/bugzilla/show_bug.cgi?id=206> .  Unlike glibc,
252*c43cad87SWarner Losh    jemalloc does follow the C standard by default (caveat: jemalloc
253*c43cad87SWarner Losh    technically cheats for size classes smaller than the quantum), but the fact
254*c43cad87SWarner Losh    that Linux systems already work around this allocator noncompliance means
255*c43cad87SWarner Losh    that it is generally safe in practice to let jemalloc's minimum alignment
256*c43cad87SWarner Losh    follow glibc's lead.  If you specify `--with-lg-quantum=3` during
257*c43cad87SWarner Losh    configuration, jemalloc will provide additional size classes that are not
258*c43cad87SWarner Losh    16-byte-aligned (24, 40, and 56).
259*c43cad87SWarner Losh
260*c43cad87SWarner Losh* `--with-lg-vaddr=<lg-vaddr>`
261*c43cad87SWarner Losh
262*c43cad87SWarner Losh    Specify the number of significant virtual address bits.  By default, the
263*c43cad87SWarner Losh    configure script attempts to detect virtual address size on those platforms
264*c43cad87SWarner Losh    where it knows how, and picks a default otherwise.  This option may be
265*c43cad87SWarner Losh    useful when cross-compiling.
266*c43cad87SWarner Losh
267*c43cad87SWarner Losh* `--disable-initial-exec-tls`
268*c43cad87SWarner Losh
269*c43cad87SWarner Losh    Disable the initial-exec TLS model for jemalloc's internal thread-local
270*c43cad87SWarner Losh    storage (on those platforms that support explicit settings).  This can allow
271*c43cad87SWarner Losh    jemalloc to be dynamically loaded after program startup (e.g. using dlopen).
272*c43cad87SWarner Losh    Note that in this case, there will be two malloc implementations operating
273*c43cad87SWarner Losh    in the same process, which will almost certainly result in confusing runtime
274*c43cad87SWarner Losh    crashes if pointers leak from one implementation to the other.
275*c43cad87SWarner Losh
276*c43cad87SWarner Losh* `--disable-libdl`
277*c43cad87SWarner Losh
278*c43cad87SWarner Losh    Disable the usage of libdl, namely dlsym(3) which is required by the lazy
279*c43cad87SWarner Losh    lock option.  This can allow building static binaries.
280*c43cad87SWarner Losh
281*c43cad87SWarner LoshThe following environment variables (not a definitive list) impact configure's
282*c43cad87SWarner Loshbehavior:
283*c43cad87SWarner Losh
284*c43cad87SWarner Losh* `CFLAGS="?"`
285*c43cad87SWarner Losh* `CXXFLAGS="?"`
286*c43cad87SWarner Losh
287*c43cad87SWarner Losh    Pass these flags to the C/C++ compiler.  Any flags set by the configure
288*c43cad87SWarner Losh    script are prepended, which means explicitly set flags generally take
289*c43cad87SWarner Losh    precedence.  Take care when specifying flags such as -Werror, because
290*c43cad87SWarner Losh    configure tests may be affected in undesirable ways.
291*c43cad87SWarner Losh
292*c43cad87SWarner Losh* `EXTRA_CFLAGS="?"`
293*c43cad87SWarner Losh* `EXTRA_CXXFLAGS="?"`
294*c43cad87SWarner Losh
295*c43cad87SWarner Losh    Append these flags to CFLAGS/CXXFLAGS, without passing them to the
296*c43cad87SWarner Losh    compiler(s) during configuration.  This makes it possible to add flags such
297*c43cad87SWarner Losh    as -Werror, while allowing the configure script to determine what other
298*c43cad87SWarner Losh    flags are appropriate for the specified configuration.
299*c43cad87SWarner Losh
300*c43cad87SWarner Losh* `CPPFLAGS="?"`
301*c43cad87SWarner Losh
302*c43cad87SWarner Losh    Pass these flags to the C preprocessor.  Note that CFLAGS is not passed to
303*c43cad87SWarner Losh    'cpp' when 'configure' is looking for include files, so you must use
304*c43cad87SWarner Losh    CPPFLAGS instead if you need to help 'configure' find header files.
305*c43cad87SWarner Losh
306*c43cad87SWarner Losh* `LD_LIBRARY_PATH="?"`
307*c43cad87SWarner Losh
308*c43cad87SWarner Losh    'ld' uses this colon-separated list to find libraries.
309*c43cad87SWarner Losh
310*c43cad87SWarner Losh* `LDFLAGS="?"`
311*c43cad87SWarner Losh
312*c43cad87SWarner Losh    Pass these flags when linking.
313*c43cad87SWarner Losh
314*c43cad87SWarner Losh* `PATH="?"`
315*c43cad87SWarner Losh
316*c43cad87SWarner Losh    'configure' uses this to find programs.
317*c43cad87SWarner Losh
318*c43cad87SWarner LoshIn some cases it may be necessary to work around configuration results that do
319*c43cad87SWarner Loshnot match reality.  For example, Linux 4.5 added support for the MADV_FREE flag
320*c43cad87SWarner Loshto madvise(2), which can cause problems if building on a host with MADV_FREE
321*c43cad87SWarner Loshsupport and deploying to a target without.  To work around this, use a cache
322*c43cad87SWarner Loshfile to override the relevant configuration variable defined in configure.ac,
323*c43cad87SWarner Loshe.g.:
324*c43cad87SWarner Losh
325*c43cad87SWarner Losh    echo "je_cv_madv_free=no" > config.cache && ./configure -C
326*c43cad87SWarner Losh
327*c43cad87SWarner Losh
328*c43cad87SWarner Losh## Advanced compilation
329*c43cad87SWarner Losh
330*c43cad87SWarner LoshTo build only parts of jemalloc, use the following targets:
331*c43cad87SWarner Losh
332*c43cad87SWarner Losh    build_lib_shared
333*c43cad87SWarner Losh    build_lib_static
334*c43cad87SWarner Losh    build_lib
335*c43cad87SWarner Losh    build_doc_html
336*c43cad87SWarner Losh    build_doc_man
337*c43cad87SWarner Losh    build_doc
338*c43cad87SWarner Losh
339*c43cad87SWarner LoshTo install only parts of jemalloc, use the following targets:
340*c43cad87SWarner Losh
341*c43cad87SWarner Losh    install_bin
342*c43cad87SWarner Losh    install_include
343*c43cad87SWarner Losh    install_lib_shared
344*c43cad87SWarner Losh    install_lib_static
345*c43cad87SWarner Losh    install_lib_pc
346*c43cad87SWarner Losh    install_lib
347*c43cad87SWarner Losh    install_doc_html
348*c43cad87SWarner Losh    install_doc_man
349*c43cad87SWarner Losh    install_doc
350*c43cad87SWarner Losh
351*c43cad87SWarner LoshTo clean up build results to varying degrees, use the following make targets:
352*c43cad87SWarner Losh
353*c43cad87SWarner Losh    clean
354*c43cad87SWarner Losh    distclean
355*c43cad87SWarner Losh    relclean
356*c43cad87SWarner Losh
357*c43cad87SWarner Losh
358*c43cad87SWarner Losh## Advanced installation
359*c43cad87SWarner Losh
360*c43cad87SWarner LoshOptionally, define make variables when invoking make, including (not
361*c43cad87SWarner Loshexclusively):
362*c43cad87SWarner Losh
363*c43cad87SWarner Losh* `INCLUDEDIR="?"`
364*c43cad87SWarner Losh
365*c43cad87SWarner Losh    Use this as the installation prefix for header files.
366*c43cad87SWarner Losh
367*c43cad87SWarner Losh* `LIBDIR="?"`
368*c43cad87SWarner Losh
369*c43cad87SWarner Losh    Use this as the installation prefix for libraries.
370*c43cad87SWarner Losh
371*c43cad87SWarner Losh* `MANDIR="?"`
372*c43cad87SWarner Losh
373*c43cad87SWarner Losh    Use this as the installation prefix for man pages.
374*c43cad87SWarner Losh
375*c43cad87SWarner Losh* `DESTDIR="?"`
376*c43cad87SWarner Losh
377*c43cad87SWarner Losh    Prepend DESTDIR to INCLUDEDIR, LIBDIR, DATADIR, and MANDIR.  This is useful
378*c43cad87SWarner Losh    when installing to a different path than was specified via --prefix.
379*c43cad87SWarner Losh
380*c43cad87SWarner Losh* `CC="?"`
381*c43cad87SWarner Losh
382*c43cad87SWarner Losh    Use this to invoke the C compiler.
383*c43cad87SWarner Losh
384*c43cad87SWarner Losh* `CFLAGS="?"`
385*c43cad87SWarner Losh
386*c43cad87SWarner Losh    Pass these flags to the compiler.
387*c43cad87SWarner Losh
388*c43cad87SWarner Losh* `CPPFLAGS="?"`
389*c43cad87SWarner Losh
390*c43cad87SWarner Losh    Pass these flags to the C preprocessor.
391*c43cad87SWarner Losh
392*c43cad87SWarner Losh* `LDFLAGS="?"`
393*c43cad87SWarner Losh
394*c43cad87SWarner Losh    Pass these flags when linking.
395*c43cad87SWarner Losh
396*c43cad87SWarner Losh* `PATH="?"`
397*c43cad87SWarner Losh
398*c43cad87SWarner Losh    Use this to search for programs used during configuration and building.
399*c43cad87SWarner Losh
400*c43cad87SWarner Losh
401*c43cad87SWarner Losh## Development
402*c43cad87SWarner Losh
403*c43cad87SWarner LoshIf you intend to make non-trivial changes to jemalloc, use the 'autogen.sh'
404*c43cad87SWarner Loshscript rather than 'configure'.  This re-generates 'configure', enables
405*c43cad87SWarner Loshconfiguration dependency rules, and enables re-generation of automatically
406*c43cad87SWarner Loshgenerated source files.
407*c43cad87SWarner Losh
408*c43cad87SWarner LoshThe build system supports using an object directory separate from the source
409*c43cad87SWarner Loshtree.  For example, you can create an 'obj' directory, and from within that
410*c43cad87SWarner Loshdirectory, issue configuration and build commands:
411*c43cad87SWarner Losh
412*c43cad87SWarner Losh    autoconf
413*c43cad87SWarner Losh    mkdir obj
414*c43cad87SWarner Losh    cd obj
415*c43cad87SWarner Losh    ../configure --enable-autogen
416*c43cad87SWarner Losh    make
417*c43cad87SWarner Losh
418*c43cad87SWarner Losh
419*c43cad87SWarner Losh## Documentation
420*c43cad87SWarner Losh
421*c43cad87SWarner LoshThe manual page is generated in both html and roff formats.  Any web browser
422*c43cad87SWarner Loshcan be used to view the html manual.  The roff manual page can be formatted
423*c43cad87SWarner Loshprior to installation via the following command:
424*c43cad87SWarner Losh
425*c43cad87SWarner Losh    nroff -man -t doc/jemalloc.3
426*c43cad87SWarner Losh||||||| dec341af7695
427*c43cad87SWarner Losh=======
428bf6039f0SWarner LoshBuilding and installing a packaged release of jemalloc can be as simple as
429bf6039f0SWarner Loshtyping the following while in the root directory of the source tree:
430bf6039f0SWarner Losh
431bf6039f0SWarner Losh    ./configure
432bf6039f0SWarner Losh    make
433bf6039f0SWarner Losh    make install
434bf6039f0SWarner Losh
435bf6039f0SWarner LoshIf building from unpackaged developer sources, the simplest command sequence
436bf6039f0SWarner Loshthat might work is:
437bf6039f0SWarner Losh
438bf6039f0SWarner Losh    ./autogen.sh
439bf6039f0SWarner Losh    make dist
440bf6039f0SWarner Losh    make
441bf6039f0SWarner Losh    make install
442bf6039f0SWarner Losh
443bf6039f0SWarner LoshNote that documentation is not built by the default target because doing so
444bf6039f0SWarner Loshwould create a dependency on xsltproc in packaged releases, hence the
445bf6039f0SWarner Loshrequirement to either run 'make dist' or avoid installing docs via the various
446bf6039f0SWarner Loshinstall_* targets documented below.
447bf6039f0SWarner Losh
448bf6039f0SWarner Losh
449bf6039f0SWarner Losh## Advanced configuration
450bf6039f0SWarner Losh
451bf6039f0SWarner LoshThe 'configure' script supports numerous options that allow control of which
452bf6039f0SWarner Loshfunctionality is enabled, where jemalloc is installed, etc.  Optionally, pass
453bf6039f0SWarner Loshany of the following arguments (not a definitive list) to 'configure':
454bf6039f0SWarner Losh
455bf6039f0SWarner Losh* `--help`
456bf6039f0SWarner Losh
457bf6039f0SWarner Losh    Print a definitive list of options.
458bf6039f0SWarner Losh
459bf6039f0SWarner Losh* `--prefix=<install-root-dir>`
460bf6039f0SWarner Losh
461bf6039f0SWarner Losh    Set the base directory in which to install.  For example:
462bf6039f0SWarner Losh
463bf6039f0SWarner Losh        ./configure --prefix=/usr/local
464bf6039f0SWarner Losh
465bf6039f0SWarner Losh    will cause files to be installed into /usr/local/include, /usr/local/lib,
466bf6039f0SWarner Losh    and /usr/local/man.
467bf6039f0SWarner Losh
468bf6039f0SWarner Losh* `--with-version=(<major>.<minor>.<bugfix>-<nrev>-g<gid>|VERSION)`
469bf6039f0SWarner Losh
470bf6039f0SWarner Losh    The VERSION file is mandatory for successful configuration, and the
471bf6039f0SWarner Losh    following steps are taken to assure its presence:
472bf6039f0SWarner Losh    1) If --with-version=<major>.<minor>.<bugfix>-<nrev>-g<gid> is specified,
473bf6039f0SWarner Losh       generate VERSION using the specified value.
474bf6039f0SWarner Losh    2) If --with-version is not specified in either form and the source
475bf6039f0SWarner Losh       directory is inside a git repository, try to generate VERSION via 'git
476bf6039f0SWarner Losh       describe' invocations that pattern-match release tags.
477bf6039f0SWarner Losh    3) If VERSION is missing, generate it with a bogus version:
478bf6039f0SWarner Losh       0.0.0-0-g0000000000000000000000000000000000000000
479bf6039f0SWarner Losh
480bf6039f0SWarner Losh    Note that --with-version=VERSION bypasses (1) and (2), which simplifies
481bf6039f0SWarner Losh    VERSION configuration when embedding a jemalloc release into another
482bf6039f0SWarner Losh    project's git repository.
483bf6039f0SWarner Losh
484bf6039f0SWarner Losh* `--with-rpath=<colon-separated-rpath>`
485bf6039f0SWarner Losh
486bf6039f0SWarner Losh    Embed one or more library paths, so that libjemalloc can find the libraries
487bf6039f0SWarner Losh    it is linked to.  This works only on ELF-based systems.
488bf6039f0SWarner Losh
489bf6039f0SWarner Losh* `--with-mangling=<map>`
490bf6039f0SWarner Losh
491bf6039f0SWarner Losh    Mangle public symbols specified in <map> which is a comma-separated list of
492bf6039f0SWarner Losh    name:mangled pairs.
493bf6039f0SWarner Losh
494bf6039f0SWarner Losh    For example, to use ld's --wrap option as an alternative method for
495bf6039f0SWarner Losh    overriding libc's malloc implementation, specify something like:
496bf6039f0SWarner Losh
497bf6039f0SWarner Losh      --with-mangling=malloc:__wrap_malloc,free:__wrap_free[...]
498bf6039f0SWarner Losh
499bf6039f0SWarner Losh    Note that mangling happens prior to application of the prefix specified by
500bf6039f0SWarner Losh    --with-jemalloc-prefix, and mangled symbols are then ignored when applying
501bf6039f0SWarner Losh    the prefix.
502bf6039f0SWarner Losh
503bf6039f0SWarner Losh* `--with-jemalloc-prefix=<prefix>`
504bf6039f0SWarner Losh
505bf6039f0SWarner Losh    Prefix all public APIs with <prefix>.  For example, if <prefix> is
506bf6039f0SWarner Losh    "prefix_", API changes like the following occur:
507bf6039f0SWarner Losh
508bf6039f0SWarner Losh      malloc()         --> prefix_malloc()
509bf6039f0SWarner Losh      malloc_conf      --> prefix_malloc_conf
510bf6039f0SWarner Losh      /etc/malloc.conf --> /etc/prefix_malloc.conf
511bf6039f0SWarner Losh      MALLOC_CONF      --> PREFIX_MALLOC_CONF
512bf6039f0SWarner Losh
513bf6039f0SWarner Losh    This makes it possible to use jemalloc at the same time as the system
514bf6039f0SWarner Losh    allocator, or even to use multiple copies of jemalloc simultaneously.
515bf6039f0SWarner Losh
516bf6039f0SWarner Losh    By default, the prefix is "", except on OS X, where it is "je_".  On OS X,
517bf6039f0SWarner Losh    jemalloc overlays the default malloc zone, but makes no attempt to actually
518bf6039f0SWarner Losh    replace the "malloc", "calloc", etc. symbols.
519bf6039f0SWarner Losh
520bf6039f0SWarner Losh* `--without-export`
521bf6039f0SWarner Losh
522bf6039f0SWarner Losh    Don't export public APIs.  This can be useful when building jemalloc as a
523bf6039f0SWarner Losh    static library, or to avoid exporting public APIs when using the zone
524bf6039f0SWarner Losh    allocator on OSX.
525bf6039f0SWarner Losh
526bf6039f0SWarner Losh* `--with-private-namespace=<prefix>`
527bf6039f0SWarner Losh
528bf6039f0SWarner Losh    Prefix all library-private APIs with <prefix>je_.  For shared libraries,
529bf6039f0SWarner Losh    symbol visibility mechanisms prevent these symbols from being exported, but
530bf6039f0SWarner Losh    for static libraries, naming collisions are a real possibility.  By
531bf6039f0SWarner Losh    default, <prefix> is empty, which results in a symbol prefix of je_ .
532bf6039f0SWarner Losh
533bf6039f0SWarner Losh* `--with-install-suffix=<suffix>`
534bf6039f0SWarner Losh
535bf6039f0SWarner Losh    Append <suffix> to the base name of all installed files, such that multiple
536bf6039f0SWarner Losh    versions of jemalloc can coexist in the same installation directory.  For
537bf6039f0SWarner Losh    example, libjemalloc.so.0 becomes libjemalloc<suffix>.so.0.
538bf6039f0SWarner Losh
539bf6039f0SWarner Losh* `--with-malloc-conf=<malloc_conf>`
540bf6039f0SWarner Losh
541bf6039f0SWarner Losh    Embed `<malloc_conf>` as a run-time options string that is processed prior to
542bf6039f0SWarner Losh    the malloc_conf global variable, the /etc/malloc.conf symlink, and the
543bf6039f0SWarner Losh    MALLOC_CONF environment variable.  For example, to change the default decay
544bf6039f0SWarner Losh    time to 30 seconds:
545bf6039f0SWarner Losh
546bf6039f0SWarner Losh      --with-malloc-conf=decay_ms:30000
547bf6039f0SWarner Losh
548bf6039f0SWarner Losh* `--enable-debug`
549bf6039f0SWarner Losh
550bf6039f0SWarner Losh    Enable assertions and validation code.  This incurs a substantial
551bf6039f0SWarner Losh    performance hit, but is very useful during application development.
552bf6039f0SWarner Losh
553bf6039f0SWarner Losh* `--disable-stats`
554bf6039f0SWarner Losh
555bf6039f0SWarner Losh    Disable statistics gathering functionality.  See the "opt.stats_print"
556bf6039f0SWarner Losh    option documentation for usage details.
557bf6039f0SWarner Losh
558bf6039f0SWarner Losh* `--enable-prof`
559bf6039f0SWarner Losh
560bf6039f0SWarner Losh    Enable heap profiling and leak detection functionality.  See the "opt.prof"
561bf6039f0SWarner Losh    option documentation for usage details.  When enabled, there are several
562bf6039f0SWarner Losh    approaches to backtracing, and the configure script chooses the first one
563bf6039f0SWarner Losh    in the following list that appears to function correctly:
564bf6039f0SWarner Losh
565bf6039f0SWarner Losh    + libunwind      (requires --enable-prof-libunwind)
566bf6039f0SWarner Losh    + libgcc         (unless --disable-prof-libgcc)
567bf6039f0SWarner Losh    + gcc intrinsics (unless --disable-prof-gcc)
568bf6039f0SWarner Losh
569bf6039f0SWarner Losh* `--enable-prof-libunwind`
570bf6039f0SWarner Losh
571bf6039f0SWarner Losh    Use the libunwind library (http://www.nongnu.org/libunwind/) for stack
572bf6039f0SWarner Losh    backtracing.
573bf6039f0SWarner Losh
574bf6039f0SWarner Losh* `--disable-prof-libgcc`
575bf6039f0SWarner Losh
576bf6039f0SWarner Losh    Disable the use of libgcc's backtracing functionality.
577bf6039f0SWarner Losh
578bf6039f0SWarner Losh* `--disable-prof-gcc`
579bf6039f0SWarner Losh
580bf6039f0SWarner Losh    Disable the use of gcc intrinsics for backtracing.
581bf6039f0SWarner Losh
582bf6039f0SWarner Losh* `--with-static-libunwind=<libunwind.a>`
583bf6039f0SWarner Losh
584bf6039f0SWarner Losh    Statically link against the specified libunwind.a rather than dynamically
585bf6039f0SWarner Losh    linking with -lunwind.
586bf6039f0SWarner Losh
587bf6039f0SWarner Losh* `--disable-fill`
588bf6039f0SWarner Losh
589bf6039f0SWarner Losh    Disable support for junk/zero filling of memory.  See the "opt.junk" and
590bf6039f0SWarner Losh    "opt.zero" option documentation for usage details.
591bf6039f0SWarner Losh
592bf6039f0SWarner Losh* `--disable-zone-allocator`
593bf6039f0SWarner Losh
594bf6039f0SWarner Losh    Disable zone allocator for Darwin.  This means jemalloc won't be hooked as
595bf6039f0SWarner Losh    the default allocator on OSX/iOS.
596bf6039f0SWarner Losh
597bf6039f0SWarner Losh* `--enable-utrace`
598bf6039f0SWarner Losh
599bf6039f0SWarner Losh    Enable utrace(2)-based allocation tracing.  This feature is not broadly
600bf6039f0SWarner Losh    portable (FreeBSD has it, but Linux and OS X do not).
601bf6039f0SWarner Losh
602bf6039f0SWarner Losh* `--enable-xmalloc`
603bf6039f0SWarner Losh
604bf6039f0SWarner Losh    Enable support for optional immediate termination due to out-of-memory
605bf6039f0SWarner Losh    errors, as is commonly implemented by "xmalloc" wrapper function for malloc.
606bf6039f0SWarner Losh    See the "opt.xmalloc" option documentation for usage details.
607bf6039f0SWarner Losh
608bf6039f0SWarner Losh* `--enable-lazy-lock`
609bf6039f0SWarner Losh
610bf6039f0SWarner Losh    Enable code that wraps pthread_create() to detect when an application
611bf6039f0SWarner Losh    switches from single-threaded to multi-threaded mode, so that it can avoid
612bf6039f0SWarner Losh    mutex locking/unlocking operations while in single-threaded mode.  In
613bf6039f0SWarner Losh    practice, this feature usually has little impact on performance unless
614bf6039f0SWarner Losh    thread-specific caching is disabled.
615bf6039f0SWarner Losh
616bf6039f0SWarner Losh* `--disable-cache-oblivious`
617bf6039f0SWarner Losh
618bf6039f0SWarner Losh    Disable cache-oblivious large allocation alignment for large allocation
619bf6039f0SWarner Losh    requests with no alignment constraints.  If this feature is disabled, all
620bf6039f0SWarner Losh    large allocations are page-aligned as an implementation artifact, which can
621bf6039f0SWarner Losh    severely harm CPU cache utilization.  However, the cache-oblivious layout
622bf6039f0SWarner Losh    comes at the cost of one extra page per large allocation, which in the
623bf6039f0SWarner Losh    most extreme case increases physical memory usage for the 16 KiB size class
624bf6039f0SWarner Losh    to 20 KiB.
625bf6039f0SWarner Losh
626bf6039f0SWarner Losh* `--disable-syscall`
627bf6039f0SWarner Losh
628bf6039f0SWarner Losh    Disable use of syscall(2) rather than {open,read,write,close}(2).  This is
629bf6039f0SWarner Losh    intended as a workaround for systems that place security limitations on
630bf6039f0SWarner Losh    syscall(2).
631bf6039f0SWarner Losh
632bf6039f0SWarner Losh* `--disable-cxx`
633bf6039f0SWarner Losh
634bf6039f0SWarner Losh    Disable C++ integration.  This will cause new and delete operator
635bf6039f0SWarner Losh    implementations to be omitted.
636bf6039f0SWarner Losh
637bf6039f0SWarner Losh* `--with-xslroot=<path>`
638bf6039f0SWarner Losh
639bf6039f0SWarner Losh    Specify where to find DocBook XSL stylesheets when building the
640bf6039f0SWarner Losh    documentation.
641bf6039f0SWarner Losh
642bf6039f0SWarner Losh* `--with-lg-page=<lg-page>`
643bf6039f0SWarner Losh
644bf6039f0SWarner Losh    Specify the base 2 log of the allocator page size, which must in turn be at
645bf6039f0SWarner Losh    least as large as the system page size.  By default the configure script
646bf6039f0SWarner Losh    determines the host's page size and sets the allocator page size equal to
647bf6039f0SWarner Losh    the system page size, so this option need not be specified unless the
648bf6039f0SWarner Losh    system page size may change between configuration and execution, e.g. when
649bf6039f0SWarner Losh    cross compiling.
650bf6039f0SWarner Losh
651bf6039f0SWarner Losh* `--with-lg-hugepage=<lg-hugepage>`
652bf6039f0SWarner Losh
653bf6039f0SWarner Losh    Specify the base 2 log of the system huge page size.  This option is useful
654bf6039f0SWarner Losh    when cross compiling, or when overriding the default for systems that do
655bf6039f0SWarner Losh    not explicitly support huge pages.
656bf6039f0SWarner Losh
657bf6039f0SWarner Losh* `--with-lg-quantum=<lg-quantum>`
658bf6039f0SWarner Losh
659bf6039f0SWarner Losh    Specify the base 2 log of the minimum allocation alignment.  jemalloc needs
660bf6039f0SWarner Losh    to know the minimum alignment that meets the following C standard
661bf6039f0SWarner Losh    requirement (quoted from the April 12, 2011 draft of the C11 standard):
662bf6039f0SWarner Losh
663bf6039f0SWarner Losh    >  The pointer returned if the allocation succeeds is suitably aligned so
664bf6039f0SWarner Losh      that it may be assigned to a pointer to any type of object with a
665bf6039f0SWarner Losh      fundamental alignment requirement and then used to access such an object
666bf6039f0SWarner Losh      or an array of such objects in the space allocated [...]
667bf6039f0SWarner Losh
668bf6039f0SWarner Losh    This setting is architecture-specific, and although jemalloc includes known
669bf6039f0SWarner Losh    safe values for the most commonly used modern architectures, there is a
670bf6039f0SWarner Losh    wrinkle related to GNU libc (glibc) that may impact your choice of
671bf6039f0SWarner Losh    <lg-quantum>.  On most modern architectures, this mandates 16-byte
672bf6039f0SWarner Losh    alignment (<lg-quantum>=4), but the glibc developers chose not to meet this
673bf6039f0SWarner Losh    requirement for performance reasons.  An old discussion can be found at
674bf6039f0SWarner Losh    <https://sourceware.org/bugzilla/show_bug.cgi?id=206> .  Unlike glibc,
675bf6039f0SWarner Losh    jemalloc does follow the C standard by default (caveat: jemalloc
676bf6039f0SWarner Losh    technically cheats for size classes smaller than the quantum), but the fact
677bf6039f0SWarner Losh    that Linux systems already work around this allocator noncompliance means
678bf6039f0SWarner Losh    that it is generally safe in practice to let jemalloc's minimum alignment
679bf6039f0SWarner Losh    follow glibc's lead.  If you specify `--with-lg-quantum=3` during
680bf6039f0SWarner Losh    configuration, jemalloc will provide additional size classes that are not
681bf6039f0SWarner Losh    16-byte-aligned (24, 40, and 56).
682bf6039f0SWarner Losh
683bf6039f0SWarner Losh* `--with-lg-vaddr=<lg-vaddr>`
684bf6039f0SWarner Losh
685bf6039f0SWarner Losh    Specify the number of significant virtual address bits.  By default, the
686bf6039f0SWarner Losh    configure script attempts to detect virtual address size on those platforms
687bf6039f0SWarner Losh    where it knows how, and picks a default otherwise.  This option may be
688bf6039f0SWarner Losh    useful when cross-compiling.
689bf6039f0SWarner Losh
690bf6039f0SWarner Losh* `--disable-initial-exec-tls`
691bf6039f0SWarner Losh
692bf6039f0SWarner Losh    Disable the initial-exec TLS model for jemalloc's internal thread-local
693bf6039f0SWarner Losh    storage (on those platforms that support explicit settings).  This can allow
694bf6039f0SWarner Losh    jemalloc to be dynamically loaded after program startup (e.g. using dlopen).
695bf6039f0SWarner Losh    Note that in this case, there will be two malloc implementations operating
696bf6039f0SWarner Losh    in the same process, which will almost certainly result in confusing runtime
697bf6039f0SWarner Losh    crashes if pointers leak from one implementation to the other.
698bf6039f0SWarner Losh
699bf6039f0SWarner Losh* `--disable-libdl`
700bf6039f0SWarner Losh
701bf6039f0SWarner Losh    Disable the usage of libdl, namely dlsym(3) which is required by the lazy
702bf6039f0SWarner Losh    lock option.  This can allow building static binaries.
703bf6039f0SWarner Losh
704bf6039f0SWarner LoshThe following environment variables (not a definitive list) impact configure's
705bf6039f0SWarner Loshbehavior:
706bf6039f0SWarner Losh
707bf6039f0SWarner Losh* `CFLAGS="?"`
708bf6039f0SWarner Losh* `CXXFLAGS="?"`
709bf6039f0SWarner Losh
710bf6039f0SWarner Losh    Pass these flags to the C/C++ compiler.  Any flags set by the configure
711bf6039f0SWarner Losh    script are prepended, which means explicitly set flags generally take
712bf6039f0SWarner Losh    precedence.  Take care when specifying flags such as -Werror, because
713bf6039f0SWarner Losh    configure tests may be affected in undesirable ways.
714bf6039f0SWarner Losh
715bf6039f0SWarner Losh* `EXTRA_CFLAGS="?"`
716bf6039f0SWarner Losh* `EXTRA_CXXFLAGS="?"`
717bf6039f0SWarner Losh
718bf6039f0SWarner Losh    Append these flags to CFLAGS/CXXFLAGS, without passing them to the
719bf6039f0SWarner Losh    compiler(s) during configuration.  This makes it possible to add flags such
720bf6039f0SWarner Losh    as -Werror, while allowing the configure script to determine what other
721bf6039f0SWarner Losh    flags are appropriate for the specified configuration.
722bf6039f0SWarner Losh
723bf6039f0SWarner Losh* `CPPFLAGS="?"`
724bf6039f0SWarner Losh
725bf6039f0SWarner Losh    Pass these flags to the C preprocessor.  Note that CFLAGS is not passed to
726bf6039f0SWarner Losh    'cpp' when 'configure' is looking for include files, so you must use
727bf6039f0SWarner Losh    CPPFLAGS instead if you need to help 'configure' find header files.
728bf6039f0SWarner Losh
729bf6039f0SWarner Losh* `LD_LIBRARY_PATH="?"`
730bf6039f0SWarner Losh
731bf6039f0SWarner Losh    'ld' uses this colon-separated list to find libraries.
732bf6039f0SWarner Losh
733bf6039f0SWarner Losh* `LDFLAGS="?"`
734bf6039f0SWarner Losh
735bf6039f0SWarner Losh    Pass these flags when linking.
736bf6039f0SWarner Losh
737bf6039f0SWarner Losh* `PATH="?"`
738bf6039f0SWarner Losh
739bf6039f0SWarner Losh    'configure' uses this to find programs.
740bf6039f0SWarner Losh
741bf6039f0SWarner LoshIn some cases it may be necessary to work around configuration results that do
742bf6039f0SWarner Loshnot match reality.  For example, Linux 4.5 added support for the MADV_FREE flag
743bf6039f0SWarner Loshto madvise(2), which can cause problems if building on a host with MADV_FREE
744bf6039f0SWarner Loshsupport and deploying to a target without.  To work around this, use a cache
745bf6039f0SWarner Loshfile to override the relevant configuration variable defined in configure.ac,
746bf6039f0SWarner Loshe.g.:
747bf6039f0SWarner Losh
748bf6039f0SWarner Losh    echo "je_cv_madv_free=no" > config.cache && ./configure -C
749bf6039f0SWarner Losh
750bf6039f0SWarner Losh
751bf6039f0SWarner Losh## Advanced compilation
752bf6039f0SWarner Losh
753bf6039f0SWarner LoshTo build only parts of jemalloc, use the following targets:
754bf6039f0SWarner Losh
755bf6039f0SWarner Losh    build_lib_shared
756bf6039f0SWarner Losh    build_lib_static
757bf6039f0SWarner Losh    build_lib
758bf6039f0SWarner Losh    build_doc_html
759bf6039f0SWarner Losh    build_doc_man
760bf6039f0SWarner Losh    build_doc
761bf6039f0SWarner Losh
762bf6039f0SWarner LoshTo install only parts of jemalloc, use the following targets:
763bf6039f0SWarner Losh
764bf6039f0SWarner Losh    install_bin
765bf6039f0SWarner Losh    install_include
766bf6039f0SWarner Losh    install_lib_shared
767bf6039f0SWarner Losh    install_lib_static
768bf6039f0SWarner Losh    install_lib_pc
769bf6039f0SWarner Losh    install_lib
770bf6039f0SWarner Losh    install_doc_html
771bf6039f0SWarner Losh    install_doc_man
772bf6039f0SWarner Losh    install_doc
773bf6039f0SWarner Losh
774bf6039f0SWarner LoshTo clean up build results to varying degrees, use the following make targets:
775bf6039f0SWarner Losh
776bf6039f0SWarner Losh    clean
777bf6039f0SWarner Losh    distclean
778bf6039f0SWarner Losh    relclean
779bf6039f0SWarner Losh
780bf6039f0SWarner Losh
781bf6039f0SWarner Losh## Advanced installation
782bf6039f0SWarner Losh
783bf6039f0SWarner LoshOptionally, define make variables when invoking make, including (not
784bf6039f0SWarner Loshexclusively):
785bf6039f0SWarner Losh
786bf6039f0SWarner Losh* `INCLUDEDIR="?"`
787bf6039f0SWarner Losh
788bf6039f0SWarner Losh    Use this as the installation prefix for header files.
789bf6039f0SWarner Losh
790bf6039f0SWarner Losh* `LIBDIR="?"`
791bf6039f0SWarner Losh
792bf6039f0SWarner Losh    Use this as the installation prefix for libraries.
793bf6039f0SWarner Losh
794bf6039f0SWarner Losh* `MANDIR="?"`
795bf6039f0SWarner Losh
796bf6039f0SWarner Losh    Use this as the installation prefix for man pages.
797bf6039f0SWarner Losh
798bf6039f0SWarner Losh* `DESTDIR="?"`
799bf6039f0SWarner Losh
800bf6039f0SWarner Losh    Prepend DESTDIR to INCLUDEDIR, LIBDIR, DATADIR, and MANDIR.  This is useful
801bf6039f0SWarner Losh    when installing to a different path than was specified via --prefix.
802bf6039f0SWarner Losh
803bf6039f0SWarner Losh* `CC="?"`
804bf6039f0SWarner Losh
805bf6039f0SWarner Losh    Use this to invoke the C compiler.
806bf6039f0SWarner Losh
807bf6039f0SWarner Losh* `CFLAGS="?"`
808bf6039f0SWarner Losh
809bf6039f0SWarner Losh    Pass these flags to the compiler.
810bf6039f0SWarner Losh
811bf6039f0SWarner Losh* `CPPFLAGS="?"`
812bf6039f0SWarner Losh
813bf6039f0SWarner Losh    Pass these flags to the C preprocessor.
814bf6039f0SWarner Losh
815bf6039f0SWarner Losh* `LDFLAGS="?"`
816bf6039f0SWarner Losh
817bf6039f0SWarner Losh    Pass these flags when linking.
818bf6039f0SWarner Losh
819bf6039f0SWarner Losh* `PATH="?"`
820bf6039f0SWarner Losh
821bf6039f0SWarner Losh    Use this to search for programs used during configuration and building.
822bf6039f0SWarner Losh
823bf6039f0SWarner Losh
824bf6039f0SWarner Losh## Development
825bf6039f0SWarner Losh
826bf6039f0SWarner LoshIf you intend to make non-trivial changes to jemalloc, use the 'autogen.sh'
827bf6039f0SWarner Loshscript rather than 'configure'.  This re-generates 'configure', enables
828bf6039f0SWarner Loshconfiguration dependency rules, and enables re-generation of automatically
829bf6039f0SWarner Loshgenerated source files.
830bf6039f0SWarner Losh
831bf6039f0SWarner LoshThe build system supports using an object directory separate from the source
832bf6039f0SWarner Loshtree.  For example, you can create an 'obj' directory, and from within that
833bf6039f0SWarner Loshdirectory, issue configuration and build commands:
834bf6039f0SWarner Losh
835bf6039f0SWarner Losh    autoconf
836bf6039f0SWarner Losh    mkdir obj
837bf6039f0SWarner Losh    cd obj
838bf6039f0SWarner Losh    ../configure --enable-autogen
839bf6039f0SWarner Losh    make
840bf6039f0SWarner Losh
841bf6039f0SWarner Losh
842bf6039f0SWarner Losh## Documentation
843bf6039f0SWarner Losh
844bf6039f0SWarner LoshThe manual page is generated in both html and roff formats.  Any web browser
845bf6039f0SWarner Loshcan be used to view the html manual.  The roff manual page can be formatted
846bf6039f0SWarner Loshprior to installation via the following command:
847bf6039f0SWarner Losh
848bf6039f0SWarner Losh    nroff -man -t doc/jemalloc.3
849*c43cad87SWarner Losh>>>>>>> main
850