aports/testing/pgexporter/no-execinfo.patch
2023-05-25 22:58:51 +00:00

75 lines
2.0 KiB
Diff

Patch-Source: https://github.com/pgexporter/pgexporter/pull/68
--
From 69c328fdde210e2013b9a63e3ce49949ffd2010f Mon Sep 17 00:00:00 2001
From: Jakub Jirutka <jakub@jirutka.cz>
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 <dirent.h>
#include <errno.h>
#include <ev.h>
-#include <execinfo.h>
#include <fcntl.h>
#include <inttypes.h>
#include <pwd.h>
@@ -50,6 +49,10 @@
#include <sys/statvfs.h>
#include <sys/types.h>
+#ifdef HAVE_EXECINFO_H
+#include <execinfo.h>
+#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;