Skip to content

Commit

Permalink
thirdparty: fix memkind build on el6 machines
Browse files Browse the repository at this point in the history
- The configure.ac shipped with the bundled jemalloc generates a broken
  configure script when invoked with autoconf 2.63 (i.e. the version of
  autoconf found on el6). Here's a patch that works around the issue and
  allows the build to proceed.
- The configure.ac in memkind requires autoconf 2.64. With a little
  finagling, we can drop that dependency to 2.63.
- The memkind build assumes that clock_gettime (needed by jemalloc) is found
  in glibc, but that's only true for new versions of glibc. In old versions,
  it's actually in librt. [1]

1. memkind/memkind#48

Change-Id: I02f3acebde7e3ea5400fe342c9c62736b8b43118
Reviewed-on: http://gerrit.cloudera.org:8080/13440
Reviewed-by: Alexey Serbin <[email protected]>
Reviewed-by: Andrew Wong <[email protected]>
Tested-by: Kudu Jenkins
  • Loading branch information
adembo authored and andrwng committed May 28, 2019
1 parent 84a6137 commit 7c3d45f
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 2 deletions.
7 changes: 5 additions & 2 deletions thirdparty/download-thirdparty.sh
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,14 @@ fetch_and_patch \
$NUMACTL_SOURCE \
$NUMACTL_PATCHLEVEL

MEMKIND_PATCHLEVEL=0
MEMKIND_PATCHLEVEL=3
fetch_and_patch \
memkind-${MEMKIND_VERSION}.tar.gz \
$MEMKIND_SOURCE \
$MEMKIND_PATCHLEVEL
$MEMKIND_PATCHLEVEL \
"patch -p1 < $TP_DIR/patches/memkind-fix-jemalloc-build-with-old-autoconf.patch" \
"patch -p1 < $TP_DIR/patches/memkind-fix-build-with-old-autoconf.patch" \
"patch -p1 < $TP_DIR/patches/memkind-fix-build-with-old-glibc.patch"

BOOST_PATCHLEVEL=1
fetch_and_patch \
Expand Down
32 changes: 32 additions & 0 deletions thirdparty/patches/memkind-fix-build-with-old-autoconf.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
commit c8dbc9f
Author: Adar Dembo <[email protected]>
Date: Sun May 26 14:20:51 2019 -0700

configure.ac: fixes for autoconf 2.63

diff --git a/configure.ac b/configure.ac
index 64c3200..ec5dbb1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,10 +25,10 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

-AC_PREREQ([2.64])
+AC_PREREQ([2.63])
AC_INIT([memkind],m4_esyscmd([tr -d '\n' < VERSION]))

-AC_CONFIG_MACRO_DIRS([m4])
+AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_SRCDIR([memkind.spec.mk])

@@ -36,7 +36,7 @@ AM_INIT_AUTOMAKE([-Wall -Werror foreign 1.11 silent-rules subdir-objects paralle
AM_SILENT_RULES([yes])

# Checks for programs and libraries.
-AM_PROG_AR
+m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
AC_PROG_CXX
AC_PROG_CC
AC_OPENMP
24 changes: 24 additions & 0 deletions thirdparty/patches/memkind-fix-build-with-old-glibc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
commit 2113b6b
Author: Adar Dembo <[email protected]>
Date: Sun May 26 14:39:46 2019 -0700

Makefile.am: fixes for building against older glibc

In older versions of glibc (such as the version found on el6 machines),
the clock_gettime function is in librt rather than in libc directly. Our
bundled jemalloc depends on clock_gettime and may link against librt, so
let's make sure the memkind library links against librt too.

diff --git a/Makefile.am b/Makefile.am
index f791ce7..de57d90 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -44,7 +44,7 @@ libmemkind_la_SOURCES = src/hbwmalloc.c \


libmemkind_la_LIBADD = jemalloc/obj/lib/libjemalloc_pic.a
-libmemkind_la_LDFLAGS = -version-info 0:1:0 -ldl
+libmemkind_la_LDFLAGS = -version-info 0:1:0 -ldl -lrt
include_HEADERS = include/hbw_allocator.h \
include/hbwmalloc.h \
include/memkind.h \
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
commit 608c2eb
Author: Adar Dembo <[email protected]>
Date: Sun May 26 14:00:50 2019 -0700

jemalloc: unroll dlsym checking logic in configure.ac

The nested calls here cause autoconf 2.63 to generate a broken script[1].
The upstream jemalloc response has been to require autoconf 2.68, but that
means we can't build jemalloc (and thus memkind) on el6.6. As a workaround,
we can simply unroll these nested calls.

1. https://github.com/jemalloc/jemalloc/issues/912

diff --git a/jemalloc/configure.ac b/jemalloc/configure.ac
index 5bd5442..cbc1e5d 100644
--- a/jemalloc/configure.ac
+++ b/jemalloc/configure.ac
@@ -1454,10 +1454,14 @@ if test "x$abi" != "xpecoff" ; then
have_pthread="1"
dnl Check if we have dlsym support.
have_dlsym="1"
- AC_CHECK_HEADERS([dlfcn.h],
- AC_CHECK_FUNC([dlsym], [],
- [AC_CHECK_LIB([dl], [dlsym], [LIBS="$LIBS -ldl"], [have_dlsym="0"])]),
- [have_dlsym="0"])
+ AC_CHECK_HEADERS([dlfcn.h], , [have_dlsym="0"])
+ check_dlsym_in_libdl="0"
+ if test "x$have_dlsym" = "x1" ; then
+ AC_CHECK_FUNC([dlsym], [], [check_dlsym_in_libdl="1"])
+ fi
+ if test "x$check_dlsym_in_libdl" = "x1" ; then
+ AC_CHECK_LIB([dl], [dlsym], [LIBS="$LIBS -ldl"], [have_dlsym="0"])
+ fi
if test "x$have_dlsym" = "x1" ; then
AC_DEFINE([JEMALLOC_HAVE_DLSYM], [ ])
fi

0 comments on commit 7c3d45f

Please sign in to comment.