From 09275bf4c7fe2c4d522f02285bf97cadd7a683c8 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Thu, 15 Sep 2022 12:03:07 +0200 Subject: [PATCH] Disable execinfo support if only header detected Some implementations (e.g. Android with API < 33) provide the execinfo.h header file, but do not define the backtrace functions expected. Disable the support for execinfo backtrace in such a case --- winpr/CMakeLists.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/winpr/CMakeLists.txt b/winpr/CMakeLists.txt index 43876f130..7dbde7c52 100644 --- a/winpr/CMakeLists.txt +++ b/winpr/CMakeLists.txt @@ -165,7 +165,18 @@ endif() if(NOT IOS) CHECK_SYMBOL_EXISTS(strndup string.h HAVE_STRNDUP) check_include_files(unistd.h HAVE_UNISTD_H) - check_include_files(execinfo.h HAVE_EXECINFO_H) + check_include_files(execinfo.h HAVE_EXECINFO_HEADER) + if (HAVE_EXECINFO_HEADER) + check_symbol_exists(backtrace execinfo.h HAVE_EXECINFO_BACKTRACE) + check_symbol_exists(backtrace_symbols execinfo.h HAVE_EXECINFO_BACKTRACE_SYMBOLS) + check_symbol_exists(backtrace_symbols_fd execinfo.h HAVE_EXECINFO_BACKTRACE_SYMBOLS_FD) + + # Some implementations (e.g. Android NDK API < 33) provide execinfo.h but do not define + # the backtrace functions. Disable detection for these cases + if (HAVE_EXECINFO_BACKTRACE AND HAVE_EXECINFO_BACKTRACE_SYMBOLS AND HAVE_EXECINFO_BACKTRACE_SYMBOLS_FD) + set(HAVE_EXECINFO_H ON) + endif() + endif() check_include_files(inttypes.h HAVE_INTTYPES_H) check_include_files(stdint.h HAVE_STDINT_H) check_include_files(inttypes.h HAVE_INTTYPES_H)