From a338a45f067568d3996096e4f52b2465c5cac12c Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Sun, 19 Jun 2022 09:59:36 +0000 Subject: [PATCH] [Media Common] Detect backtrace() on non-GNU after b66bb0c234b4 ld: error: undefined symbol: backtrace >>> referenced by mos_utilities_specific.cpp:2504 (media_softlet/linux/common/os/osservice/mos_utilities_specific.cpp:2504) >>> media_driver/CMakeFiles/iHD_drv_video_COMMON.dir/__/media_softlet/linux/common/os/osservice/mos_utilities_specific.cpp.o:(MosUtilities::MosTraceEvent(unsigned short, unsigned char, void const*, unsigned int, void const*, unsigned int)) c++: error: linker command failed with exit code 1 (use -v to see invocation) --- .../linux/common/os/osservice/mos_utilities_specific.cpp | 4 ++++ media_softlet/media_top_cmake.cmake | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/media_softlet/linux/common/os/osservice/mos_utilities_specific.cpp b/media_softlet/linux/common/os/osservice/mos_utilities_specific.cpp index 58083d796d..d551053b3e 100644 --- a/media_softlet/linux/common/os/osservice/mos_utilities_specific.cpp +++ b/media_softlet/linux/common/os/osservice/mos_utilities_specific.cpp @@ -51,7 +51,9 @@ #include #include // fork #include +#ifdef HAVE_EXECINFO_H #include // backtrace +#endif const char *MosUtilitiesSpecificNext::m_szUserFeatureFile = USER_FEATURE_FILE; MOS_PUF_KEYLIST MosUtilitiesSpecificNext::m_ufKeyList = nullptr; @@ -2489,6 +2491,7 @@ void MosUtilities::MosTraceEvent( MOS_FreeMemory(pTraceBuf); } } +#ifdef HAVE_EXECINFO_H if (m_mosTraceFilter & (1ULL << TR_KEY_CALL_STACK)) { // reserve space for header and stack size field. @@ -2508,6 +2511,7 @@ void MosUtilities::MosTraceEvent( size_t ret = write(MosUtilitiesSpecificNext::m_mosTraceFd, traceBuf, nLen); } } +#endif /* HAVE_EXECINFO_H */ } return; } diff --git a/media_softlet/media_top_cmake.cmake b/media_softlet/media_top_cmake.cmake index f381a0bfe1..70a549866c 100644 --- a/media_softlet/media_top_cmake.cmake +++ b/media_softlet/media_top_cmake.cmake @@ -29,6 +29,15 @@ option (MEDIA_RUN_TEST_SUITE "run google test module after install" ON) include(${MEDIA_SOFTLET_CMAKE}/media_gen_flags.cmake) include(${MEDIA_SOFTLET_CMAKE}/media_feature_flags.cmake) +check_include_file_cxx("execinfo.h" HAVE_EXECINFO_H) +if(HAVE_EXECINFO_H) + target_compile_definitions(${LIB_NAME} PRIVATE HAVE_EXECINFO_H) +endif() + +check_library_exists(execinfo backtrace "" HAVE_LIBEXECINFO) +if(HAVE_LIBEXECINFO) + target_link_libraries (${LIB_NAME} PRIVATE execinfo) +endif() if(NOT DEFINED SKIP_GMM_CHECK) # checking dependencies