USE_JEMALLOC in the OSS build if we have jemalloc
authorWez Furlong <wez@fb.com>
Wed, 7 Dec 2016 20:53:52 +0000 (12:53 -0800)
committerFacebook Github Bot <facebook-github-bot-bot@fb.com>
Wed, 7 Dec 2016 21:08:30 +0000 (13:08 -0800)
commite44d8a6211a820ce24c358dc63515278ccf23d64
tree8c27454c730fd70a2cd0a55797dc115b4e98b85e
parent77d5e54744c2ab78ffc06e26085bf18725ec73e1
USE_JEMALLOC in the OSS build if we have jemalloc

Summary:
Nothing defines USE_JEMALLOC in the OSS build today and that causes
some portability problems.

Specifically, the homebrew recipe will make libjemalloc available and our
configure script will detect it and add it to the library flags.

Our subsequent check for `malloc_usable_size` then finds this function in
libjemalloc.

When later attempting to build wangle against the homebrew folly we get
compilation failures because the prototype for `malloc_usable_size` is only
available in the jemalloc headers and nothing in the saved configuration for
folly is set up for this to be pulled in as it it guarded by `USE_JEMALLOC`.

This attempts to resolve the situation by forcing on `USE_JEMALLOC` when
we detect the library in configure.

This is made a little more complicated because we cannot set `USE_JEMALLOC`
in the OSS build; it gets rewritten to have a `FOLLY_` prefix.  Since we
have code outside of folly that requires that this symbol be `USE_JEMALLOC`,
I've changed the conditional to check for both flavors of the symbol, with
and without the prefix.

Reviewed By: yfeldblum

Differential Revision: D4289176

fbshipit-source-id: 756bc815c3ef1fac454e603feb72155d98c5aadd
folly/configure.ac
folly/portability/Malloc.cpp
folly/portability/Malloc.h