1 |
commit: 144edbafdebe29ac1d2d3edede2385364d740ea6 |
2 |
Author: listout <listout <AT> protonmail <DOT> com> |
3 |
AuthorDate: Tue Sep 13 10:20:17 2022 +0000 |
4 |
Commit: Guilherme Amadio <amadio <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Sep 14 14:54:52 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=144edbaf |
7 |
|
8 |
sci-physics/geant: Fix building on musl, avoid execinfo.h |
9 |
|
10 |
Avoid including execinfo.h and calling backtrace function on system that |
11 |
don't provide the header. |
12 |
|
13 |
Closes: https://bugs.gentoo.org/829151 |
14 |
Closes: https://github.com/gentoo/gentoo/pull/26313 |
15 |
Signed-off-by: brahmajit das <listout <AT> protonmail.com> |
16 |
Signed-off-by: Guilherme Amadio <amadio <AT> gentoo.org> |
17 |
|
18 |
.../files/geant-4.11.0.2-musl-avoid-execinfo.patch | 100 +++++++++++++++++++++ |
19 |
sci-physics/geant/geant-4.11.0.2-r1.ebuild | 4 + |
20 |
2 files changed, 104 insertions(+) |
21 |
|
22 |
diff --git a/sci-physics/geant/files/geant-4.11.0.2-musl-avoid-execinfo.patch b/sci-physics/geant/files/geant-4.11.0.2-musl-avoid-execinfo.patch |
23 |
new file mode 100644 |
24 |
index 000000000000..e73a9c24c597 |
25 |
--- /dev/null |
26 |
+++ b/sci-physics/geant/files/geant-4.11.0.2-musl-avoid-execinfo.patch |
27 |
@@ -0,0 +1,100 @@ |
28 |
+# Avoid including execinfo and calling backtrace function when execinfo.h is |
29 |
+# not present or supplied by system's libc |
30 |
+# |
31 |
+# Closes: https://bugs.gentoo.org/829151 |
32 |
+--- a/source/global/management/include/G4Backtrace.hh |
33 |
++++ b/source/global/management/include/G4Backtrace.hh |
34 |
+@@ -85,23 +85,6 @@ |
35 |
+ # endif |
36 |
+ #endif |
37 |
+ |
38 |
+-#if defined(G4UNIX) && !defined(WIN32) |
39 |
+-# include <cxxabi.h> |
40 |
+-# include <execinfo.h> |
41 |
+-# include <unistd.h> |
42 |
+-#endif |
43 |
+- |
44 |
+-#if defined(G4LINUX) |
45 |
+-# include <features.h> |
46 |
+-#endif |
47 |
+- |
48 |
+-#include <cfenv> |
49 |
+-#include <csignal> |
50 |
+-#include <type_traits> |
51 |
+- |
52 |
+-template <typename FuncT, typename... ArgTypes> |
53 |
+-using G4ResultOf_t = std::invoke_result_t<FuncT, ArgTypes...>; |
54 |
+- |
55 |
+ // compatible OS and compiler |
56 |
+ #if defined(G4UNIX) && \ |
57 |
+ (defined(__GNUC__) || defined(__clang__) || defined(_INTEL_COMPILER)) |
58 |
+@@ -109,7 +92,9 @@ using G4ResultOf_t = std::invoke_result_t<FuncT, ArgTypes...>; |
59 |
+ # define G4SIGNAL_AVAILABLE |
60 |
+ # endif |
61 |
+ # if !defined(G4DEMANGLE_AVAILABLE) |
62 |
+-# define G4DEMANGLE_AVAILABLE |
63 |
++# if defined(G4UNIX) && defined(HAVE_EXECINFO_H) |
64 |
++# define G4DEMANGLE_AVAILABLE |
65 |
++# endif |
66 |
+ # endif |
67 |
+ #endif |
68 |
+ |
69 |
+@@ -121,6 +106,25 @@ using G4ResultOf_t = std::invoke_result_t<FuncT, ArgTypes...>; |
70 |
+ # endif |
71 |
+ #endif |
72 |
+ |
73 |
++#if defined(G4UNIX) && !defined(WIN32) |
74 |
++# include <cxxabi.h> |
75 |
++#if defined(HAVE_EXECINFO_H) |
76 |
++# include <execinfo.h> |
77 |
++#endif |
78 |
++# include <unistd.h> |
79 |
++#endif |
80 |
++ |
81 |
++#if defined(G4LINUX) |
82 |
++# include <features.h> |
83 |
++#endif |
84 |
++ |
85 |
++#include <cfenv> |
86 |
++#include <csignal> |
87 |
++#include <type_traits> |
88 |
++ |
89 |
++template <typename FuncT, typename... ArgTypes> |
90 |
++using G4ResultOf_t = std::invoke_result_t<FuncT, ArgTypes...>; |
91 |
++ |
92 |
+ //----------------------------------------------------------------------------// |
93 |
+ |
94 |
+ inline G4String G4Demangle(const char* _str) |
95 |
+@@ -368,6 +372,7 @@ G4Backtrace::GetMangled(FuncT&& func) |
96 |
+ std::array<type, Depth> btrace; |
97 |
+ btrace.fill((std::is_pointer<type>::value) ? nullptr : type{}); |
98 |
+ |
99 |
++#if defined(G4DEMANGLE_AVAILABLE) |
100 |
+ // plus one for this stack-frame |
101 |
+ std::array<void*, Depth + Offset> buffer; |
102 |
+ // size of returned buffer |
103 |
+@@ -387,6 +392,7 @@ G4Backtrace::GetMangled(FuncT&& func) |
104 |
+ btrace[i] = func(bsym[i]); |
105 |
+ free(bsym); |
106 |
+ } |
107 |
++#endif |
108 |
+ return btrace; |
109 |
+ } |
110 |
+ |
111 |
+--- a/source/global/management/sources.cmake |
112 |
++++ b/source/global/management/sources.cmake |
113 |
+@@ -6,6 +6,14 @@ set(G4MULTITHREADED ${GEANT4_BUILD_MULTITHREADED}) |
114 |
+ set(G4_STORE_TRAJECTORY ${GEANT4_BUILD_STORE_TRAJECTORY}) |
115 |
+ set(G4VERBOSE ${GEANT4_BUILD_VERBOSE_CODE}) |
116 |
+ |
117 |
++include(CheckIncludeFile) |
118 |
++ |
119 |
++check_include_file(execinfo.h HAVE_EXECINFO_H) |
120 |
++ |
121 |
++if(HAVE_SYS_TYPES_H) |
122 |
++ list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_EXECINFO_H) |
123 |
++endif() |
124 |
++ |
125 |
+ configure_file(${CMAKE_CURRENT_LIST_DIR}/include/G4GlobalConfig.hh.in |
126 |
+ ${CMAKE_CURRENT_BINARY_DIR}/include/G4GlobalConfig.hh) |
127 |
+ |
128 |
|
129 |
diff --git a/sci-physics/geant/geant-4.11.0.2-r1.ebuild b/sci-physics/geant/geant-4.11.0.2-r1.ebuild |
130 |
index 1eaf3d9af34b..e43a735dfdc4 100644 |
131 |
--- a/sci-physics/geant/geant-4.11.0.2-r1.ebuild |
132 |
+++ b/sci-physics/geant/geant-4.11.0.2-r1.ebuild |
133 |
@@ -75,6 +75,10 @@ RDEPEND=" |
134 |
|
135 |
S="${WORKDIR}/${MY_P}" |
136 |
|
137 |
+PATCHES=( |
138 |
+ "${FILESDIR}"/${PN}-4.11.0.2-musl-avoid-execinfo.patch |
139 |
+) |
140 |
+ |
141 |
src_configure() { |
142 |
local mycmakeargs=( |
143 |
-DCMAKE_INSTALL_DATADIR="${EPREFIX}/usr/share/geant4" |