Patch-Source: https://github.com/pgexporter/pgexporter/pull/68 -- From 69c328fdde210e2013b9a63e3ce49949ffd2010f Mon Sep 17 00:00:00 2001 From: Jakub Jirutka Date: Thu, 25 May 2023 21:36:01 +0200 Subject: [PATCH] Allow building on Linux systems without execinfo.h musl-based systems, such as Alpine Linux, don't support execinfo. --- CMakeLists.txt | 1 + src/CMakeLists.txt | 5 +++++ src/libpgexporter/utils.c | 7 +++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 97105bf..da9b55d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,7 @@ message(STATUS "pgexporter ${VERSION_STRING}") include(CheckCCompilerFlag) include(CheckCSourceCompiles) +include(CheckIncludeFile) include(FindPackageHandleStandardArgs) include(GNUInstallDirs) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7667e93..7105baf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,6 +14,11 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") add_compile_options(-DHAVE_LINUX) add_compile_options(-D_POSIX_C_SOURCE=200809L) + check_include_file("execinfo.h" HAVE_EXECINFO_H) + if (HAVE_EXECINFO_H) + add_compile_options(-DHAVE_EXECINFO_H) + endif() + # # Include directories # diff --git a/src/libpgexporter/utils.c b/src/libpgexporter/utils.c index a627397..f042b11 100644 --- a/src/libpgexporter/utils.c +++ b/src/libpgexporter/utils.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -50,6 +49,10 @@ #include #include +#ifdef HAVE_EXECINFO_H +#include +#endif + #ifndef EVBACKEND_LINUXAIO #define EVBACKEND_LINUXAIO 0x00000040U #endif @@ -1992,7 +1995,7 @@ is_wal_file(char* file) int pgexporter_backtrace(void) { -#ifdef HAVE_LINUX +#ifdef HAVE_EXECINFO_H void* array[100]; size_t size; char** strings;