From d5e1164a67783e3d9a008420386f98cdfa3a8a1f Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Jun 04 2018 13:44:30 +0000 Subject: Ticket 48377 - Bundle jemalloc Descriptrion: gperftools is going away in RHEL, that includes tcmalloc, so we now need to bundle jemalloc again. https://pagure.io/389-ds-base/issue/48377 Reviewed by: vashirov(Thanks!) --- diff --git a/ldap/admin/src/base-initconfig.in b/ldap/admin/src/base-initconfig.in index 1403ada..f9e9bdc 100644 --- a/ldap/admin/src/base-initconfig.in +++ b/ldap/admin/src/base-initconfig.in @@ -40,3 +40,9 @@ # is a problem and fail to start. # If using systemd, omit the "; export PID_TIME" at the end. #PID_TIME=600 ; export PID_TIME + +# jemalloc is a general purpose malloc implementation that emphasizes +# fragmentation avoidance and scalable concurrency support. jemalloc +# has been shown to have a significant positive impact on the Directory +# Server's process size/growth. +LD_PRELOAD=@libdir@/@package_name@/lib/libjemalloc.so diff --git a/rpm.mk b/rpm.mk index b72fa5f..a62a15d 100644 --- a/rpm.mk +++ b/rpm.mk @@ -9,6 +9,9 @@ RPM_NAME_VERSION = $(PACKAGE)-$(RPM_VERSION)$(RPM_VERSION_PREREL) NAME_VERSION = $(PACKAGE)-$(RPM_VERSION)$(VERSION_PREREL) TARBALL = $(NAME_VERSION).tar.bz2 NUNC_STANS_ON = 1 +JEMALLOC_URL ?= $(shell rpmspec -P $(RPMBUILD)/SPECS/389-ds-base.spec | awk '/^Source3:/ {print $$2}') +JEMALLOC_TARBALL ?= $(shell basename "$(JEMALLOC_URL)") +BUNDLE_JEMALLOC = 1 # Some sanitizers are supported only by clang CLANG_ON = 0 @@ -37,6 +40,9 @@ tarballs: local-archive cd dist; tar cfj sources/$(TARBALL) $(NAME_VERSION) rm -rf dist/$(NAME_VERSION) cd dist/sources ; \ + if [ $(BUNDLE_JEMALLOC) -eq 1 ]; then \ + wget $(JEMALLOC_URL) ; \ + fi rpmroot: rm -rf $(RPMBUILD) @@ -55,6 +61,7 @@ rpmroot: -e s/__UBSAN_ON__/$(UBSAN_ON)/ \ -e s/__PERL_ON__/$(PERL_ON)/ \ -e s/__CLANG_ON__/$(CLANG_ON)/ \ + -e s/__BUNDLE_JEMALLOC__/$(BUNDLE_JEMALLOC)/ \ rpm/$(PACKAGE).spec.in > $(RPMBUILD)/SPECS/$(PACKAGE).spec rpmdistdir: @@ -66,6 +73,9 @@ srpmdistdir: rpmbuildprep: cp dist/sources/$(TARBALL) $(RPMBUILD)/SOURCES/ cp rpm/$(PACKAGE)-* $(RPMBUILD)/SOURCES/ + if [ $(BUNDLE_JEMALLOC) -eq 1 ]; then \ + cp dist/sources/$(JEMALLOC_TARBALL) $(RPMBUILD)/SOURCES/ ; \ + fi srpms: rpmroot srpmdistdir tarballs rpmbuildprep rpmbuild --define "_topdir $(RPMBUILD)" -bs $(RPMBUILD)/SPECS/$(PACKAGE).spec diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in index a910ad9..b773136 100644 --- a/rpm/389-ds-base.spec.in +++ b/rpm/389-ds-base.spec.in @@ -2,6 +2,12 @@ %global pkgname dirsrv %global srcname 389-ds-base +%global bundle_jemalloc __BUNDLE_JEMALLOC__ +%if %{bundle_jemalloc} +%global jemalloc_name jemalloc +%global jemalloc_ver 5.0.1 +%endif + # This is used in certain builds to help us know if it has extra features. %global variant base # for a pre-release, define the prerel field e.g. .a1 .rc2 - comment out for official release @@ -29,14 +35,7 @@ %define nss_version 3.11 %if %{use_asan} || %{use_msan} || %{use_tsan} || %{use_ubsan} -%global use_tcmalloc 0 %global variant base-xsan -%else -%if %{_arch} != "s390x" && %{_arch} != "s390" && !%{use_rust} -%global use_tcmalloc 1 -%else -%global use_tcmalloc 0 -%endif %endif # Use Clang instead of GCC @@ -81,6 +80,7 @@ BuildRequires: libatomic BuildRequires: clang BuildRequires: compiler-rt %else +BuildRequires: gcc BuildRequires: gcc-c++ %if %{use_asan} BuildRequires: libasan @@ -123,10 +123,6 @@ BuildRequires: python%{python3_pkgversion} BuildRequires: python%{python3_pkgversion}-devel BuildRequires: python%{python3_pkgversion}-setuptools -%if %{use_tcmalloc} -BuildRequires: gperftools-devel -%endif - # For cockpit BuildRequires: rsync # END BUILD REQUIRES @@ -137,10 +133,7 @@ Requires: %{name}-libs = %{version}-%{release} %if 0%{?rhel} > 7 || 0%{?fedora} Requires: python%{python3_pkgversion}-lib389 = %{version}-%{release} %endif -# Attach to -base our script deps -%if %{use_tcmalloc} -Requires: gperftools-libs -%endif + # this is needed for using semanage from our setup scripts Requires: policycoreutils-python # This is needed for our future move to python selinux interaction. @@ -184,6 +177,9 @@ Source0: http://www.port389.org/sources/%{name}-%{version}%{?prerel}.ta # 389-ds-git.sh should be used to generate the source tarball from git Source1: %{name}-git.sh Source2: %{name}-devel.README +%if %{bundle_jemalloc} +Source3: https://github.com/jemalloc/%{jemalloc_name}/releases/download/%{jemalloc_ver}/%{jemalloc_name}-%{jemalloc_ver}.tar.bz2 +%endif %description 389 Directory Server is an LDAPv3 compliant server. The base package includes @@ -309,6 +305,10 @@ A cockpit UI Plugin for configuring and administering the 389 Directory Server %prep %setup -q -n %{name}-%{version}%{?prerel} +%if %{bundle_jemalloc} +%setup -q -n %{name}-%{version}%{?prerel} -T -D -b 3 +%endif + cp %{SOURCE2} README.devel %build @@ -339,10 +339,6 @@ TSAN_FLAGS="--enable-tsan --enable-debug" UBSAN_FLAGS="--enable-ubsan --enable-debug" %endif -%if %{use_tcmalloc} -TCMALLOC_FLAGS="--enable-tcmalloc" -%endif - %if %{use_rust} RUST_FLAGS="--enable-rust" %endif @@ -351,6 +347,16 @@ RUST_FLAGS="--enable-rust" PERL_FLAGS="--disable-perl" %endif +%if %{bundle_jemalloc} +# Build jemalloc +pushd ../%{jemalloc_name}-%{jemalloc_ver} +%configure \ + --libdir=%{_libdir}/%{pkgname}/lib \ + --bindir=%{_libdir}/%{pkgname}/bin +make +popd +%endif + # Rebuild the autotool artifacts now. autoreconf -fiv @@ -360,7 +366,7 @@ autoreconf -fiv --with-systemdsystemconfdir=%{_sysconfdir}/systemd/system \ --with-systemdgroupname=%{groupname} \ --libexecdir=%{_libexecdir}/%{pkgname} \ - $NSSARGS $TCMALLOC_FLAGS $ASAN_FLAGS $MSAN_FLAGS $TSAN_FLAGS $UBSAN_FLAGS $RUST_FLAGS $PERL_FLAGS $CLANG_FLAGS \ + $NSSARGS $ASAN_FLAGS $MSAN_FLAGS $TSAN_FLAGS $UBSAN_FLAGS $RUST_FLAGS $PERL_FLAGS $CLANG_FLAGS \ --enable-cmocka %if 0%{?rhel} > 7 || 0%{?fedora} @@ -425,6 +431,14 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/libsvrcore.la sed -i -e 's|#{{PERL-EXEC}}|#!/usr/bin/perl|' $RPM_BUILD_ROOT%{_datadir}/%{pkgname}/script-templates/template-*.pl %endif +%if %{bundle_jemalloc} +pushd ../%{jemalloc_name}-%{jemalloc_ver} +make DESTDIR="$RPM_BUILD_ROOT" install_lib install_bin +cp -pa COPYING ../%{name}-%{version}%{?prerel}/COPYING.jemalloc +cp -pa README ../%{name}-%{version}%{?prerel}/README.jemalloc +popd +%endif + %check # This checks the code, if it fails it prints why, then re-raises the fail to shortcircuit the rpm build. %if %{use_tsan} @@ -543,7 +557,11 @@ fi %files %defattr(-,root,root,-) +%if %{bundle_jemalloc} +%doc LICENSE LICENSE.GPLv3+ LICENSE.openssl README.jemalloc COPYING.jemalloc +%else %doc LICENSE LICENSE.GPLv3+ LICENSE.openssl +%endif %dir %{_sysconfdir}/%{pkgname} %dir %{_sysconfdir}/%{pkgname}/schema %config(noreplace)%{_sysconfdir}/%{pkgname}/schema/*.ldif @@ -625,6 +643,10 @@ fi %exclude %{_sbindir}/ldap-agent* %exclude %{_mandir}/man1/ldap-agent.1.gz %exclude %{_unitdir}/%{pkgname}-snmp.service +%if %{bundle_jemalloc} +%{_libdir}/%{pkgname}/lib/ +%{_libdir}/%{pkgname}/bin/ +%endif %files devel %defattr(-,root,root,-) @@ -638,6 +660,9 @@ fi %{_libdir}/%{pkgname}/libnunc-stans.so %{_libdir}/%{pkgname}/libsds.so %{_libdir}/%{pkgname}/libldaputil.so +%if %{bundle_jemalloc} +%{_libdir}/%{pkgname}/lib/libjemalloc.so +%endif %{_libdir}/pkgconfig/svrcore.pc %{_libdir}/pkgconfig/dirsrv.pc %{_libdir}/pkgconfig/libsds.pc @@ -653,6 +678,9 @@ fi %{_libdir}/%{pkgname}/libnunc-stans.so.* %{_libdir}/%{pkgname}/libsds.so.* %{_libdir}/%{pkgname}/libldaputil.so.* +%if %{bundle_jemalloc} +%{_libdir}/%{pkgname}/lib/libjemalloc.so.* +%endif %if %{use_rust} %{_libdir}/%{pkgname}/librsds.so %endif