Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2320: simulate_replay fails to link related to dumpStack #2332

Merged
1 change: 1 addition & 0 deletions ci/build_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ cmake -G "${CMAKE_GENERATOR:-Ninja}" \
-Dvt_debug_verbose="${VT_DEBUG_VERBOSE:-0}" \
-Dvt_tests_num_nodes="${VT_TESTS_NUM_NODES:-}" \
-Dvt_external_fmt="${VT_EXTERNAL_FMT:-0}" \
-DLIBUNWIND_ROOT="${LIBUNWIND_ROOT:-/usr}" \
-Dvt_no_color_enabled="${VT_NO_COLOR_ENABLED:-0}" \
-DCMAKE_CXX_STANDARD="${CMAKE_CXX_STANDARD:-17}" \
-DBUILD_SHARED_LIBS="${BUILD_SHARED_LIBS:-0}" \
Expand Down
42 changes: 42 additions & 0 deletions cmake-modules/Findlibunwind.cmake
nlslatt marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

# Users can pass LIBUNWIND_ROOT, LIBUNWIND_INCLUDE_DIR, and LIBUNWIND_LIBRARY as CMake variables.
# If LIBUNWIND_ROOT is provided, the INCLUDE_DIR and LIBRARY variables may be omitted.
#
# LIBUNWIND_FOUND, LIBUNWIND_INCLUDE_DIRS, and LIBUNWIND_LIBRARIES are outputs

if(LIBUNWIND_ROOT)
set(LIBUNWIND_INCLUDE_DIR ${LIBUNWIND_INCLUDE_DIR};${LIBUNWIND_ROOT}/include)
set(LIBUNWIND_LIBRARY ${LIBUNWIND_LIBRARY};${LIBUNWIND_ROOT}/lib64;${LIBUNWIND_ROOT}/lib)
endif()

# First, check only in the hinted paths
find_path(LIBUNWIND_INCLUDE_DIRS NAMES libunwind.h
DOC "The libunwind include directory"
HINTS ${LIBUNWIND_INCLUDE_DIR}
NO_DEFAULT_PATH
)
find_library(LIBUNWIND_LIBRARIES NAMES unwind
DOC "The libunwind library"
HINTS ${LIBUNWIND_LIBRARY}
NO_DEFAULT_PATH
)

# If that fails, check in CMake's default paths
find_path(LIBUNWIND_INCLUDE_DIRS NAMES libunwind.h
DOC "The libunwind include directory"
)
find_library(LIBUNWIND_LIBRARIES NAMES unwind
DOC "The libunwind library"
)

include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBUNWIND
REQUIRED_VARS LIBUNWIND_LIBRARIES LIBUNWIND_INCLUDE_DIRS)

if(LIBUNWIND_FOUND)
if(NOT TARGET libunwind)
add_library(libunwind UNKNOWN IMPORTED)
set_target_properties(libunwind PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LIBUNWIND_INCLUDE_DIRS}")
set_property(TARGET libunwind APPEND PROPERTY IMPORTED_LOCATION "${LIBUNWIND_LIBRARY}")
endif()
endif()
1 change: 0 additions & 1 deletion cmake/check_system_functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ check_include_files(mach/mach.h vt_has_mach_mach_h)
check_include_files(sys/resource.h vt_has_sys_resource_h)
check_include_files(unistd.h vt_has_unistd_h)
check_include_files(inttypes.h vt_has_inttypes_h)
check_include_files(libunwind.h vt_has_libunwind_h)
check_include_files(execinfo.h vt_has_execinfo_h)

check_function_exists(mstats vt_has_mstats)
Expand Down
4 changes: 2 additions & 2 deletions cmake/link_vt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ function(link_target_with_vt)
endif()

if (NOT DEFINED ARG_LINK_UNWIND AND ${ARG_DEFAULT_LINK_SET} OR ARG_LINK_UNWIND)
if (vt_has_libunwind_h)
if (vt_feature_cmake_libunwind)
if (${ARG_DEBUG_LINK})
message(STATUS "link_target_with_vt: unwind=${ARG_LINK_UNWIND}")
endif()
if (NOT DEFINED APPLE)
target_link_libraries(
${ARG_TARGET} PUBLIC ${ARG_BUILD_TYPE} unwind
${ARG_TARGET} PUBLIC ${ARG_BUILD_TYPE} ${LIBUNWIND_LIBRARIES}
)
endif()
endif()
Expand Down
11 changes: 11 additions & 0 deletions cmake/load_libunwind.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set(vt_feature_cmake_libunwind "0")

if(NOT DEFINED LIBUNWIND_ROOT)
set(LIBUNWIND_ROOT "/usr")
endif()

find_package(libunwind)

if(LIBUNWIND_FOUND)
set(vt_feature_cmake_libunwind "1")
endif()
3 changes: 3 additions & 0 deletions cmake/load_packages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ find_package(Perl)
# Doxygen package
include(cmake/load_doxygen.cmake)

# Optionally link with libunwind
include(cmake/load_libunwind.cmake)

# Optionally link with Zoltan
include(cmake/load_zoltan_package.cmake)

Expand Down
2 changes: 1 addition & 1 deletion cmake_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
#define vt_feature_cmake_debug_verbose @vt_feature_cmake_debug_verbose@
#define vt_feature_cmake_rdma_tests @vt_feature_cmake_rdma_tests@
#define vt_feature_cmake_external_fmt @vt_feature_cmake_external_fmt@
#define vt_feature_cmake_libunwind @vt_feature_cmake_libunwind@

#define vt_detected_max_num_nodes @cmake_detected_max_num_nodes@

Expand All @@ -89,7 +90,6 @@
#cmakedefine vt_has_unistd_h
#cmakedefine vt_has_inttypes_h
#cmakedefine vt_has_sysconf
#cmakedefine vt_has_libunwind_h
#cmakedefine vt_has_execinfo_h

#if vt_feature_cmake_external_fmt
Expand Down
7 changes: 4 additions & 3 deletions src/vt/configs/error/stack_out.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

#include <cxxabi.h>

#if defined(vt_has_libunwind_h)
#if vt_check_enabled(libunwind)
# define UNW_LOCAL_ONLY
# include <libunwind.h>
#elif defined(vt_has_execinfo_h)
Expand All @@ -59,7 +59,7 @@ namespace vt { namespace debug { namespace stack {

DumpStackType dumpStack(int skip) {
DumpStackType stack;
#if defined(vt_has_libunwind_h)
#if vt_check_enabled(libunwind)

unw_cursor_t cursor;
unw_context_t context;
Expand Down Expand Up @@ -152,7 +152,8 @@ DumpStackType dumpStack(int skip) {
std::free(symbols);

return stack;
#else //neither libnunwind.h or libexecinfo.h is available
#else // neither libunwind.h nor libexecinfo.h is available
(void)skip;
return stack;
#endif
}
Expand Down
1 change: 1 addition & 0 deletions src/vt/configs/features/features_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
#define vt_feature_production_build 0 || vt_feature_cmake_production_build
#define vt_feature_debug_verbose 0 || vt_feature_cmake_debug_verbose
#define vt_feature_fmt_external 0 || vt_feature_cmake_external_fmt
#define vt_feature_libunwind 0 || vt_feature_cmake_libunwind

#define vt_check_enabled(test_option) (vt_feature_ ## test_option != 0)

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/configs/test_stack_dumping.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

namespace vt { namespace tests { namespace unit {

#if defined(vt_has_libunwind_h) || defined(vt_has_execinfo_h)
#if vt_check_enabled(libunwind) || defined(vt_has_execinfo_h)

struct TestStackDumping : TestParallelHarness {};

Expand Down