commit:     b2812d756f23179a480f982ef877f3ff5b7e4116
Author:     brahmajit das <listout <AT> protonmail <DOT> com>
AuthorDate: Fri Jul 29 18:53:09 2022 +0000
Commit:     Joonas Niilola <juippis <AT> gentoo <DOT> org>
CommitDate: Wed Aug 17 16:17:56 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b2812d75

dev-libs/sink: Musl fix build error, missing execinfo.h

On musl execinfo.h is not present, it results in build error for missing
header file. Hence we are going check first for execinfo.h then include
and use it for backtrace.

Closes: https://bugs.gentoo.org/830945
Signed-off-by: brahmajit das <listout <AT> protonmail.com>
Closes: https://github.com/gentoo/gentoo/pull/26655
Signed-off-by: Joonas Niilola <juippis <AT> gentoo.org>

 dev-libs/sink/files/sink-0.8.0-musl-execinfo.patch | 48 ++++++++++++++++++++++
 dev-libs/sink/sink-0.8.0-r3.ebuild                 |  6 ++-
 2 files changed, 53 insertions(+), 1 deletion(-)

diff --git a/dev-libs/sink/files/sink-0.8.0-musl-execinfo.patch 
b/dev-libs/sink/files/sink-0.8.0-musl-execinfo.patch
new file mode 100644
index 000000000000..b5085702a33e
--- /dev/null
+++ b/dev-libs/sink/files/sink-0.8.0-musl-execinfo.patch
@@ -0,0 +1,48 @@
+# Since musl doesn't have execinfo. We're going to avoid including it and make
+# the printStacktrace function void
+# Closes: https://bugs.gentoo.org/830945
+--- a/synchronizer/CMakeLists.txt
++++ b/synchronizer/CMakeLists.txt
+@@ -2,6 +2,12 @@ project(sink_synchronizer)
+
+ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
+
++INCLUDE(CheckIncludeFiles)
++CHECK_INCLUDE_FILES("execinfo.h" HAVE_EXECINFO)
++IF (HAVE_EXECINFO)
++      add_compile_definitions(HAVE_EXECINFO_H)
++ENDIF(HAVE_EXECINFO)
++
+ set(sinksynchronizer_SRCS
+     main.cpp
+     backtrace.cpp
+--- a/synchronizer/backtrace.cpp
++++ b/synchronizer/backtrace.cpp
+@@ -31,7 +31,9 @@
+ #include <chrono>
+
+ #ifndef Q_OS_WIN
++#ifdef HAVE_EXECINFO_H
+ #include <execinfo.h>
++#endif // HAVE_EXECINFO_H
+ #include <unistd.h>
+ #include <cxxabi.h>
+ #include <dlfcn.h>
+@@ -143,7 +145,7 @@ private:
+ //Print a demangled stacktrace
+ static void printStacktrace()
+ {
+-#ifndef Q_OS_WIN
++#if !defined(Q_OS_WIN) && defined(HAVE_EXECINFO_H)
+     int skip = 1;
+       void *callstack[128];
+       const int nMaxFrames = sizeof(callstack) / sizeof(callstack[0]);
+@@ -178,7 +180,7 @@ static void printStacktrace()
+               trace_buf << "[truncated]\n";
+     }
+     std::cerr << trace_buf.str();
+-#else
++#elif defined(Q_OS_WIN)
+     enum { maxStackFrames = 100 };
+     DebugSymbolResolver resolver(GetCurrentProcess());
+     if (resolver.isValid()) {

diff --git a/dev-libs/sink/sink-0.8.0-r3.ebuild 
b/dev-libs/sink/sink-0.8.0-r3.ebuild
index 78d2b574ac2b..c8108f329bf4 100644
--- a/dev-libs/sink/sink-0.8.0-r3.ebuild
+++ b/dev-libs/sink/sink-0.8.0-r3.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2021 Gentoo Authors
+# Copyright 1999-2022 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=7
@@ -42,6 +42,10 @@ DEPEND="${RDEPEND}
 # fails to build
 RESTRICT+=" test"
 
+PATCHES=(
+       "${FILESDIR}"/${PN}-0.8.0-musl-execinfo.patch
+)
+
 src_prepare() {
        cmake_src_prepare
        # tests are sprinkled all over the place, and examples are needed...

Reply via email to