#49747 Ticket 48377 - Bundle jemalloc
Closed 3 years ago by spichugi. Opened 5 years ago by mreynolds.
mreynolds/389-ds-base ticket48377  into  master

@@ -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

file modified
+10
@@ -9,6 +9,9 @@ 

  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 @@ 

  	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 @@ 

  	-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 @@ 

  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

file modified
+48 -20
@@ -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:    clang

  BuildRequires:    compiler-rt

  %else

+ BuildRequires:    gcc

  BuildRequires:    gcc-c++

  %if %{use_asan}

  BuildRequires:    libasan
@@ -123,10 +123,6 @@ 

  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 @@ 

  %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 @@ 

  # 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 @@ 

  %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 @@ 

  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 @@ 

  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 @@ 

             --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 @@ 

  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 @@ 

  

  %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 @@ 

  %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 @@ 

  %{_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 @@ 

  %{_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

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: ?

rebased onto d5e1164

5 years ago

Pull-Request has been merged by mreynolds

5 years ago

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This pull request has been cloned to Github as issue and is available here:
- https://github.com/389ds/389-ds-base/issues/2806

If you want to continue to work on the PR, please navigate to the github issue,
download the patch from the attachments and file a new pull request.

Thank you for understanding. We apologize for all inconvenience.

Pull-Request has been closed by spichugi

3 years ago