This is an automated email from the ASF dual-hosted git repository. alexey pushed a commit to branch branch-1.17.x in repository https://gitbox.apache.org/repos/asf/kudu.git
commit 287443d682b0ff2bffcde8c97080638a4939392e Author: Alexey Serbin <[email protected]> AuthorDate: Fri Oct 6 16:49:49 2023 -0700 [thirdparty] build gperftools with libunwind support This patch enables libunwind support when building gperftools. That's to add stracktrace collection option based on libunwind: it seems that might be useful with current version of gperftools library (2.8.1) where frame-pointer-based option isn't available for aarch64, so the only collection method is libgcc-based. Change-Id: I59b307e3ee3ff9464934ef60ca439dcfcd496a2c Reviewed-on: http://gerrit.cloudera.org:8080/20544 Tested-by: Kudu Jenkins Reviewed-by: Marton Greber <[email protected]> Reviewed-by: Alexey Serbin <[email protected]> (cherry picked from commit 71ffac30f2869671e22af44739afc6c824918a09) Reviewed-on: http://gerrit.cloudera.org:8080/20569 Reviewed-by: Yingchun Lai <[email protected]> --- CMakeLists.txt | 9 ++++++++- thirdparty/build-definitions.sh | 39 ++++++++++++++++++++++++++++++--------- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c7af97d8c..5493cce1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1157,9 +1157,16 @@ if (NOT "${KUDU_USE_ASAN}" AND ADD_THIRDPARTY_LIB(tcmalloc STATIC_LIB "${TCMALLOC_STATIC_LIB}" SHARED_LIB "${TCMALLOC_SHARED_LIB}") + # gperftools in thirdparty are built with --enable-libunwind to allow + # for TCMALLOC_STACKTRACE_METHOD=libunwind stacktrace collection + set(PROFILER_DEPS) + if (NOT APPLE) + set(PROFILER_DEPS unwind) + endif() ADD_THIRDPARTY_LIB(profiler STATIC_LIB "${PROFILER_STATIC_LIB}" - SHARED_LIB "${PROFILER_SHARED_LIB}") + SHARED_LIB "${PROFILER_SHARED_LIB}" + DEPS "${PROFILER_DEPS}") list(APPEND KUDU_BASE_LIBS tcmalloc profiler) add_definitions("-DTCMALLOC_ENABLED") set(KUDU_TCMALLOC_AVAILABLE 1) diff --git a/thirdparty/build-definitions.sh b/thirdparty/build-definitions.sh index b1fa65330..5f16d00ee 100644 --- a/thirdparty/build-definitions.sh +++ b/thirdparty/build-definitions.sh @@ -465,18 +465,39 @@ build_glog() { } build_gperftools() { + local cfg_options="\ + --enable-frame-pointers\ + --with-pic\ + --prefix=$PREFIX\ + --enable-emergency-malloc" + + local cfg_cflags="$EXTRA_CFLAGS" + local cfg_cxxflags="$EXTRA_CXXFLAGS" + local cfg_ldflags="$EXTRA_LDFLAGS" + local cfg_libs="$EXTRA_LIBS" + + # On Linux, build perftools with libunwind support to have an option + # to collect stacktraces using libunwind in addition to the libgcc- + # and the frame pointers-based methods (if available for particular + # architecture). For more details on the stacktrace capturing options, + # see [1]. + # + # [1] https://github.com/gperftools/gperftools/wiki/gperftools'-stacktrace-capturing-methods-and-their-issues + if [ -n "$OS_LINUX" ]; then + cfg_options="$cfg_options --enable-libunwind" + cfg_cflags="$cfg_cflags -I$PREFIX/include" + cfg_cxxflags="$cfg_cxxflags -I$PREFIX/include" + cfg_ldflags="$cfg_ldflags -L$PREFIX/lib -Wl,-rpath,$PREFIX/lib" + fi + GPERFTOOLS_BDIR=$TP_BUILD_DIR/$GPERFTOOLS_NAME$MODE_SUFFIX mkdir -p $GPERFTOOLS_BDIR pushd $GPERFTOOLS_BDIR - CFLAGS="$EXTRA_CFLAGS" \ - CXXFLAGS="$EXTRA_CXXFLAGS" \ - LDFLAGS="$EXTRA_LDFLAGS" \ - LIBS="$EXTRA_LIBS" \ - $GPERFTOOLS_SOURCE/configure \ - --enable-frame-pointers \ - --with-pic \ - --prefix=$PREFIX \ - --enable-emergency-malloc + CFLAGS="$cfg_cflags" \ + CXXFLAGS="$cfg_cxxflags" \ + LDFLAGS="$cfg_ldflags" \ + LIBS="$cfg_libs" \ + $GPERFTOOLS_SOURCE/configure $cfg_options fixup_libtool make -j$PARALLEL $EXTRA_MAKEFLAGS install popd
