mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 06:38:13 -05:00
#14720 Probe std::stacktrace by linking instead of trusting the feature macro
libstdc++ defines __cpp_lib_stacktrace from GCC 13 on, but the implementation lives in libstdc++exp, which some distributions do not ship (Red Hat's gcc-toolset among them). The header-only feature test then reports the feature as present and the link fails with undefined references to std::__stacktrace_impl::_S_current. Add cmake/StdStacktrace.cmake, which probes the feature by actually linking: first with no extra library, then with stdc++exp. The result selects the link library through RESINSIGHT_STACKTRACE_LIBRARIES, or defines RIA_HAS_STD_STACKTRACE=0 project-wide when neither links, so the crash handler compiles out its stack-trace capture and logs the signal only. RiaMainTools.cpp and RiaOpenTelemetryManager.h now honour a RIA_HAS_STD_STACKTRACE definition from the build system and only include <stacktrace> when the feature is enabled. Follow-up to #14045.
This commit is contained in:
1 parent
aa3ec82e1c
commit
3f7aee5972
5 files changed
+105
-38
No files matched your search
@@ -321,34 +321,12 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
# According to ivarun rt is needed on OpenSuse, and Fedora. See:
|
||||
# https://github.com/OPM/ResInsight/pull/7
|
||||
list(APPEND EXTERNAL_LINK_LIBRARIES rt)
|
||||
|
||||
# std::stacktrace requires stdc++exp. If a custom build of GCC stdc++exp is
|
||||
# required, define the search path here.
|
||||
set(RESINSIGHT_GCC_STDCPP_EXP_PATH
|
||||
""
|
||||
CACHE PATH "Path to search for stdc++exp"
|
||||
)
|
||||
|
||||
if(RESINSIGHT_GCC_STDCPP_EXP_PATH)
|
||||
find_library(
|
||||
STDCPP_EXP_LIBRARY
|
||||
NAMES stdc++exp
|
||||
HINTS ${RESINSIGHT_GCC_STDCPP_EXP_PATH}
|
||||
)
|
||||
if(STDCPP_EXP_LIBRARY)
|
||||
message(
|
||||
STATUS
|
||||
"stdc++exp library found at custom location: ${STDCPP_EXP_LIBRARY}"
|
||||
)
|
||||
list(APPEND EXTERNAL_LINK_LIBRARIES ${STDCPP_EXP_LIBRARY})
|
||||
endif()
|
||||
else()
|
||||
# stdc++exp is required for std::stacktrace
|
||||
message(STATUS "stdc++exp library found at default location")
|
||||
list(APPEND EXTERNAL_LINK_LIBRARIES stdc++exp)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# std::stacktrace needs stdc++exp on most libstdc++ toolchains. Which library,
|
||||
# if any, is probed in cmake/StdStacktrace.cmake.
|
||||
list(APPEND EXTERNAL_LINK_LIBRARIES ${RESINSIGHT_STACKTRACE_LIBRARIES})
|
||||
|
||||
target_link_libraries(
|
||||
ApplicationLibCode PUBLIC ${LINK_LIBRARIES} ${EXTERNAL_LINK_LIBRARIES}
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user