Skip to content

Commit

Permalink
add script to build gperftools/libtcmalloc
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Yan committed May 30, 2022
1 parent 371cbb9 commit 3843734
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt install -y wget \
&& apt install -y python-dev \
&& apt install -y python3-dev \
&& apt install -y libgoogle-perftools-dev \
&& apt install -y dh-autoreconf \
51 changes: 51 additions & 0 deletions build_tcmalloc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bash

# =============================================================================
# FILENAME : build_tcmalloc.sh
# AUTHOR : Michael Yan
# CREATION : 2022-05-30
# Script to build gperftools/libtcmalloc with specified version.
#
# This script will the do the following steps
# 1. Create working directory
# 2. clone the tcmalloc source
# 3. checkout the desired release version
# 4. configure, build and install
# =============================================================================
set -e

if [ "$#" -ne 1 ]
then
echo "Usage: $0 <gperftools version>"
echo " For example, \"$0 2.7\""
echo " Please refer to https://github.com/gperftools/gperftools/releases"
exit 1
fi

PROJECT_FOLDER=$(pwd)
release_tag=$1
echo "Current project folder is $PROJECT_FOLDER"
build_folder=$PROJECT_FOLDER/build
mkdir -p $build_folder
cd $build_folder
scr_dir="gperftools"
if [ ! -d $scr_dir ]
then
echo "cloning gperftools ..."
git clone https://github.com/gperftools/gperftools.git
fi
cd $scr_dir

echo "checkout $release_tag"
branch_name=gperftools-$release_tag
if [ -n "$(git branch --list ${branch_name})" ]
then
echo "Branch name $branch_name already exists."
else
git checkout tags/$branch_name -b $branch_name
fi

echo "building..."
./autogen.sh
./configure
make clean && make -j 4 && sudo make install
2 changes: 1 addition & 1 deletion test/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ mallocTest_tcmalloc: mallocTest_tcmalloc.o
$(CXX) $(COMP_OPT) -o $@ $^ $(LIBS) -ltcmalloc

check-tcmalloc: mallocTest_tcmalloc
$(GDB) mallocTest_tcmalloc -q -ex 'switch_heap tc' -x verify.py
export LD_LIBRARY_PATH=/usr/local/lib; $(GDB) mallocTest_tcmalloc -q -x verify.py

clean:
rm *.o ${TARGETS}

0 comments on commit 3843734

Please sign in to comment.