9906660eb7
When statically linking jemalloc, it may be beneficial not to export its symbols if it makes sense, which allows the compiler and the linker to do some further optimizations.
284 lines
9.9 KiB
Plaintext
284 lines
9.9 KiB
Plaintext
Building and installing jemalloc can be as simple as typing the following while
|
|
in the root directory of the source tree:
|
|
|
|
./configure
|
|
make
|
|
make install
|
|
|
|
=== Advanced configuration =====================================================
|
|
|
|
The 'configure' script supports numerous options that allow control of which
|
|
functionality is enabled, where jemalloc is installed, etc. Optionally, pass
|
|
any of the following arguments (not a definitive list) to 'configure':
|
|
|
|
--help
|
|
Print a definitive list of options.
|
|
|
|
--prefix=<install-root-dir>
|
|
Set the base directory in which to install. For example:
|
|
|
|
./configure --prefix=/usr/local
|
|
|
|
will cause files to be installed into /usr/local/include, /usr/local/lib,
|
|
and /usr/local/man.
|
|
|
|
--with-rpath=<colon-separated-rpath>
|
|
Embed one or more library paths, so that libjemalloc can find the libraries
|
|
it is linked to. This works only on ELF-based systems.
|
|
|
|
--with-mangling=<map>
|
|
Mangle public symbols specified in <map> which is a comma-separated list of
|
|
name:mangled pairs.
|
|
|
|
For example, to use ld's --wrap option as an alternative method for
|
|
overriding libc's malloc implementation, specify something like:
|
|
|
|
--with-mangling=malloc:__wrap_malloc,free:__wrap_free[...]
|
|
|
|
Note that mangling happens prior to application of the prefix specified by
|
|
--with-jemalloc-prefix, and mangled symbols are then ignored when applying
|
|
the prefix.
|
|
|
|
--with-jemalloc-prefix=<prefix>
|
|
Prefix all public APIs with <prefix>. For example, if <prefix> is
|
|
"prefix_", API changes like the following occur:
|
|
|
|
malloc() --> prefix_malloc()
|
|
malloc_conf --> prefix_malloc_conf
|
|
/etc/malloc.conf --> /etc/prefix_malloc.conf
|
|
MALLOC_CONF --> PREFIX_MALLOC_CONF
|
|
|
|
This makes it possible to use jemalloc at the same time as the system
|
|
allocator, or even to use multiple copies of jemalloc simultaneously.
|
|
|
|
By default, the prefix is "", except on OS X, where it is "je_". On OS X,
|
|
jemalloc overlays the default malloc zone, but makes no attempt to actually
|
|
replace the "malloc", "calloc", etc. symbols.
|
|
|
|
--without-export
|
|
Don't export public APIs. This can be useful when building jemalloc as a
|
|
static library, or to avoid exporting public APIs when using the zone
|
|
allocator on OSX.
|
|
|
|
--with-private-namespace=<prefix>
|
|
Prefix all library-private APIs with <prefix>. For shared libraries,
|
|
symbol visibility mechanisms prevent these symbols from being exported, but
|
|
for static libraries, naming collisions are a real possibility. By
|
|
default, the prefix is "" (empty string).
|
|
|
|
--with-install-suffix=<suffix>
|
|
Append <suffix> to the base name of all installed files, such that multiple
|
|
versions of jemalloc can coexist in the same installation directory. For
|
|
example, libjemalloc.so.0 becomes libjemalloc<suffix>.so.0.
|
|
|
|
--enable-cc-silence
|
|
Enable code that silences non-useful compiler warnings. This is helpful
|
|
when trying to tell serious warnings from those due to compiler
|
|
limitations, but it potentially incurs a performance penalty.
|
|
|
|
--enable-debug
|
|
Enable assertions and validation code. This incurs a substantial
|
|
performance hit, but is very useful during application development.
|
|
|
|
--disable-stats
|
|
Disable statistics gathering functionality. See the "opt.stats_print"
|
|
option documentation for usage details.
|
|
|
|
--enable-prof
|
|
Enable heap profiling and leak detection functionality. See the "opt.prof"
|
|
option documentation for usage details. When enabled, there are several
|
|
approaches to backtracing, and the configure script chooses the first one
|
|
in the following list that appears to function correctly:
|
|
|
|
+ libunwind (requires --enable-prof-libunwind)
|
|
+ libgcc (unless --disable-prof-libgcc)
|
|
+ gcc intrinsics (unless --disable-prof-gcc)
|
|
|
|
--enable-prof-libunwind
|
|
Use the libunwind library (http://www.nongnu.org/libunwind/) for stack
|
|
backtracing.
|
|
|
|
--disable-prof-libgcc
|
|
Disable the use of libgcc's backtracing functionality.
|
|
|
|
--disable-prof-gcc
|
|
Disable the use of gcc intrinsics for backtracing.
|
|
|
|
--with-static-libunwind=<libunwind.a>
|
|
Statically link against the specified libunwind.a rather than dynamically
|
|
linking with -lunwind.
|
|
|
|
--disable-tcache
|
|
Disable thread-specific caches for small objects. Objects are cached and
|
|
released in bulk, thus reducing the total number of mutex operations. See
|
|
the "opt.tcache" option for usage details.
|
|
|
|
--enable-mremap
|
|
Enable huge realloc() via mremap(2). mremap() is disabled by default
|
|
because the flavor used is specific to Linux, which has a quirk in its
|
|
virtual memory allocation algorithm that causes semi-permanent VM map holes
|
|
under normal jemalloc operation.
|
|
|
|
--disable-munmap
|
|
Disable virtual memory deallocation via munmap(2); instead keep track of
|
|
the virtual memory for later use. munmap() is disabled by default (i.e.
|
|
--disable-munmap is implied) on Linux, which has a quirk in its virtual
|
|
memory allocation algorithm that causes semi-permanent VM map holes under
|
|
normal jemalloc operation.
|
|
|
|
--enable-dss
|
|
Enable support for page allocation/deallocation via sbrk(2), in addition to
|
|
mmap(2).
|
|
|
|
--disable-fill
|
|
Disable support for junk/zero filling of memory, quarantine, and redzones.
|
|
See the "opt.junk", "opt.zero", "opt.quarantine", and "opt.redzone" option
|
|
documentation for usage details.
|
|
|
|
--disable-valgrind
|
|
Disable support for Valgrind.
|
|
|
|
--disable-experimental
|
|
Disable support for the experimental API (*allocm()).
|
|
|
|
--enable-utrace
|
|
Enable utrace(2)-based allocation tracing. This feature is not broadly
|
|
portable (FreeBSD has it, but Linux and OS X do not).
|
|
|
|
--enable-xmalloc
|
|
Enable support for optional immediate termination due to out-of-memory
|
|
errors, as is commonly implemented by "xmalloc" wrapper function for malloc.
|
|
See the "opt.xmalloc" option documentation for usage details.
|
|
|
|
--enable-lazy-lock
|
|
Enable code that wraps pthread_create() to detect when an application
|
|
switches from single-threaded to multi-threaded mode, so that it can avoid
|
|
mutex locking/unlocking operations while in single-threaded mode. In
|
|
practice, this feature usually has little impact on performance unless
|
|
thread-specific caching is disabled.
|
|
|
|
--disable-tls
|
|
Disable thread-local storage (TLS), which allows for fast access to
|
|
thread-local variables via the __thread keyword. If TLS is available,
|
|
jemalloc uses it for several purposes.
|
|
|
|
--with-xslroot=<path>
|
|
Specify where to find DocBook XSL stylesheets when building the
|
|
documentation.
|
|
|
|
The following environment variables (not a definitive list) impact configure's
|
|
behavior:
|
|
|
|
CFLAGS="?"
|
|
Pass these flags to the compiler. You probably shouldn't define this unless
|
|
you know what you are doing. (Use EXTRA_CFLAGS instead.)
|
|
|
|
EXTRA_CFLAGS="?"
|
|
Append these flags to CFLAGS. This makes it possible to add flags such as
|
|
-Werror, while allowing the configure script to determine what other flags
|
|
are appropriate for the specified configuration.
|
|
|
|
The configure script specifically checks whether an optimization flag (-O*)
|
|
is specified in EXTRA_CFLAGS, and refrains from specifying an optimization
|
|
level if it finds that one has already been specified.
|
|
|
|
CPPFLAGS="?"
|
|
Pass these flags to the C preprocessor. Note that CFLAGS is not passed to
|
|
'cpp' when 'configure' is looking for include files, so you must use
|
|
CPPFLAGS instead if you need to help 'configure' find header files.
|
|
|
|
LD_LIBRARY_PATH="?"
|
|
'ld' uses this colon-separated list to find libraries.
|
|
|
|
LDFLAGS="?"
|
|
Pass these flags when linking.
|
|
|
|
PATH="?"
|
|
'configure' uses this to find programs.
|
|
|
|
=== Advanced compilation =======================================================
|
|
|
|
To build only parts of jemalloc, use the following targets:
|
|
|
|
build_lib_shared
|
|
build_lib_static
|
|
build_lib
|
|
build_doc_html
|
|
build_doc_man
|
|
build_doc
|
|
|
|
To install only parts of jemalloc, use the following targets:
|
|
|
|
install_bin
|
|
install_include
|
|
install_lib_shared
|
|
install_lib_static
|
|
install_lib
|
|
install_doc_html
|
|
install_doc_man
|
|
install_doc
|
|
|
|
To clean up build results to varying degrees, use the following make targets:
|
|
|
|
clean
|
|
distclean
|
|
relclean
|
|
|
|
=== Advanced installation ======================================================
|
|
|
|
Optionally, define make variables when invoking make, including (not
|
|
exclusively):
|
|
|
|
INCLUDEDIR="?"
|
|
Use this as the installation prefix for header files.
|
|
|
|
LIBDIR="?"
|
|
Use this as the installation prefix for libraries.
|
|
|
|
MANDIR="?"
|
|
Use this as the installation prefix for man pages.
|
|
|
|
DESTDIR="?"
|
|
Prepend DESTDIR to INCLUDEDIR, LIBDIR, DATADIR, and MANDIR. This is useful
|
|
when installing to a different path than was specified via --prefix.
|
|
|
|
CC="?"
|
|
Use this to invoke the C compiler.
|
|
|
|
CFLAGS="?"
|
|
Pass these flags to the compiler.
|
|
|
|
CPPFLAGS="?"
|
|
Pass these flags to the C preprocessor.
|
|
|
|
LDFLAGS="?"
|
|
Pass these flags when linking.
|
|
|
|
PATH="?"
|
|
Use this to search for programs used during configuration and building.
|
|
|
|
=== Development ================================================================
|
|
|
|
If you intend to make non-trivial changes to jemalloc, use the 'autogen.sh'
|
|
script rather than 'configure'. This re-generates 'configure', enables
|
|
configuration dependency rules, and enables re-generation of automatically
|
|
generated source files.
|
|
|
|
The build system supports using an object directory separate from the source
|
|
tree. For example, you can create an 'obj' directory, and from within that
|
|
directory, issue configuration and build commands:
|
|
|
|
autoconf
|
|
mkdir obj
|
|
cd obj
|
|
../configure --enable-autogen
|
|
make
|
|
|
|
=== Documentation ==============================================================
|
|
|
|
The manual page is generated in both html and roff formats. Any web browser
|
|
can be used to view the html manual. The roff manual page can be formatted
|
|
prior to installation via the following command:
|
|
|
|
nroff -man -t doc/jemalloc.3
|