From 6358bc9331a961b882173367e9483f4eb4ca4783 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 18 Feb 2022 11:13:25 -0800 Subject: [PATCH] Logging: rejiggle the way we detect the availability of backtrace() API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We had proper CMake tests for all we needed, so we can drop the old detection we were forced to use way back when. Said test (CMake's own FindBacktrace.cmake) even found QNX's offering, which we reported as "yes" in our configure output, but never actually used because it was a different API. Now we'll report "no" for QNX. Pick-to: 6.3 Change-Id: Ic15405335d804bdea761fffd16d4f73cfe4cf38a Reviewed-by: Qt CI Bot Reviewed-by: Kai Koehne Reviewed-by: Alexey Edelev Reviewed-by: Tor Arne Vestbø --- src/corelib/CMakeLists.txt | 2 ++ src/corelib/configure.cmake | 4 +++- src/corelib/global/qlogging.cpp | 21 ++++++--------------- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index 89abd8d863..c39c2c4c86 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -703,6 +703,8 @@ qt_internal_extend_target(Core CONDITION QT_FEATURE_commandlineparser ) qt_internal_extend_target(Core CONDITION QT_FEATURE_backtrace + DEFINES + BACKTRACE_HEADER="${Backtrace_HEADER}" LIBRARIES WrapBacktrace::WrapBacktrace ) diff --git a/src/corelib/configure.cmake b/src/corelib/configure.cmake index 82bc03a4fd..249e84cb01 100644 --- a/src/corelib/configure.cmake +++ b/src/corelib/configure.cmake @@ -14,7 +14,9 @@ set_property(CACHE INPUT_libb2 PROPERTY STRINGS undefined no qt system) #### Libraries -if((UNIX) OR QT_FIND_ALL_PACKAGES_ALWAYS) +if((UNIX AND NOT QNX) OR QT_FIND_ALL_PACKAGES_ALWAYS) + # QNX's libbacktrace has an API wholly different from all the other Unix + # offerings qt_find_package(WrapBacktrace PROVIDED_TARGETS WrapBacktrace::WrapBacktrace MODULE_NAME core QMAKE_LIB backtrace) endif() qt_find_package(WrapDoubleConversion PROVIDED_TARGETS WrapDoubleConversion::WrapDoubleConversion MODULE_NAME core QMAKE_LIB doubleconversion) diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 0049f5ef35..c369259788 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -2,7 +2,7 @@ ** ** Copyright (C) 2021 The Qt Company Ltd. ** Copyright (C) 2016 Olivier Goffart -** Copyright (C) 2018 Intel Corporation. +** Copyright (C) 2022 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -107,14 +107,11 @@ extern char *__progname; #endif #ifndef QT_BOOTSTRAPPED -#if QT_CONFIG(regularexpression) -# ifdef __UCLIBC__ -# if __UCLIBC_HAS_BACKTRACE__ -# define QLOGGING_HAVE_BACKTRACE -# endif -# elif (defined(__GLIBC__) && defined(__GLIBCXX__)) || (__has_include() && __has_include()) -# define QLOGGING_HAVE_BACKTRACE -# endif +#if __has_include() && QT_CONFIG(backtrace) && QT_CONFIG(regularexpression) +# include +# include BACKTRACE_HEADER +# include +# define QLOGGING_HAVE_BACKTRACE #endif #if defined(Q_OS_LINUX) && (defined(__GLIBC__) || __has_include()) @@ -152,12 +149,6 @@ static QT_PREPEND_NAMESPACE(qint64) qt_gettid() return qintptr(QThread::currentThreadId()); } #endif - -#ifdef QLOGGING_HAVE_BACKTRACE -# include -# include -# include -#endif #endif // !QT_BOOTSTRAPPED #include