1 |
commit: 07f1954e0dd0fb941be3396f15257793f791b23a |
2 |
Author: brahmajit das <listout <AT> protonmail <DOT> com> |
3 |
AuthorDate: Tue Aug 23 15:39:17 2022 +0000 |
4 |
Commit: Sam James <sam <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Sep 1 02:01:54 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=07f1954e |
7 |
|
8 |
media-gfx/blender: Upstream musl libc fixes backport |
9 |
|
10 |
These are some of the patch that I submitted upstream and have been |
11 |
accepted. They will be a part of next blender release. However, this PR |
12 |
is a backport of those fixes for blender 3.2.2. |
13 |
|
14 |
Please refer: |
15 |
https://github.com/blender/blender/commit/f197b1a1f1bbc0334310fb1c911327246767a1a3, and |
16 |
https://github.com/blender/blender/commit/7be7280c5710f7831789cdde140d010722be9068 |
17 |
|
18 |
Closes: https://bugs.gentoo.org/739474 |
19 |
|
20 |
Signed-off-by: brahmajit das <listout <AT> protonmail.com> |
21 |
Closes: https://github.com/gentoo/gentoo/pull/26860 |
22 |
Signed-off-by: Sam James <sam <AT> gentoo.org> |
23 |
|
24 |
media-gfx/blender/blender-3.2.2.ebuild | 5 + |
25 |
.../files/blender-3.2.2-musl-glibc-prereq.patch | 27 ++++ |
26 |
...der-3.2.2-support-building-with-musl-libc.patch | 177 +++++++++++++++++++++ |
27 |
3 files changed, 209 insertions(+) |
28 |
|
29 |
diff --git a/media-gfx/blender/blender-3.2.2.ebuild b/media-gfx/blender/blender-3.2.2.ebuild |
30 |
index 8c82138b1e5a..70024e231bf6 100644 |
31 |
--- a/media-gfx/blender/blender-3.2.2.ebuild |
32 |
+++ b/media-gfx/blender/blender-3.2.2.ebuild |
33 |
@@ -123,6 +123,11 @@ BDEPEND=" |
34 |
nls? ( sys-devel/gettext ) |
35 |
" |
36 |
|
37 |
+PATCHES=( |
38 |
+ "${FILESDIR}"/${PN}-3.2.2-support-building-with-musl-libc.patch |
39 |
+ "${FILESDIR}"/${PN}-3.2.2-musl-glibc-prereq.patch |
40 |
+) |
41 |
+ |
42 |
blender_check_requirements() { |
43 |
[[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp |
44 |
|
45 |
|
46 |
diff --git a/media-gfx/blender/files/blender-3.2.2-musl-glibc-prereq.patch b/media-gfx/blender/files/blender-3.2.2-musl-glibc-prereq.patch |
47 |
new file mode 100644 |
48 |
index 000000000000..a572f25788de |
49 |
--- /dev/null |
50 |
+++ b/media-gfx/blender/files/blender-3.2.2-musl-glibc-prereq.patch |
51 |
@@ -0,0 +1,27 @@ |
52 |
+Fix build error in libc_compat when using musl libc |
53 |
+ |
54 |
+Checking for the existence of and using __GLIBC_PREREQ can't be done in the |
55 |
+same conditional. |
56 |
+ |
57 |
+Please refer: https://github.com/blender/blender/commit/7be7280c5710f7831789cdde140d010722be9068 |
58 |
+--- a/intern/libc_compat/libc_compat.c |
59 |
++++ b/intern/libc_compat/libc_compat.c |
60 |
+@@ -13,7 +13,8 @@ |
61 |
+ # include <features.h> |
62 |
+ # include <math.h> |
63 |
+ |
64 |
+-# if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 31) |
65 |
++# if defined(__GLIBC_PREREQ) |
66 |
++# if __GLIBC_PREREQ(2, 31) |
67 |
+ |
68 |
+ double __exp_finite(double x); |
69 |
+ double __exp2_finite(double x); |
70 |
+@@ -112,5 +113,6 @@ float __powf_finite(float x, float y) |
71 |
+ return powf(x, y); |
72 |
+ } |
73 |
+ |
74 |
+-# endif /* __GLIBC_PREREQ */ |
75 |
+-#endif /* __linux__ */ |
76 |
++# endif /* __GLIBC_PREREQ(2, 31) */ |
77 |
++# endif /* __GLIBC_PREREQ */ |
78 |
++#endif /* __linux__ */ |
79 |
|
80 |
diff --git a/media-gfx/blender/files/blender-3.2.2-support-building-with-musl-libc.patch b/media-gfx/blender/files/blender-3.2.2-support-building-with-musl-libc.patch |
81 |
new file mode 100644 |
82 |
index 000000000000..fb3f2584f0fe |
83 |
--- /dev/null |
84 |
+++ b/media-gfx/blender/files/blender-3.2.2-support-building-with-musl-libc.patch |
85 |
@@ -0,0 +1,177 @@ |
86 |
+CMake: support building with musl libc |
87 |
+ |
88 |
+Instead of using macros like GLIBC we can use the CMake build |
89 |
+systems internal functions to check if some header or functions are |
90 |
+present on the running system's libc. |
91 |
+ |
92 |
+Add ./build_files/cmake/have_features.cmake to add checks for |
93 |
+platform features which can be used to set defines for source |
94 |
+files that require them. |
95 |
+ |
96 |
+Please refer: https://github.com/blender/blender/commit/f197b1a1f1bbc0334310fb1c911327246767a1a3 |
97 |
+--- a/CMakeLists.txt |
98 |
++++ b/CMakeLists.txt |
99 |
+@@ -112,6 +112,11 @@ blender_project_hack_post() |
100 |
+ |
101 |
+ enable_testing() |
102 |
+ |
103 |
++#----------------------------------------------------------------------------- |
104 |
++# Test compiler/library features. |
105 |
++ |
106 |
++include(build_files/cmake/have_features.cmake) |
107 |
++ |
108 |
+ #----------------------------------------------------------------------------- |
109 |
+ # Redirect output files |
110 |
+ |
111 |
+--- /dev/null |
112 |
++++ b/build_files/cmake/have_features.cmake |
113 |
+@@ -0,0 +1,33 @@ |
114 |
++# SPDX-License-Identifier: GPL-2.0-or-later |
115 |
++# Copyright 2022 Blender Foundation. All rights reserved. |
116 |
++ |
117 |
++# This file is used to test the system for headers & symbols. |
118 |
++# Variables should use the `HAVE_` prefix. |
119 |
++# Defines should use the same name as the CMAKE variable. |
120 |
++ |
121 |
++include(CheckSymbolExists) |
122 |
++ |
123 |
++# Used for: `intern/guardedalloc/intern/mallocn_intern.h`. |
124 |
++# Function `malloc_stats` is only available on GLIBC, |
125 |
++# so check that before defining `HAVE_MALLOC_STATS`. |
126 |
++check_symbol_exists(malloc_stats "malloc.h" HAVE_MALLOC_STATS_H) |
127 |
++ |
128 |
++# Used for: `source/creator/creator_signals.c`. |
129 |
++# The function `feenableexcept` is not present non-GLIBC systems, |
130 |
++# hence we need to check if it's available in the `fenv.h` file. |
131 |
++set(HAVE_FEENABLEEXCEPT OFF) |
132 |
++if(CMAKE_SYSTEM_NAME STREQUAL "Linux") |
133 |
++ check_symbol_exists(feenableexcept "fenv.h" HAVE_FEENABLEEXCEPT) |
134 |
++endif() |
135 |
++ |
136 |
++# Used for: `source/blender/blenlib/intern/system.c`. |
137 |
++# `execinfo` is not available on non-GLIBC systems (at least not on MUSL-LIBC), |
138 |
++# so check the presence of the header before including it and using the it for back-trace. |
139 |
++set(HAVE_EXECINFO_H OFF) |
140 |
++if(NOT MSVC) |
141 |
++ include(CheckIncludeFiles) |
142 |
++ check_include_files("execinfo.h" HAVE_EXECINFO_H) |
143 |
++ if(HAVE_EXECINFO_H) |
144 |
++ add_definitions(-DHAVE_EXECINFO_H) |
145 |
++ endif() |
146 |
++endif() |
147 |
+--- a/intern/guardedalloc/CMakeLists.txt |
148 |
++++ b/intern/guardedalloc/CMakeLists.txt |
149 |
+@@ -1,6 +1,10 @@ |
150 |
+ # SPDX-License-Identifier: GPL-2.0-or-later |
151 |
+ # Copyright 2006 Blender Foundation. All rights reserved. |
152 |
+ |
153 |
++if(HAVE_MALLOC_STATS_H) |
154 |
++ add_definitions(-DHAVE_MALLOC_STATS_H) |
155 |
++endif() |
156 |
++ |
157 |
+ set(INC |
158 |
+ . |
159 |
+ ../atomic |
160 |
+--- a/intern/guardedalloc/intern/mallocn_intern.h |
161 |
++++ b/intern/guardedalloc/intern/mallocn_intern.h |
162 |
+@@ -17,8 +17,7 @@ |
163 |
+ #undef HAVE_MALLOC_STATS |
164 |
+ #define USE_MALLOC_USABLE_SIZE /* internal, when we have malloc_usable_size() */ |
165 |
+ |
166 |
+-#if defined(__linux__) || (defined(__FreeBSD_kernel__) && !defined(__FreeBSD__)) || \ |
167 |
+- defined(__GLIBC__) |
168 |
++#if defined(HAVE_MALLOC_STATS_H) |
169 |
+ # include <malloc.h> |
170 |
+ # define HAVE_MALLOC_STATS |
171 |
+ #elif defined(__FreeBSD__) |
172 |
+--- a/source/blender/blenlib/CMakeLists.txt |
173 |
++++ b/source/blender/blenlib/CMakeLists.txt |
174 |
+@@ -1,6 +1,10 @@ |
175 |
+ # SPDX-License-Identifier: GPL-2.0-or-later |
176 |
+ # Copyright 2006 Blender Foundation. All rights reserved. |
177 |
+ |
178 |
++if(HAVE_EXECINFO_H) |
179 |
++ add_definitions(-DHAVE_EXECINFO_H) |
180 |
++endif() |
181 |
++ |
182 |
+ set(INC |
183 |
+ . |
184 |
+ # ../blenkernel # don't add this back! |
185 |
+--- a/source/blender/blenlib/intern/system.c |
186 |
++++ b/source/blender/blenlib/intern/system.c |
187 |
+@@ -21,7 +21,9 @@ |
188 |
+ |
189 |
+ # include "BLI_winstuff.h" |
190 |
+ #else |
191 |
+-# include <execinfo.h> |
192 |
++# if defined(HAVE_EXECINFO_H) |
193 |
++# include <execinfo.h> |
194 |
++# endif |
195 |
+ # include <unistd.h> |
196 |
+ #endif |
197 |
+ |
198 |
+@@ -61,9 +63,9 @@ int BLI_cpu_support_sse2(void) |
199 |
+ #if !defined(_MSC_VER) |
200 |
+ void BLI_system_backtrace(FILE *fp) |
201 |
+ { |
202 |
+- /* ------------- */ |
203 |
+- /* Linux / Apple */ |
204 |
+-# if defined(__linux__) || defined(__APPLE__) |
205 |
++ /* ----------------------- */ |
206 |
++ /* If system as execinfo.h */ |
207 |
++# if defined(HAVE_EXECINFO_H) |
208 |
+ |
209 |
+ # define SIZE 100 |
210 |
+ void *buffer[SIZE]; |
211 |
+--- a/source/blender/makesdna/intern/CMakeLists.txt |
212 |
++++ b/source/blender/makesdna/intern/CMakeLists.txt |
213 |
+@@ -5,6 +5,11 @@ |
214 |
+ |
215 |
+ add_definitions(-DWITH_DNA_GHASH) |
216 |
+ |
217 |
++# Needed for `mallocn.c`. |
218 |
++if(HAVE_MALLOC_STATS_H) |
219 |
++ add_definitions(-DHAVE_MALLOC_STATS_H) |
220 |
++endif() |
221 |
++ |
222 |
+ blender_include_dirs( |
223 |
+ ../../../../intern/atomic |
224 |
+ ../../../../intern/guardedalloc |
225 |
+--- a/source/blender/makesrna/intern/CMakeLists.txt |
226 |
++++ b/source/blender/makesrna/intern/CMakeLists.txt |
227 |
+@@ -6,6 +6,11 @@ if(CMAKE_COMPILER_IS_GNUCC) |
228 |
+ string(APPEND CMAKE_C_FLAGS " -Werror=implicit-function-declaration") |
229 |
+ endif() |
230 |
+ |
231 |
++# Needed for `mallocn.c`. |
232 |
++if(HAVE_MALLOC_STATS_H) |
233 |
++ add_definitions(-DHAVE_MALLOC_STATS_H) |
234 |
++endif() |
235 |
++ |
236 |
+ # files rna_access.c rna_define.c makesrna.c intentionally excluded. |
237 |
+ set(DEFSRC |
238 |
+ rna_ID.c |
239 |
+--- a/source/creator/CMakeLists.txt |
240 |
++++ b/source/creator/CMakeLists.txt |
241 |
+@@ -22,6 +22,10 @@ set(LIB |
242 |
+ bf_windowmanager |
243 |
+ ) |
244 |
+ |
245 |
++if(HAVE_FEENABLEEXCEPT) |
246 |
++ add_definitions(-DHAVE_FEENABLEEXCEPT) |
247 |
++endif() |
248 |
++ |
249 |
+ if(WITH_TBB) |
250 |
+ # Force TBB libraries to be in front of MKL (part of OpenImageDenoise), so |
251 |
+ # that it is initialized before MKL and static library initialization order |
252 |
+--- a/source/creator/creator_signals.c |
253 |
++++ b/source/creator/creator_signals.c |
254 |
+@@ -258,7 +258,7 @@ void main_signal_setup_fpe(void) |
255 |
+ * set breakpoints on sig_handle_fpe */ |
256 |
+ signal(SIGFPE, sig_handle_fpe); |
257 |
+ |
258 |
+-# if defined(__linux__) && defined(__GNUC__) |
259 |
++# if defined(__linux__) && defined(__GNUC__) && defined(HAVE_FEENABLEEXCEPT) |
260 |
+ feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); |
261 |
+ # endif /* defined(__linux__) && defined(__GNUC__) */ |
262 |
+ # if defined(OSX_SSE_FPE) |