This is an automated email from the ASF dual-hosted git repository.

zy-kkk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new b8efbe159ad [fix](build) Upgrade gperftools to fix macOS ARM64 BE 
linking (#69231)
b8efbe159ad is described below

commit b8efbe159ad9e12c3da401900b9ca305bd9c9f31
Author: zy-kkk <[email protected]>
AuthorDate: Tue Oct 20 11:32:34 2026 +0800

    [fix](build) Upgrade gperftools to fix macOS ARM64 BE linking (#69231)
    
    Large BE binaries can fail to link on macOS ARM64 with gperftools 2.10:
    
    ```text
    ld: fixup error (kind=arm64_b26) at '_tc_free'+0x40
    B/BL out of range (displacement=-265493668, max is +/-128MB)
    ```
    
    gperftools 2.10 places allocator functions in custom Mach-O sections, 
`google_malloc` and `malloc_hook`, without the pure-instructions attribute. 
This affects branch island placement in large binaries. As the BE grows, the 
branch from `tc_free` toward `perftools_pthread_getspecific` can exceed the 
ARM64 ±128 MiB range.
    
    Upgrade gperftools from 2.10 to 2.18.1. Upstream removed the macOS 
`ATTRIBUTE_SECTION` mechanism in 
[5472781](https://github.com/gperftools/gperftools/commit/5472781f4ae2e4f32b667eabc15f70c267f429e8),
 eliminating the custom sections responsible for this layout issue. Using the 
upstream fix avoids maintaining a local section-attribute patch or linker 
workaround.
    
    Update the download URL, archive name, source directory and checksum in 
`thirdparty/vars.sh`.
    
    Preserve frame-pointer unwinding on Linux ARM64 by setting 
`TCMALLOC_DONT_PREFER_LIBUNWIND=1` when building gperftools. In 2.18.1, 
`--enable-frame-pointers` only prefers the frame-pointer unwinder on x86; 
without this setting, ARM64 selects libgcc. CPU profiling can then enter 
`dl_iterate_phdr` while holding the profiler's signal lock and deadlock with 
another thread holding the loader lock. The setting restores the previous 
`generic_fp` selection on Linux ARM64.
---
 thirdparty/build-thirdparty.sh | 11 ++++++++---
 thirdparty/vars.sh             |  8 ++++----
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/thirdparty/build-thirdparty.sh b/thirdparty/build-thirdparty.sh
index 52c2d481b20..0f0b0990fc9 100755
--- a/thirdparty/build-thirdparty.sh
+++ b/thirdparty/build-thirdparty.sh
@@ -684,9 +684,14 @@ build_gperftools() {
         ./autogen.sh
     fi
 
-    CPPFLAGS="-I${TP_INCLUDE_DIR}" \
-        LDFLAGS="-L${TP_LIB_DIR}" \
-        LD_LIBRARY_PATH="${TP_LIB_DIR}" \
+    local cppflags="-I${TP_INCLUDE_DIR}"
+    if [[ "${KERNEL}" == "Linux" && "$(uname -m)" == "aarch64" ]]; then
+        # --enable-frame-pointers only selects the FP unwinder on x86 in 
2.18.1.
+        # Keep ARM64 SIGPROF callbacks out of libgcc and its loader locks.
+        cppflags+=" -DTCMALLOC_DONT_PREFER_LIBUNWIND=1"
+    fi
+
+    CPPFLAGS="${cppflags}" \
         LDFLAGS="-L${TP_LIB_DIR}" \
         LD_LIBRARY_PATH="${TP_LIB_DIR}" \
         ./configure --prefix="${TP_INSTALL_DIR}/gperftools" --disable-shared 
--enable-static --disable-libunwind --with-pic --enable-frame-pointers
diff --git a/thirdparty/vars.sh b/thirdparty/vars.sh
index 07cd7449205..8359d0cc90a 100644
--- a/thirdparty/vars.sh
+++ b/thirdparty/vars.sh
@@ -105,10 +105,10 @@ SNAPPY_SOURCE=snappy-1.2.1
 SNAPPY_MD5SUM="dd6f9b667e69491e1dbf7419bdf68823"
 
 # gperftools
-GPERFTOOLS_DOWNLOAD="https://github.com/gperftools/gperftools/releases/download/gperftools-2.10/gperftools-2.10.tar.gz";
-GPERFTOOLS_NAME=gperftools-2.10.tar.gz
-GPERFTOOLS_SOURCE=gperftools-2.10
-GPERFTOOLS_MD5SUM="62bf6c76ba855ed580de5e139bd2a483"
+GPERFTOOLS_DOWNLOAD="https://github.com/gperftools/gperftools/releases/download/gperftools-2.18.1/gperftools-2.18.1.tar.gz";
+GPERFTOOLS_NAME=gperftools-2.18.1.tar.gz
+GPERFTOOLS_SOURCE=gperftools-2.18.1
+GPERFTOOLS_MD5SUM="129c01f6f5297f0482b33d431b5ec555"
 
 # zlib
 
ZLIB_DOWNLOAD="https://github.com/madler/zlib/releases/download/v1.3.1/zlib-1.3.1.tar.gz";


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to