From 52c985ff2759f867c759797d85d185264122d3d1 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 16 Nov 2021 15:37:10 +0800 Subject: [PATCH] [TD-11070]: cmake jemalloc script. (#8697) --- cmake/platform.inc | 2 +- deps/CMakeLists.txt | 2 ++ packaging/release.sh | 7 ++++- packaging/tools/make_install.sh | 47 ++++++++++++++++----------------- 4 files changed, 32 insertions(+), 26 deletions(-) diff --git a/cmake/platform.inc b/cmake/platform.inc index 328c5f23ee..463a5ebbab 100755 --- a/cmake/platform.inc +++ b/cmake/platform.inc @@ -36,7 +36,7 @@ IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux") # Get OS information and store in variable TD_OS_INFO. # execute_process(COMMAND chmod 777 ${TD_COMMUNITY_DIR}/packaging/tools/get_os.sh) - execute_process(COMMAND sh ${TD_COMMUNITY_DIR}/packaging/tools/get_os.sh "" OUTPUT_VARIABLE TD_OS_INFO) + execute_process(COMMAND ${TD_COMMUNITY_DIR}/packaging/tools/get_os.sh "" OUTPUT_VARIABLE TD_OS_INFO) MESSAGE(STATUS "The current os is " ${TD_OS_INFO}) SET(TD_LINUX TRUE) diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index 773a791a25..38f36c4ed6 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -55,6 +55,7 @@ IF (TD_LINUX_64 AND JEMALLOC_ENABLED) MESSAGE("") MESSAGE("setup deps/jemalloc, current source dir:" ${CMAKE_CURRENT_SOURCE_DIR}) MESSAGE("binary dir:" ${CMAKE_BINARY_DIR}) + include(ExternalProject) ExternalProject_Add(jemalloc PREFIX "jemalloc" SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/jemalloc @@ -62,6 +63,7 @@ IF (TD_LINUX_64 AND JEMALLOC_ENABLED) CONFIGURE_COMMAND ./autogen.sh COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/build/ BUILD_COMMAND ${MAKE} ) + INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/build/include) ENDIF () IF (${TSZ_ENABLED} MATCHES "true") diff --git a/packaging/release.sh b/packaging/release.sh index b9fe25ec08..490188826d 100755 --- a/packaging/release.sh +++ b/packaging/release.sh @@ -213,7 +213,12 @@ else exit 1 fi -make -j8 && ${csudo} make install +if [[ "$allocator" == "jemalloc" ]]; then + # jemalloc need compile first, so disable parallel build + make V=1 && ${csudo} make install +else + make -j8 && ${csudo} make install +fi cd ${curr_dir} diff --git a/packaging/tools/make_install.sh b/packaging/tools/make_install.sh index f883c82270..093b2bb0a7 100755 --- a/packaging/tools/make_install.sh +++ b/packaging/tools/make_install.sh @@ -204,31 +204,31 @@ function install_jemalloc() { /usr/bin/install -c -d /usr/local/bin if [ -f "${binary_dir}/build/bin/jemalloc-config" ]; then - /usr/bin/install -c -m 755 ${binary_dir}/build/bin/jemalloc-config /usr/local/bin + ${csudo} /usr/bin/install -c -m 755 ${binary_dir}/build/bin/jemalloc-config /usr/local/bin fi if [ -f "${binary_dir}/build/bin/jemalloc.sh" ]; then - /usr/bin/install -c -m 755 ${binary_dir}/build/bin/jemalloc.sh /usr/local/bin + ${csudo} /usr/bin/install -c -m 755 ${binary_dir}/build/bin/jemalloc.sh /usr/local/bin fi if [ -f "${binary_dir}/build/bin/jeprof" ]; then - /usr/bin/install -c -m 755 ${binary_dir}/build/bin/jeprof /usr/local/bin + ${csudo} /usr/bin/install -c -m 755 ${binary_dir}/build/bin/jeprof /usr/local/bin fi if [ -f "${binary_dir}/build/include/jemalloc/jemalloc.h" ]; then - /usr/bin/install -c -d /usr/local/include/jemalloc - /usr/bin/install -c -m 644 ${binary_dir}/build/include/jemalloc/jemalloc.h\ + ${csudo} /usr/bin/install -c -d /usr/local/include/jemalloc + ${csudo} /usr/bin/install -c -m 644 ${binary_dir}/build/include/jemalloc/jemalloc.h\ /usr/local/include/jemalloc fi if [ -f "${binary_dir}/build/lib/libjemalloc.so.2" ]; then - /usr/bin/install -c -d /usr/local/lib - /usr/bin/install -c -m 755 ${binary_dir}/build/lib/libjemalloc.so.2 /usr/local/lib - ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so - /usr/bin/install -c -d /usr/local/lib + ${csudo} /usr/bin/install -c -d /usr/local/lib + ${csudo} /usr/bin/install -c -m 755 ${binary_dir}/build/lib/libjemalloc.so.2 /usr/local/lib + ${csudo} ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so + ${csudo} /usr/bin/install -c -d /usr/local/lib [ -f ${binary_dir}/build/lib/libjemalloc.a ] && - /usr/bin/install -c -m 755 ${binary_dir}/build/lib/libjemalloc.a /usr/local/lib + ${csudo} /usr/bin/install -c -m 755 ${binary_dir}/build/lib/libjemalloc.a /usr/local/lib [ -f ${binary_dir}/build/lib/libjemalloc_pic.a ] && - /usr/bin/install -c -m 755 ${binary_dir}/build/lib/libjemalloc_pic.a /usr/local/lib + ${csudo} /usr/bin/install -c -m 755 ${binary_dir}/build/lib/libjemalloc_pic.a /usr/local/lib if [ -f "${binary_dir}/build/lib/pkgconfig/jemalloc.pc" ]; then - /usr/bin/install -c -d /usr/local/lib/pkgconfig - /usr/bin/install -c -m 644 ${binary_dir}/build/lib/pkgconfig/jemalloc.pc\ + ${csudo} /usr/bin/install -c -d /usr/local/lib/pkgconfig + ${csudo} /usr/bin/install -c -m 644 ${binary_dir}/build/lib/pkgconfig/jemalloc.pc\ /usr/local/lib/pkgconfig fi if [ -d /etc/ld.so.conf.d ]; then @@ -239,29 +239,28 @@ function install_jemalloc() { fi fi if [ -f "${binary_dir}/build/share/doc/jemalloc/jemalloc.html" ]; then - /usr/bin/install -c -d /usr/local/share/doc/jemalloc - /usr/bin/install -c -m 644 ${binary_dir}/build/share/doc/jemalloc/jemalloc.html\ + ${csudo} /usr/bin/install -c -d /usr/local/share/doc/jemalloc + ${csudo} /usr/bin/install -c -m 644 ${binary_dir}/build/share/doc/jemalloc/jemalloc.html\ /usr/local/share/doc/jemalloc fi if [ -f "${binary_dir}/build/share/man/man3/jemalloc.3" ]; then - /usr/bin/install -c -d /usr/local/share/man/man3 - /usr/bin/install -c -m 644 ${binary_dir}/build/share/man/man3/jemalloc.3\ + ${csudo} /usr/bin/install -c -d /usr/local/share/man/man3 + ${csudo} /usr/bin/install -c -m 644 ${binary_dir}/build/share/man/man3/jemalloc.3\ /usr/local/share/man/man3 fi - fi } function install_avro() { if [ "$osType" != "Darwin" ]; then if [ -f "${binary_dir}/build/$1/libavro.so.23.0.0" ]; then - /usr/bin/install -c -d /usr/local/$1 - /usr/bin/install -c -m 755 ${binary_dir}/build/$1/libavro.so.23.0.0 /usr/local/$1 - ln -sf libavro.so.23.0.0 /usr/local/$1/libavro.so.23 - ln -sf libavro.so.23 /usr/local/$1/libavro.so - /usr/bin/install -c -d /usr/local/$1 + ${csudo} /usr/bin/install -c -d /usr/local/$1 + ${csudo} /usr/bin/install -c -m 755 ${binary_dir}/build/$1/libavro.so.23.0.0 /usr/local/$1 + ${csudo} ln -sf libavro.so.23.0.0 /usr/local/$1/libavro.so.23 + ${csudo} ln -sf libavro.so.23 /usr/local/$1/libavro.so + ${csudo} /usr/bin/install -c -d /usr/local/$1 [ -f ${binary_dir}/build/$1/libavro.a ] && - /usr/bin/install -c -m 755 ${binary_dir}/build/$1/libavro.a /usr/local/$1 + ${csudo} /usr/bin/install -c -m 755 ${binary_dir}/build/$1/libavro.a /usr/local/$1 if [ -d /etc/ld.so.conf.d ]; then echo "/usr/local/$1" | ${csudo} tee /etc/ld.so.conf.d/libavro.conf -- GitLab