Add the --disable-initial-exec-tls configure option.

Right now we always make our TLS use the initial-exec model if the compiler
supports it.  This change allows configure-time disabling of this setting, which
can be helpful when dynamically loading jemalloc is the only option.
This commit is contained in:
David Goldblatt 2018-04-17 12:52:22 -07:00 committed by David Goldblatt
parent e40b2f75bd
commit a62e42baeb
2 changed files with 35 additions and 6 deletions

View File

@ -265,6 +265,15 @@ any of the following arguments (not a definitive list) to 'configure':
configuration, jemalloc will provide additional size classes that are not
16-byte-aligned (24, 40, and 56).
* `--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
jemalloc to be dynamically loaded after program starup (e.g. using dlopen).
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.
The following environment variables (not a definitive list) impact configure's
behavior:

View File

@ -733,12 +733,9 @@ JE_COMPILABLE([tls_model attribute], [],
foo = 0;],
[je_cv_tls_model])
JE_CFLAGS_RESTORE()
if test "x${je_cv_tls_model}" = "xyes" ; then
AC_DEFINE([JEMALLOC_TLS_MODEL],
[__attribute__((tls_model("initial-exec")))])
else
AC_DEFINE([JEMALLOC_TLS_MODEL], [ ])
fi
dnl (Setting of JEMALLOC_TLS_MODEL is done later, after we've checked for
dnl --disable-initial-exec-tls)
dnl Check for alloc_size attribute support.
JE_CFLAGS_SAVE()
JE_CFLAGS_ADD([-Werror])
@ -1993,6 +1990,29 @@ if test "x${enable_zone_allocator}" = "x1" ; then
AC_DEFINE([JEMALLOC_ZONE], [ ])
fi
dnl ============================================================================
dnl Use initial-exec TLS by default.
AC_ARG_ENABLE([initial-exec-tls],
[AS_HELP_STRING([--disable-initial-exec-tls],
[Disable the initial-exec tls model])],
[if test "x$enable_initial_exec_tls" = "xno" ; then
enable_initial_exec_tls="0"
else
enable_initial_exec_tls="1"
fi
],
[enable_initial_exec_tls="1"]
)
AC_SUBST([enable_initial_exec_tls])
if test "x${je_cv_tls_model}" = "xyes" -a \
"x${enable_initial_exec_tls}" = "x1" ; then
AC_DEFINE([JEMALLOC_TLS_MODEL],
[__attribute__((tls_model("initial-exec")))])
else
AC_DEFINE([JEMALLOC_TLS_MODEL], [ ])
fi
dnl ============================================================================
dnl Enable background threads if possible.