2014-09-24 00:21:49 +08:00
|
|
|
Building and installing a packaged release of jemalloc can be as simple as
|
|
|
|
typing the following while in the root directory of the source tree:
|
2009-06-26 09:06:48 +08:00
|
|
|
|
|
|
|
./configure
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
|
2014-09-24 00:21:49 +08:00
|
|
|
If building from unpackaged developer sources, the simplest command sequence
|
|
|
|
that might work is:
|
|
|
|
|
|
|
|
./autogen.sh
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
|
2022-02-01 04:28:15 +08:00
|
|
|
You can uninstall the installed build artifacts like this:
|
|
|
|
|
|
|
|
make uninstall
|
|
|
|
|
2021-02-16 09:12:23 +08:00
|
|
|
Notes:
|
|
|
|
- "autoconf" needs to be installed
|
|
|
|
- Documentation is built by the default target only when xsltproc is
|
2019-08-16 13:33:34 +08:00
|
|
|
available. Build will warn but not stop if the dependency is missing.
|
2014-09-24 00:21:49 +08:00
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
|
|
|
|
## Advanced configuration
|
2009-06-26 09:06:48 +08:00
|
|
|
|
|
|
|
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':
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--help`
|
|
|
|
|
2009-06-26 09:06:48 +08:00
|
|
|
Print a definitive list of options.
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--prefix=<install-root-dir>`
|
|
|
|
|
2009-06-26 09:06:48 +08:00
|
|
|
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.
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--with-version=(<major>.<minor>.<bugfix>-<nrev>-g<gid>|VERSION)`
|
|
|
|
|
2017-05-04 01:07:39 +08:00
|
|
|
The VERSION file is mandatory for successful configuration, and the
|
|
|
|
following steps are taken to assure its presence:
|
|
|
|
1) If --with-version=<major>.<minor>.<bugfix>-<nrev>-g<gid> is specified,
|
|
|
|
generate VERSION using the specified value.
|
|
|
|
2) If --with-version is not specified in either form and the source
|
|
|
|
directory is inside a git repository, try to generate VERSION via 'git
|
|
|
|
describe' invocations that pattern-match release tags.
|
|
|
|
3) If VERSION is missing, generate it with a bogus version:
|
|
|
|
0.0.0-0-g0000000000000000000000000000000000000000
|
|
|
|
|
|
|
|
Note that --with-version=VERSION bypasses (1) and (2), which simplifies
|
|
|
|
VERSION configuration when embedding a jemalloc release into another
|
|
|
|
project's git repository.
|
2016-03-15 11:19:11 +08:00
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--with-rpath=<colon-separated-rpath>`
|
|
|
|
|
2009-12-29 16:09:15 +08:00
|
|
|
Embed one or more library paths, so that libjemalloc can find the libraries
|
|
|
|
it is linked to. This works only on ELF-based systems.
|
2009-06-26 09:06:48 +08:00
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--with-mangling=<map>`
|
|
|
|
|
2012-03-02 09:19:20 +08:00
|
|
|
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.
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--with-jemalloc-prefix=<prefix>`
|
|
|
|
|
2010-10-24 09:37:06 +08:00
|
|
|
Prefix all public APIs with <prefix>. For example, if <prefix> is
|
2010-12-17 06:13:46 +08:00
|
|
|
"prefix_", API changes like the following occur:
|
2010-10-24 09:37:06 +08:00
|
|
|
|
|
|
|
malloc() --> prefix_malloc()
|
|
|
|
malloc_conf --> prefix_malloc_conf
|
|
|
|
/etc/malloc.conf --> /etc/prefix_malloc.conf
|
|
|
|
MALLOC_CONF --> PREFIX_MALLOC_CONF
|
|
|
|
|
2010-10-25 07:18:29 +08:00
|
|
|
This makes it possible to use jemalloc at the same time as the system
|
|
|
|
allocator, or even to use multiple copies of jemalloc simultaneously.
|
2009-12-29 16:09:15 +08:00
|
|
|
|
2010-09-06 01:35:13 +08:00
|
|
|
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.
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--without-export`
|
|
|
|
|
2014-09-05 13:27:26 +08:00
|
|
|
Don't export public APIs. This can be useful when building jemalloc as a
|
2012-11-19 17:55:26 +08:00
|
|
|
static library, or to avoid exporting public APIs when using the zone
|
|
|
|
allocator on OSX.
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--with-private-namespace=<prefix>`
|
|
|
|
|
Refactor to support more varied testing.
Refactor the test harness to support three types of tests:
- unit: White box unit tests. These tests have full access to all
internal jemalloc library symbols. Though in actuality all symbols
are prefixed by jet_, macro-based name mangling abstracts this away
from test code.
- integration: Black box integration tests. These tests link with
the installable shared jemalloc library, and with the exception of
some utility code and configure-generated macro definitions, they have
no access to jemalloc internals.
- stress: Black box stress tests. These tests link with the installable
shared jemalloc library, as well as with an internal allocator with
symbols prefixed by jet_ (same as for unit tests) that can be used to
allocate data structures that are internal to the test code.
Move existing tests into test/{unit,integration}/ as appropriate.
Split out internal parts of jemalloc_defs.h.in and put them in
jemalloc_internal_defs.h.in. This reduces internals exposure to
applications that #include <jemalloc/jemalloc.h>.
Refactor jemalloc.h header generation so that a single header file
results, and the prototypes can be used to generate jet_ prototypes for
tests. Split jemalloc.h.in into multiple parts (jemalloc_defs.h.in,
jemalloc_macros.h.in, jemalloc_protos.h.in, jemalloc_mangle.h.in) and
use a shell script to generate a unified jemalloc.h at configure time.
Change the default private namespace prefix from "" to "je_".
Add missing private namespace mangling.
Remove hard-coded private_namespace.h. Instead generate it and
private_unnamespace.h from private_symbols.txt. Use similar logic for
public symbols, which aids in name mangling for jet_ symbols.
Add test_warn() and test_fail(). Replace existing exit(1) calls with
test_fail() calls.
2013-12-01 07:25:42 +08:00
|
|
|
Prefix all library-private APIs with <prefix>je_. For shared libraries,
|
2011-07-31 07:40:52 +08:00
|
|
|
symbol visibility mechanisms prevent these symbols from being exported, but
|
|
|
|
for static libraries, naming collisions are a real possibility. By
|
Refactor to support more varied testing.
Refactor the test harness to support three types of tests:
- unit: White box unit tests. These tests have full access to all
internal jemalloc library symbols. Though in actuality all symbols
are prefixed by jet_, macro-based name mangling abstracts this away
from test code.
- integration: Black box integration tests. These tests link with
the installable shared jemalloc library, and with the exception of
some utility code and configure-generated macro definitions, they have
no access to jemalloc internals.
- stress: Black box stress tests. These tests link with the installable
shared jemalloc library, as well as with an internal allocator with
symbols prefixed by jet_ (same as for unit tests) that can be used to
allocate data structures that are internal to the test code.
Move existing tests into test/{unit,integration}/ as appropriate.
Split out internal parts of jemalloc_defs.h.in and put them in
jemalloc_internal_defs.h.in. This reduces internals exposure to
applications that #include <jemalloc/jemalloc.h>.
Refactor jemalloc.h header generation so that a single header file
results, and the prototypes can be used to generate jet_ prototypes for
tests. Split jemalloc.h.in into multiple parts (jemalloc_defs.h.in,
jemalloc_macros.h.in, jemalloc_protos.h.in, jemalloc_mangle.h.in) and
use a shell script to generate a unified jemalloc.h at configure time.
Change the default private namespace prefix from "" to "je_".
Add missing private namespace mangling.
Remove hard-coded private_namespace.h. Instead generate it and
private_unnamespace.h from private_symbols.txt. Use similar logic for
public symbols, which aids in name mangling for jet_ symbols.
Add test_warn() and test_fail(). Replace existing exit(1) calls with
test_fail() calls.
2013-12-01 07:25:42 +08:00
|
|
|
default, <prefix> is empty, which results in a symbol prefix of je_ .
|
2011-07-31 07:40:52 +08:00
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--with-install-suffix=<suffix>`
|
|
|
|
|
2010-01-17 17:49:20 +08:00
|
|
|
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.
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--with-malloc-conf=<malloc_conf>`
|
|
|
|
|
|
|
|
Embed `<malloc_conf>` as a run-time options string that is processed prior to
|
2016-02-08 06:23:22 +08:00
|
|
|
the malloc_conf global variable, the /etc/malloc.conf symlink, and the
|
2016-10-13 02:49:19 +08:00
|
|
|
MALLOC_CONF environment variable. For example, to change the default decay
|
|
|
|
time to 30 seconds:
|
2016-02-08 06:23:22 +08:00
|
|
|
|
2017-05-18 01:47:00 +08:00
|
|
|
--with-malloc-conf=decay_ms:30000
|
2016-02-08 06:23:22 +08:00
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--enable-debug`
|
|
|
|
|
2009-06-26 09:06:48 +08:00
|
|
|
Enable assertions and validation code. This incurs a substantial
|
|
|
|
performance hit, but is very useful during application development.
|
2012-12-07 05:16:26 +08:00
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--disable-stats`
|
|
|
|
|
2012-02-29 12:41:16 +08:00
|
|
|
Disable statistics gathering functionality. See the "opt.stats_print"
|
2010-10-25 07:18:29 +08:00
|
|
|
option documentation for usage details.
|
2009-06-26 09:06:48 +08:00
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--enable-prof`
|
|
|
|
|
2010-10-25 07:18:29 +08:00
|
|
|
Enable heap profiling and leak detection functionality. See the "opt.prof"
|
2011-03-16 13:23:12 +08:00
|
|
|
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:
|
2010-02-11 02:37:56 +08:00
|
|
|
|
2011-03-16 13:23:12 +08:00
|
|
|
+ libunwind (requires --enable-prof-libunwind)
|
|
|
|
+ libgcc (unless --disable-prof-libgcc)
|
|
|
|
+ gcc intrinsics (unless --disable-prof-gcc)
|
2010-02-11 10:15:53 +08:00
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--enable-prof-libunwind`
|
|
|
|
|
2010-02-11 02:37:56 +08:00
|
|
|
Use the libunwind library (http://www.nongnu.org/libunwind/) for stack
|
2011-03-16 13:23:12 +08:00
|
|
|
backtracing.
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--disable-prof-libgcc`
|
|
|
|
|
2011-03-16 13:23:12 +08:00
|
|
|
Disable the use of libgcc's backtracing functionality.
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--disable-prof-gcc`
|
|
|
|
|
2011-03-16 13:23:12 +08:00
|
|
|
Disable the use of gcc intrinsics for backtracing.
|
2010-02-11 02:37:56 +08:00
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--with-static-libunwind=<libunwind.a>`
|
|
|
|
|
2010-03-03 06:12:58 +08:00
|
|
|
Statically link against the specified libunwind.a rather than dynamically
|
|
|
|
linking with -lunwind.
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--disable-fill`
|
|
|
|
|
2016-04-06 09:18:15 +08:00
|
|
|
Disable support for junk/zero filling of memory. See the "opt.junk" and
|
|
|
|
"opt.zero" option documentation for usage details.
|
2012-04-06 15:35:09 +08:00
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--disable-zone-allocator`
|
|
|
|
|
2014-09-05 13:27:26 +08:00
|
|
|
Disable zone allocator for Darwin. This means jemalloc won't be hooked as
|
2012-11-27 01:52:41 +08:00
|
|
|
the default allocator on OSX/iOS.
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--enable-utrace`
|
|
|
|
|
2012-04-06 04:36:17 +08:00
|
|
|
Enable utrace(2)-based allocation tracing. This feature is not broadly
|
|
|
|
portable (FreeBSD has it, but Linux and OS X do not).
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--enable-xmalloc`
|
|
|
|
|
2009-06-26 09:06:48 +08:00
|
|
|
Enable support for optional immediate termination due to out-of-memory
|
|
|
|
errors, as is commonly implemented by "xmalloc" wrapper function for malloc.
|
2010-10-25 07:18:29 +08:00
|
|
|
See the "opt.xmalloc" option documentation for usage details.
|
2009-06-26 09:06:48 +08:00
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--enable-lazy-lock`
|
|
|
|
|
2012-02-14 04:36:11 +08:00
|
|
|
Enable code that wraps pthread_create() to detect when an application
|
2009-06-26 09:06:48 +08:00
|
|
|
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
|
2009-12-29 16:09:15 +08:00
|
|
|
thread-specific caching is disabled.
|
2009-06-26 09:06:48 +08:00
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--disable-cache-oblivious`
|
|
|
|
|
2021-02-10 14:24:35 +08:00
|
|
|
Disable cache-oblivious large allocation alignment by default, for large
|
|
|
|
allocation requests with no alignment constraints. If this feature is
|
|
|
|
disabled, all large allocations are page-aligned as an implementation
|
|
|
|
artifact, which can severely harm CPU cache utilization. However, the
|
|
|
|
cache-oblivious layout comes at the cost of one extra page per large
|
|
|
|
allocation, which in the most extreme case increases physical memory usage
|
|
|
|
for the 16 KiB size class to 20 KiB.
|
2015-05-05 00:58:36 +08:00
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--disable-syscall`
|
|
|
|
|
2016-12-04 08:47:36 +08:00
|
|
|
Disable use of syscall(2) rather than {open,read,write,close}(2). This is
|
|
|
|
intended as a workaround for systems that place security limitations on
|
|
|
|
syscall(2).
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--disable-cxx`
|
|
|
|
|
jemalloc cpp new/delete bindings
Adds cpp bindings for jemalloc, along with necessary autoconf settings.
This is mostly to add sized deallocation support, which can't be added
from C directly. Sized deallocation is ~10% microbench improvement.
* Import ax_cxx_compile_stdcxx.m4 from the autoconf repo, seems like the
easiest way to get c++14 detection.
* Adds various other changes, like CXXFLAGS, to configure.ac.
* Adds new rules to Makefile.in for src/jemalloc-cpp.cpp, and a basic
unittest.
* Both new and delete are overridden, to ensure jemalloc is used for
both.
* TODO future enhancement of avoiding extra PLT thunks for new and
delete - sdallocx and malloc are publicly exported jemalloc symbols,
using an alias would link them directly. Unfortunately, was having
trouble getting it to play nice with jemalloc's namespace support.
Testing:
Tested gcc 4.8, gcc 5, gcc 5.2, clang 4.0. Only gcc >= 5 has sized
deallocation support, verified that the rest build correctly.
Tested mac osx and Centos.
Tested --with-jemalloc-prefix and --without-export.
This resolves #202.
2016-10-24 06:56:30 +08:00
|
|
|
Disable C++ integration. This will cause new and delete operator
|
|
|
|
implementations to be omitted.
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--with-xslroot=<path>`
|
|
|
|
|
2010-11-25 14:00:02 +08:00
|
|
|
Specify where to find DocBook XSL stylesheets when building the
|
|
|
|
documentation.
|
2010-01-18 06:06:20 +08:00
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--with-lg-page=<lg-page>`
|
|
|
|
|
2017-04-17 07:23:32 +08:00
|
|
|
Specify the base 2 log of the allocator page size, which must in turn be at
|
|
|
|
least as large as the system page size. By default the configure script
|
|
|
|
determines the host's page size and sets the allocator page size equal to
|
|
|
|
the system page size, so this option need not be specified unless the
|
|
|
|
system page size may change between configuration and execution, e.g. when
|
|
|
|
cross compiling.
|
2014-10-10 08:54:06 +08:00
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--with-lg-hugepage=<lg-hugepage>`
|
|
|
|
|
2016-11-18 05:36:17 +08:00
|
|
|
Specify the base 2 log of the system huge page size. This option is useful
|
|
|
|
when cross compiling, or when overriding the default for systems that do
|
|
|
|
not explicitly support huge pages.
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `--with-lg-quantum=<lg-quantum>`
|
|
|
|
|
2014-10-11 13:34:25 +08:00
|
|
|
Specify the base 2 log of the minimum allocation alignment. jemalloc needs
|
|
|
|
to know the minimum alignment that meets the following C standard
|
|
|
|
requirement (quoted from the April 12, 2011 draft of the C11 standard):
|
2014-10-10 08:54:06 +08:00
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
> The pointer returned if the allocation succeeds is suitably aligned so
|
2014-10-10 08:54:06 +08:00
|
|
|
that it may be assigned to a pointer to any type of object with a
|
|
|
|
fundamental alignment requirement and then used to access such an object
|
|
|
|
or an array of such objects in the space allocated [...]
|
|
|
|
|
|
|
|
This setting is architecture-specific, and although jemalloc includes known
|
|
|
|
safe values for the most commonly used modern architectures, there is a
|
|
|
|
wrinkle related to GNU libc (glibc) that may impact your choice of
|
2017-04-22 06:35:54 +08:00
|
|
|
<lg-quantum>. On most modern architectures, this mandates 16-byte
|
|
|
|
alignment (<lg-quantum>=4), but the glibc developers chose not to meet this
|
2014-10-15 13:31:49 +08:00
|
|
|
requirement for performance reasons. An old discussion can be found at
|
2017-05-12 02:57:05 +08:00
|
|
|
<https://sourceware.org/bugzilla/show_bug.cgi?id=206> . Unlike glibc,
|
2014-10-11 13:34:25 +08:00
|
|
|
jemalloc does follow the C standard by default (caveat: jemalloc
|
2017-04-22 06:35:54 +08:00
|
|
|
technically cheats for size classes smaller than the quantum), but the fact
|
|
|
|
that Linux systems already work around this allocator noncompliance means
|
|
|
|
that it is generally safe in practice to let jemalloc's minimum alignment
|
2017-05-12 02:57:05 +08:00
|
|
|
follow glibc's lead. If you specify `--with-lg-quantum=3` during
|
2017-04-22 06:35:54 +08:00
|
|
|
configuration, jemalloc will provide additional size classes that are not
|
|
|
|
16-byte-aligned (24, 40, and 56).
|
2014-10-11 13:34:25 +08:00
|
|
|
|
2018-05-03 22:52:03 +08:00
|
|
|
* `--with-lg-vaddr=<lg-vaddr>`
|
|
|
|
|
2018-05-05 01:44:17 +08:00
|
|
|
Specify the number of significant virtual address bits. By default, the
|
|
|
|
configure script attempts to detect virtual address size on those platforms
|
|
|
|
where it knows how, and picks a default otherwise. This option may be
|
|
|
|
useful when cross-compiling.
|
2018-05-03 22:52:03 +08:00
|
|
|
|
2018-04-18 03:52:22 +08:00
|
|
|
* `--disable-initial-exec-tls`
|
|
|
|
|
|
|
|
Disable the initial-exec TLS model for jemalloc's internal thread-local
|
|
|
|
storage (on those platforms that support explicit settings). This can allow
|
2018-05-03 05:35:31 +08:00
|
|
|
jemalloc to be dynamically loaded after program startup (e.g. using dlopen).
|
2018-04-18 03:52:22 +08:00
|
|
|
Note that in this case, there will be two malloc implementations operating
|
|
|
|
in the same process, which will almost certainly result in confusing runtime
|
|
|
|
crashes if pointers leak from one implementation to the other.
|
|
|
|
|
2018-06-08 03:27:19 +08:00
|
|
|
* `--disable-libdl`
|
|
|
|
|
|
|
|
Disable the usage of libdl, namely dlsym(3) which is required by the lazy
|
|
|
|
lock option. This can allow building static binaries.
|
|
|
|
|
2009-06-26 09:06:48 +08:00
|
|
|
The following environment variables (not a definitive list) impact configure's
|
|
|
|
behavior:
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `CFLAGS="?"`
|
|
|
|
* `CXXFLAGS="?"`
|
|
|
|
|
2016-12-16 23:18:55 +08:00
|
|
|
Pass these flags to the C/C++ compiler. Any flags set by the configure
|
|
|
|
script are prepended, which means explicitly set flags generally take
|
|
|
|
precedence. Take care when specifying flags such as -Werror, because
|
|
|
|
configure tests may be affected in undesirable ways.
|
2009-06-26 09:06:48 +08:00
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `EXTRA_CFLAGS="?"`
|
|
|
|
* `EXTRA_CXXFLAGS="?"`
|
|
|
|
|
2016-12-16 23:18:55 +08:00
|
|
|
Append these flags to CFLAGS/CXXFLAGS, without passing them to the
|
|
|
|
compiler(s) during configuration. 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.
|
2009-06-26 09:06:48 +08:00
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `CPPFLAGS="?"`
|
|
|
|
|
2009-06-26 09:06:48 +08:00
|
|
|
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.
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `LD_LIBRARY_PATH="?"`
|
|
|
|
|
2009-06-26 09:06:48 +08:00
|
|
|
'ld' uses this colon-separated list to find libraries.
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `LDFLAGS="?"`
|
|
|
|
|
2009-06-26 09:06:48 +08:00
|
|
|
Pass these flags when linking.
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `PATH="?"`
|
|
|
|
|
2009-06-26 09:06:48 +08:00
|
|
|
'configure' uses this to find programs.
|
|
|
|
|
2016-11-17 02:56:40 +08:00
|
|
|
In some cases it may be necessary to work around configuration results that do
|
2016-12-01 01:57:12 +08:00
|
|
|
not match reality. For example, Linux 4.5 added support for the MADV_FREE flag
|
|
|
|
to madvise(2), which can cause problems if building on a host with MADV_FREE
|
|
|
|
support and deploying to a target without. To work around this, use a cache
|
|
|
|
file to override the relevant configuration variable defined in configure.ac,
|
|
|
|
e.g.:
|
2016-11-17 02:56:40 +08:00
|
|
|
|
2016-12-01 01:57:12 +08:00
|
|
|
echo "je_cv_madv_free=no" > config.cache && ./configure -C
|
2016-11-17 02:56:40 +08:00
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
|
|
|
|
## Advanced compilation
|
2009-06-26 09:06:48 +08:00
|
|
|
|
2012-03-03 08:38:37 +08:00
|
|
|
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
|
|
|
|
|
2010-03-04 07:48:20 +08:00
|
|
|
To install only parts of jemalloc, use the following targets:
|
2009-06-26 09:06:48 +08:00
|
|
|
|
2010-04-12 10:02:43 +08:00
|
|
|
install_bin
|
2010-03-04 07:48:20 +08:00
|
|
|
install_include
|
2012-03-03 08:38:37 +08:00
|
|
|
install_lib_shared
|
|
|
|
install_lib_static
|
2018-04-22 05:53:03 +08:00
|
|
|
install_lib_pc
|
2010-03-04 07:48:20 +08:00
|
|
|
install_lib
|
2012-03-03 08:38:37 +08:00
|
|
|
install_doc_html
|
|
|
|
install_doc_man
|
2010-11-25 14:00:02 +08:00
|
|
|
install_doc
|
2009-06-26 09:06:48 +08:00
|
|
|
|
|
|
|
To clean up build results to varying degrees, use the following make targets:
|
|
|
|
|
|
|
|
clean
|
|
|
|
distclean
|
|
|
|
relclean
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
|
|
|
|
## Advanced installation
|
2009-06-26 09:06:48 +08:00
|
|
|
|
|
|
|
Optionally, define make variables when invoking make, including (not
|
|
|
|
exclusively):
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `INCLUDEDIR="?"`
|
|
|
|
|
2009-06-26 09:06:48 +08:00
|
|
|
Use this as the installation prefix for header files.
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `LIBDIR="?"`
|
|
|
|
|
2009-06-26 09:06:48 +08:00
|
|
|
Use this as the installation prefix for libraries.
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `MANDIR="?"`
|
|
|
|
|
2009-06-26 09:06:48 +08:00
|
|
|
Use this as the installation prefix for man pages.
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `DESTDIR="?"`
|
|
|
|
|
2010-12-17 06:13:46 +08:00
|
|
|
Prepend DESTDIR to INCLUDEDIR, LIBDIR, DATADIR, and MANDIR. This is useful
|
|
|
|
when installing to a different path than was specified via --prefix.
|
2010-03-04 07:48:20 +08:00
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `CC="?"`
|
|
|
|
|
2009-06-26 09:06:48 +08:00
|
|
|
Use this to invoke the C compiler.
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `CFLAGS="?"`
|
|
|
|
|
2009-06-26 09:06:48 +08:00
|
|
|
Pass these flags to the compiler.
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `CPPFLAGS="?"`
|
|
|
|
|
2009-06-26 09:06:48 +08:00
|
|
|
Pass these flags to the C preprocessor.
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `LDFLAGS="?"`
|
|
|
|
|
2009-06-26 09:06:48 +08:00
|
|
|
Pass these flags when linking.
|
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
* `PATH="?"`
|
|
|
|
|
2009-06-26 09:06:48 +08:00
|
|
|
Use this to search for programs used during configuration and building.
|
|
|
|
|
2022-06-14 06:32:33 +08:00
|
|
|
## Building for Windows
|
|
|
|
|
|
|
|
There are at least two ways to build jemalloc's libraries for Windows. They
|
|
|
|
differ in their ease of use and flexibility.
|
|
|
|
|
|
|
|
### With MSVC solutions
|
|
|
|
This is the easy, but less flexible approach. It doesn't let you specify
|
|
|
|
arguments to the `configure` script.
|
|
|
|
|
|
|
|
1. Install Cygwin with at least the following packages:
|
|
|
|
* autoconf
|
|
|
|
* autogen
|
|
|
|
* gawk
|
|
|
|
* grep
|
|
|
|
* sed
|
|
|
|
|
|
|
|
2. Install Visual Studio 2015 or 2017 with Visual C++
|
|
|
|
|
|
|
|
3. Add Cygwin\bin to the PATH environment variable
|
|
|
|
|
|
|
|
4. Open "x64 Native Tools Command Prompt for VS 2017"
|
|
|
|
(note: x86/x64 doesn't matter at this point)
|
|
|
|
|
|
|
|
5. Generate header files:
|
|
|
|
sh -c "CC=cl ./autogen.sh"
|
|
|
|
|
|
|
|
6. Now the project can be opened and built in Visual Studio:
|
|
|
|
msvc\jemalloc_vc2017.sln
|
|
|
|
|
|
|
|
### With MSYS
|
|
|
|
This is a more involved approach that offers the same configuration flexibility
|
|
|
|
as Linux builds. We use it for our CI workflow to test different jemalloc
|
|
|
|
configurations on Windows.
|
|
|
|
|
|
|
|
1. Install the prerequisites
|
|
|
|
1. MSYS2
|
|
|
|
2. Chocolatey
|
|
|
|
3. Visual Studio if you want to compile with MSVC compiler
|
|
|
|
|
|
|
|
2. Run your bash emulation. It could be MSYS2 or Git Bash (this manual was
|
|
|
|
tested on both)
|
|
|
|
3. Manually and selectively follow
|
|
|
|
[before_install.sh](https://github.com/jemalloc/jemalloc/blob/dev/scripts/windows/before_install.sh)
|
|
|
|
script.
|
|
|
|
1. Skip the `TRAVIS_OS_NAME` check, `rm -rf C:/tools/msys64` and `choco
|
|
|
|
uninstall/upgrade` part.
|
|
|
|
2. If using `msys2` shell, add path to `RefreshEnv.cmd` to `PATH`:
|
|
|
|
`PATH="$PATH:/c/ProgramData/chocolatey/bin"`
|
|
|
|
3. Assign `msys_shell_cmd`, `msys2`, `mingw32` and `mingw64` as in the
|
|
|
|
script.
|
|
|
|
4. Pick `CROSS_COMPILE_32BIT` , `CC` and `USE_MSVC` values depending on
|
|
|
|
your needs. For instance, if you'd like to build for x86_64 Windows
|
|
|
|
with `gcc`, then `CROSS_COMPILE_32BIT="no"`, `CC="gcc"` and
|
|
|
|
`USE_MSVC=""`. If you'd like to build for x86 Windows with `cl.exe`,
|
|
|
|
then `CROSS_COMPILE_32BIT="yes"`, `CC="cl.exe"`, `USE_MSVC="x86"`.
|
|
|
|
For x86_64 builds with `cl.exe`, assign `USE_MSVC="amd64"` and
|
|
|
|
`CROSS_COMPILE_32BIT="no"`.
|
|
|
|
5. Replace the path to `vcvarsall.bat` with the path on your system. For
|
|
|
|
instance, on my Windows PC with Visual Studio 17, the path is
|
|
|
|
`C:\Program Files (x86)\Microsoft Visual
|
|
|
|
Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat`.
|
|
|
|
6. Execute the rest of the script. It will install the required
|
|
|
|
dependencies and assign the variable `build_env`, which is a function
|
|
|
|
that executes following commands with the correct environment
|
|
|
|
variables set.
|
|
|
|
4. Use `$build_env <command>` as you would in a Linux shell:
|
|
|
|
1. `$build_env autoconf`
|
|
|
|
2. `$build_env ./configure CC="<desired compiler>" <configuration flags>`
|
|
|
|
3. `$build_env mingw32-make`
|
|
|
|
|
|
|
|
If you're having any issues with the above, ensure the following:
|
|
|
|
|
|
|
|
5. When you run `cmd //C RefreshEnv.cmd`, you get an output line starting with
|
|
|
|
`Refreshing` . If it errors saying `RefreshEnv.cmd` is not found, then you
|
|
|
|
need to add it to your `PATH` as described above in item 3.2
|
|
|
|
|
|
|
|
6. When you run `cmd //C $vcvarsall`, it prints a bunch of environment
|
|
|
|
variables. Otherwise, check the path to the `vcvarsall.bat` in `$vcvarsall`
|
|
|
|
script and fix it.
|
2017-05-12 02:57:05 +08:00
|
|
|
|
|
|
|
## Development
|
2009-06-26 09:06:48 +08:00
|
|
|
|
|
|
|
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
|
2010-09-12 13:47:39 +08:00
|
|
|
|
2017-05-12 02:57:05 +08:00
|
|
|
|
|
|
|
## Documentation
|
2010-09-12 13:47:39 +08:00
|
|
|
|
2010-11-25 14:00:02 +08:00
|
|
|
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
|
2012-04-24 03:49:23 +08:00
|
|
|
prior to installation via the following command:
|
2010-09-12 13:47:39 +08:00
|
|
|
|
2010-11-25 14:00:02 +08:00
|
|
|
nroff -man -t doc/jemalloc.3
|