github-actions[bot] commented on code in PR #69819:
URL: https://github.com/apache/doris/pull/69819#discussion_r4439614569


##########
be/test/jemalloc_hook/CMakeLists.txt:
##########
@@ -0,0 +1,55 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# This allocator test must not use ASAN: its interceptors would hide missing
+# glibc allocation entry points. Keep it separate from doris_be_test, which
+# run-be-ut.sh builds with USE_JEMALLOC=OFF.
+cmake_minimum_required(VERSION 3.20)
+project(doris_jemalloc_hook_test LANGUAGES CXX)
+
+if (NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
+    message(FATAL_ERROR "jemalloc hook tests require Linux/glibc")
+endif()
+
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
+get_filename_component(DORIS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../.." 
ABSOLUTE)
+set(THIRDPARTY_DIR "$ENV{DORIS_THIRDPARTY}/installed")
+find_package(Threads REQUIRED)
+
+foreach (LIB_NAME gtest gtest_main jemalloc_doris unwind lzma)
+    find_library(${LIB_NAME}_LIBRARY NAMES ${LIB_NAME}
+        PATHS "${THIRDPARTY_DIR}/lib" "${THIRDPARTY_DIR}/lib64"
+        NO_DEFAULT_PATH REQUIRED)
+endforeach()
+
+add_library(jemalloc_hook_test_dso SHARED jemalloc_hook_test_dso.cpp)
+target_compile_options(jemalloc_hook_test_dso PRIVATE 
-ftls-model=global-dynamic)
+
+add_executable(jemalloc_hook_test
+    jemalloc_hook_test.cpp
+    "${DORIS_SOURCE_DIR}/be/src/runtime/memory/jemalloc_hook.cpp")
+target_include_directories(jemalloc_hook_test PRIVATE 
"${THIRDPARTY_DIR}/include")
+target_compile_definitions(jemalloc_hook_test PRIVATE
+    JEMALLOC_HOOK_TEST_DSO="$<TARGET_FILE:jemalloc_hook_test_dso>")
+# Do not enable ENABLE_EXPORTS: verify the hook also works with the production
+# executable's default symbol visibility.
+target_link_libraries(jemalloc_hook_test PRIVATE
+    "${gtest_main_LIBRARY}" "${gtest_LIBRARY}" "${jemalloc_doris_LIBRARY}"
+    "${unwind_LIBRARY}" "${lzma_LIBRARY}" Threads::Threads ${CMAKE_DL_LIBS})

Review Comment:
   [P2] Link zlib for the standalone ARM64 test. On Linux aarch64 with modern 
ELF headers (`SHF_COMPRESSED`), the repository's default libunwind 1.8.3 build 
enables [debug-frame and zlib 
support](https://github.com/libunwind/libunwind/blob/v1.8.3/configure.ac#L369-L439),
 so its dwarf lookup object [references 
`uncompress`](https://github.com/libunwind/libunwind/blob/v1.8.3/src/dwarf/Gfind_proc_info-lsb.c#L125-L140).
 The prof-enabled jemalloc dependency pulls that object in through 
`unw_backtrace` and local address-space initialization even when profiling is 
disabled at runtime. This target links libunwind and liblzma but never libz, so 
`./run-be-ut.sh --jemalloc-hook --run` fails at link time with an undefined 
reference to `uncompress`, before the tests can run. Find the installed z 
library and link it after unwind, or consume dependency metadata that carries 
it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to