diff --git a/CMakeLists.txt b/CMakeLists.txt index 1dafffdbe15..7676058a243 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,7 @@ option(ENABLE_POSIX_CAP ) option(ENABLE_PROFILER "Use gperftools profiler (default OFF)") option(ENABLE_TCMALLOC "Use TCMalloc (default OFF)") +option(ENABLE_UNWIND "Use libunwind if found on system (default ON)" ON) set(TS_MAX_HOST_NAME_LEN 256 CACHE STRING "Max host name length (default 256)") set(TS_USE_SET_RBIO 1 CACHE STRING "Use openssl set_rbio (default 1)") set(TS_USE_DIAGS 1 CACHE STRING "Use diags (default 1)") @@ -150,6 +151,14 @@ if(TSMallocReplacement_FOUND) link_libraries(ts::TSMallocReplacement) endif() +if(ENABLE_UNWIND) + find_package(unwind) + if(unwind_FOUND) + link_libraries(unwind::unwind) + endif() + set(TS_USE_REMOTE_UNWINDING ${unwind_FOUND}) +endif() + find_package(ZLIB REQUIRED) include(Check128BitCas) diff --git a/cmake/Findunwind.cmake b/cmake/Findunwind.cmake new file mode 100644 index 00000000000..42d356a01bf --- /dev/null +++ b/cmake/Findunwind.cmake @@ -0,0 +1,49 @@ +####################### +# +# 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. +# +####################### + +# Findunwind.cmake +# +# This will define the following variables +# +# unwind_FOUND +# unwind_LIBRARY +# unwind_INCLUDE_DIRS +# +# and the following imported targets +# +# unwind::unwind +# + +find_library(unwind_LIBRARY NAMES unwind) +find_path(unwind_INCLUDE_DIR NAMES unwind.h) + +mark_as_advanced(unwind_FOUND unwind_LIBRARY unwind_INCLUDE_DIR) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(unwind + REQUIRED_VARS unwind_LIBRARY unwind_INCLUDE_DIR +) + +if(unwind_FOUND) + set(unwind_INCLUDE_DIRS ${unwind_INCLUDE_DIR}) +endif() + +if(unwind_FOUND AND NOT TARGET unwind::unwind) + add_library(unwind::unwind INTERFACE IMPORTED) + target_include_directories(unwind::unwind INTERFACE ${unwind_INCLUDE_DIRS}) + target_link_libraries(unwind::unwind INTERFACE "${unwind_LIBRARY}") +endif() diff --git a/include/tscore/ink_config.h.cmake.in b/include/tscore/ink_config.h.cmake.in index cc0446822d1..ffb2eb49de6 100644 --- a/include/tscore/ink_config.h.cmake.in +++ b/include/tscore/ink_config.h.cmake.in @@ -125,6 +125,7 @@ const int DEFAULT_STACKSIZE = @DEFAULT_STACK_SIZE@; #cmakedefine01 TS_USE_LINUX_IO_URING #cmakedefine01 TS_USE_LINUX_NATIVE_AIO #cmakedefine01 TS_USE_POSIX_CAP +#cmakedefine01 TS_USE_REMOTE_UNWINDING #cmakedefine01 TS_USE_SET_RBIO #cmakedefine01 TS_USE_TLS13