This is an automated email from the ASF dual-hosted git repository.
junrushao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm-ffi.git
The following commit(s) were added to refs/heads/main by this push:
new 33b3768 [CMAKE] Hide symbols from libbacktrace (#139)
33b3768 is described below
commit 33b37685fdbef6cbecea19160fe784f9fbe83fd8
Author: Tianqi Chen <[email protected]>
AuthorDate: Wed Oct 15 20:31:59 2025 -0400
[CMAKE] Hide symbols from libbacktrace (#139)
This PR updates the cmake to hide symbols from
libbacktrace given it is only used internally
---
cmake/Utils/AddLibbacktrace.cmake | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/cmake/Utils/AddLibbacktrace.cmake
b/cmake/Utils/AddLibbacktrace.cmake
index 17b9c8a..82ece97 100644
--- a/cmake/Utils/AddLibbacktrace.cmake
+++ b/cmake/Utils/AddLibbacktrace.cmake
@@ -37,6 +37,12 @@ function (_libbacktrace_compile)
file(MAKE_DIRECTORY ${libbacktrace_prefix}/lib)
detect_target_triple(TVM_FFI_MACHINE_NAME)
message(STATUS "Detected target triple: ${TVM_FFI_MACHINE_NAME}")
+
+ # Add symbol hiding flags for GCC, Clang, and AppleClang
+ set(symbol_hiding_flags "")
+ if (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
+ set(symbol_hiding_flags "-fvisibility=hidden -fvisibility-inlines-hidden")
+ endif ()
ExternalProject_Add(
project_libbacktrace
PREFIX libbacktrace
@@ -50,7 +56,7 @@ function (_libbacktrace_compile)
"--with-pic" #
"CC=${cmake_c_compiler}" #
"CPP=${cmake_c_compiler} -E" #
- "CFLAGS=${CMAKE_C_FLAGS}" #
+ "CFLAGS=${CMAKE_C_FLAGS} ${symbol_hiding_flags}" #
"LDFLAGS=${CMAKE_EXE_LINKER_FLAGS}" #
"NM=${CMAKE_NM}" #
"STRIP=${CMAKE_STRIP}" #