Refactor --with-jemalloc option
Find jemalloc header first, then using the found header, try [with mangle, without mangle] x [no more additional libraries, adding jemalloc] combination.
This commit is contained in:
parent
82d425515d
commit
e8d9539373
Notes:
git
2021-07-08 00:53:59 +09:00
74
configure.ac
74
configure.ac
@ -1297,45 +1297,53 @@ AC_ARG_WITH([jemalloc],
|
||||
[AS_HELP_STRING([--with-jemalloc],[use jemalloc allocator])],
|
||||
[with_jemalloc=$withval], [with_jemalloc=no])
|
||||
AS_IF([test "x$with_jemalloc" != xno],[
|
||||
AC_SEARCH_LIBS([malloc_conf], [jemalloc],
|
||||
[
|
||||
AC_DEFINE(HAVE_LIBJEMALLOC, 1)
|
||||
with_jemalloc=yes
|
||||
],
|
||||
[test x$with_jemalloc = xyes && with_jemalloc=no])
|
||||
for malloc_header in jemalloc/jemalloc.h jemalloc.h; do
|
||||
AC_CHECK_HEADER($malloc_header, [break], [malloc_header=])
|
||||
done
|
||||
# find jemalloc header first
|
||||
malloc_header=
|
||||
AC_CHECK_HEADER(jemalloc/jemalloc.h, [malloc_header=jemalloc/jemalloc.h], [
|
||||
AC_CHECK_HEADER(jemalloc.h, [malloc_header=jemalloc.h])
|
||||
])
|
||||
AS_IF([test "$malloc_header" != ""], [
|
||||
AC_DEFINE_UNQUOTED(RUBY_ALTERNATIVE_MALLOC_HEADER, [<$malloc_header>])
|
||||
],
|
||||
[test x$with_jemalloc = xyes && with_jemalloc=no])
|
||||
AS_IF([test "x$with_jemalloc" != xyes], [
|
||||
AC_CACHE_CHECK([for jemalloc with JEMALLOC_MANGLE], rb_cv_jemalloc_demangle,
|
||||
[AC_LINK_IFELSE([AC_LANG_PROGRAM([@%:@define JEMALLOC_MANGLE 1
|
||||
@%:@ifdef RUBY_ALTERNATIVE_MALLOC_HEADER
|
||||
@%:@include RUBY_ALTERNATIVE_MALLOC_HEADER
|
||||
@%:@else
|
||||
extern const char *malloc_conf;
|
||||
@%:@endif], [return !&malloc_conf])],
|
||||
[rb_cv_jemalloc_demangle=yes],
|
||||
[rb_cv_jemalloc_demangle=no])
|
||||
])
|
||||
])
|
||||
AS_IF([test "x$rb_cv_jemalloc_demangle" = xyes], [
|
||||
AC_DEFINE(JEMALLOC_MANGLE)
|
||||
with_jemalloc=yes
|
||||
save_LIBS="$LIBS"
|
||||
AC_CACHE_CHECK([for jemalloc library], rb_cv_jemalloc_library, [
|
||||
rb_cv_jemalloc_library=no
|
||||
# try [with mangle, without mangle] x [no more additional
|
||||
# libraries, adding jemalloc] combination, using the jemalloc
|
||||
# header found above.
|
||||
for mangle in '' mangle; do
|
||||
for lib in '' -ljemalloc; do
|
||||
LIBS="${lib:+$lib }$LIBS"
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([${mangle:+@%:@define JEMALLOC_MANGLE 1}
|
||||
@%:@include <stdio.h>
|
||||
@%:@ifdef RUBY_ALTERNATIVE_MALLOC_HEADER
|
||||
@%:@include RUBY_ALTERNATIVE_MALLOC_HEADER
|
||||
@%:@else
|
||||
extern const char *malloc_conf;
|
||||
@%:@endif],
|
||||
[/* access at runtime not to be optimized away */
|
||||
if (malloc_conf) printf("malloc_conf=%s\n", malloc_conf);])],
|
||||
[rb_cv_jemalloc_library="${lib:-none required}${mangle:+ with mangle}"])
|
||||
LIBS="$save_LIBS"
|
||||
test "${rb_cv_jemalloc_library}" = no || break 2
|
||||
done
|
||||
done
|
||||
])
|
||||
with_jemalloc=${rb_cv_jemalloc_library}
|
||||
AS_CASE(["$with_jemalloc"],
|
||||
[no],
|
||||
[AC_MSG_ERROR([jemalloc requested but not found])],
|
||||
[-l*], [
|
||||
set dummy $with_jemalloc
|
||||
LIBS="$2 $LIBS"
|
||||
])
|
||||
AS_CASE(["$with_jemalloc"],
|
||||
[yes],
|
||||
[
|
||||
AC_DEFINE(HAVE_MALLOC_CONF)
|
||||
ac_cv_func_malloc_usable_size=yes
|
||||
],
|
||||
[no],
|
||||
[AC_MSG_ERROR([jemalloc requested but not found])
|
||||
[*" with mangle"], [
|
||||
AC_DEFINE(JEMALLOC_MANGLE)
|
||||
])
|
||||
])
|
||||
AC_DEFINE(HAVE_MALLOC_CONF)
|
||||
ac_cv_func_malloc_usable_size=yes
|
||||
]) # with_jemalloc
|
||||
|
||||
dnl check for large file stuff
|
||||
mv confdefs.h confdefs1.h
|
||||
|
Loading…
x
Reference in New Issue
Block a user