1 |
commit: 35fa4d2f59a272a53e02f54b6c962217d8d67554 |
2 |
Author: Jory Pratt <anarchy <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Jan 21 03:50:56 2022 +0000 |
4 |
Commit: Jory Pratt <anarchy <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Jan 21 03:50:56 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=35fa4d2f |
7 |
|
8 |
media-libs/mesa: backport patches for non glibc users |
9 |
|
10 |
Package-Manager: Portage-3.0.28, Repoman-3.0.3 |
11 |
Signed-off-by: Jory Pratt <anarchy <AT> gentoo.org> |
12 |
|
13 |
media-libs/mesa/Manifest | 2 +- |
14 |
.../mesa-21.1.4-add-disable-tls-support.patch | 42 ------- |
15 |
media-libs/mesa/files/mesa-tls-2.patch | 60 +++++++++ |
16 |
media-libs/mesa/files/mesa-tls.patch | 134 +++++++++++++++++++++ |
17 |
.../{mesa-21.2.6.ebuild => mesa-21.3.4.ebuild} | 30 ++--- |
18 |
media-libs/mesa/metadata.xml | 2 - |
19 |
6 files changed, 204 insertions(+), 66 deletions(-) |
20 |
|
21 |
diff --git a/media-libs/mesa/Manifest b/media-libs/mesa/Manifest |
22 |
index 9cc0fbb3..6fdb1557 100644 |
23 |
--- a/media-libs/mesa/Manifest |
24 |
+++ b/media-libs/mesa/Manifest |
25 |
@@ -1 +1 @@ |
26 |
-DIST mesa-21.2.6.tar.xz 15868208 BLAKE2B aaa6447a2f5a472c2ee2b7d6b12effb79d02804684358fd233aa00bda945c66efa3850931cd9114c51ddd492033b9f66372380395540a11fe40229edfe7ee125 SHA512 e65d77e2609cba85bd2cdbd4ba2072729c1556a43defdd24a91e708e3223f84b23657e63a91b16c5729684ea12fe31f45bae88294c572e057f2981a5d6c0f5a0 |
27 |
+DIST mesa-21.3.4.tar.xz 16497248 BLAKE2B 3fe2543bb6286a0d84a247785dbb4b5dd6df905eab748a89854589008d9db5aae6c52e473c58cff8d03694d46d3ce2a2680fddc8c978f898dc9bcdec02ca9b6b SHA512 7aeea3dba0d39f4ac9f23c54aa0e6853d48000f50c4dd484618c28debe705cdd765ae8fafb5ddea0773976f7189849d9128be3f2282fea74394b59019cb786b9 |
28 |
|
29 |
diff --git a/media-libs/mesa/files/mesa-21.1.4-add-disable-tls-support.patch b/media-libs/mesa/files/mesa-21.1.4-add-disable-tls-support.patch |
30 |
deleted file mode 100644 |
31 |
index 8e7089c9..00000000 |
32 |
--- a/media-libs/mesa/files/mesa-21.1.4-add-disable-tls-support.patch |
33 |
+++ /dev/null |
34 |
@@ -1,42 +0,0 @@ |
35 |
-From a9b290ecff1ed3fdfd95bae551ce47dea8fa13fb Mon Sep 17 00:00:00 2001 |
36 |
-From: Jory Pratt <anarchy@g.o> |
37 |
-Date: Tue, 6 Jul 2021 07:54:09 -0500 |
38 |
-Subject: [PATCH] Add disable glx support for musl |
39 |
- |
40 |
---- |
41 |
- meson.build | 4 +++- |
42 |
- meson_options.txt | 6 ++++++ |
43 |
- 2 files changed, 9 insertions(+), 1 deletion(-) |
44 |
- |
45 |
-diff --git a/meson.build b/meson.build |
46 |
-index e1e94e7..b355f94 100644 |
47 |
---- a/meson.build |
48 |
-+++ b/meson.build |
49 |
-@@ -447,7 +447,9 @@ endif |
50 |
- |
51 |
- # Android uses emutls for versions <= P/28. For USE_ELF_TLS we need ELF TLS. |
52 |
- use_elf_tls = false |
53 |
--if (not ['freebsd', 'openbsd', 'haiku'].contains(host_machine.system()) and |
54 |
-+with_use_elf_tls = get_option('use-elf-tls') |
55 |
-+if with_use_elf_tls and |
56 |
-+ (not ['freebsd', 'openbsd', 'haiku'].contains(host_machine.system()) and |
57 |
- (not with_platform_android or get_option('platform-sdk-version') >= 29) and |
58 |
- (not with_platform_windows or not with_shared_glapi)) |
59 |
- pre_args += '-DUSE_ELF_TLS' |
60 |
-diff --git a/meson_options.txt b/meson_options.txt |
61 |
-index a7030ab..73bd28e 100644 |
62 |
---- a/meson_options.txt |
63 |
-+++ b/meson_options.txt |
64 |
-@@ -465,3 +465,9 @@ option( |
65 |
- value : true, |
66 |
- description : 'use msse2 flag for mingw x86. Default: true', |
67 |
- ) |
68 |
-+option( |
69 |
-+ 'use-elf-tls', |
70 |
-+ type : 'boolean', |
71 |
-+ value : false, |
72 |
-+ description : 'Build support for initial-exec TLS model' |
73 |
-+) |
74 |
--- |
75 |
-2.31.1 |
76 |
- |
77 |
|
78 |
diff --git a/media-libs/mesa/files/mesa-tls-2.patch b/media-libs/mesa/files/mesa-tls-2.patch |
79 |
new file mode 100644 |
80 |
index 00000000..c849e27d |
81 |
--- /dev/null |
82 |
+++ b/media-libs/mesa/files/mesa-tls-2.patch |
83 |
@@ -0,0 +1,60 @@ |
84 |
+From 60d95c5d0feef4e4b2820a26c4708aff10f5730d Mon Sep 17 00:00:00 2001 |
85 |
+From: "Alex Xu (Hello71)" <alex_y_xu@×××××.ca> |
86 |
+Date: Thu, 2 Sep 2021 12:19:53 -0400 |
87 |
+Subject: [PATCH] Auto-enable TLSDESC support |
88 |
+MIME-Version: 1.0 |
89 |
+Content-Type: text/plain; charset=UTF-8 |
90 |
+Content-Transfer-Encoding: 8bit |
91 |
+ |
92 |
+TLSDESC speeds up access to dynamic TLS. This is especially important |
93 |
+for non-glibc targets, but is also helpful for non-initial-exec TLS |
94 |
+variables. |
95 |
+ |
96 |
+The entry asm does not support TLSDESC, but it only accesses |
97 |
+initial-exec symbols, so it is not necessary to handle that separately. |
98 |
+ |
99 |
+Acked-by: Tapani Pälli <tapani.palli@×××××.com> |
100 |
+Acked-by: Jesse Natalie <jenatali@×××××××××.com> |
101 |
+Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12722> |
102 |
+--- |
103 |
+ meson.build | 24 ++++++++++++++++++++++++ |
104 |
+ 1 file changed, 24 insertions(+) |
105 |
+ |
106 |
+diff --git a/meson.build b/meson.build |
107 |
+index a7ace23677c..29f0c3f3912 100644 |
108 |
+--- a/meson.build |
109 |
++++ b/meson.build |
110 |
+@@ -520,6 +520,30 @@ if not with_platform_windows or not with_shared_glapi |
111 |
+ c_args += '-fno-emulated-tls' |
112 |
+ cpp_args += '-fno-emulated-tls' |
113 |
+ endif |
114 |
++ |
115 |
++ # -mtls-dialect=gnu2 speeds up non-initial-exec TLS significantly but requires |
116 |
++ # full toolchain (including libc) support. |
117 |
++ have_mtls_dialect = false |
118 |
++ foreach c_arg : get_option('c_args') |
119 |
++ if c_arg.startswith('-mtls-dialect=') |
120 |
++ have_mtls_dialect = true |
121 |
++ break |
122 |
++ endif |
123 |
++ endforeach |
124 |
++ if not have_mtls_dialect |
125 |
++ # need .run to check libc support. meson aborts when calling .run when |
126 |
++ # cross-compiling, but because this is just an optimization we can skip it |
127 |
++ if meson.is_cross_build() |
128 |
++ warning('cannot auto-detect -mtls-dialect when cross-compiling, using compiler default') |
129 |
++ else |
130 |
++ # -fpic to force dynamic tls, otherwise TLS relaxation defeats check |
131 |
++ gnu2_test = cc.run('int __thread x; int main() { return x; }', args: ['-mtls-dialect=gnu2', '-fpic'], name: '-mtls-dialect=gnu2') |
132 |
++ if gnu2_test.returncode() == 0 |
133 |
++ c_args += '-mtls-dialect=gnu2' |
134 |
++ cpp_args += '-mtls-dialect=gnu2' |
135 |
++ endif |
136 |
++ endif |
137 |
++ endif |
138 |
+ endif |
139 |
+ |
140 |
+ if with_glx != 'disabled' |
141 |
+-- |
142 |
+GitLab |
143 |
+ |
144 |
|
145 |
diff --git a/media-libs/mesa/files/mesa-tls.patch b/media-libs/mesa/files/mesa-tls.patch |
146 |
new file mode 100644 |
147 |
index 00000000..f445c934 |
148 |
--- /dev/null |
149 |
+++ b/media-libs/mesa/files/mesa-tls.patch |
150 |
@@ -0,0 +1,134 @@ |
151 |
+From 8570a2a280587a1e43ac11ad46ad62dfdd6c7b39 Mon Sep 17 00:00:00 2001 |
152 |
+From: "Alex Xu (Hello71)" <alex_y_xu@×××××.ca> |
153 |
+Date: Thu, 2 Sep 2021 11:58:32 -0400 |
154 |
+Subject: [PATCH] Use initial-exec TLS for glibc only, enable TLS elsewhere |
155 |
+MIME-Version: 1.0 |
156 |
+Content-Type: text/plain; charset=UTF-8 |
157 |
+Content-Transfer-Encoding: 8bit |
158 |
+ |
159 |
+It is not portable to use initial-exec TLS in dlopened libraries. glibc |
160 |
+and FreeBSD allocate extra memory for extra initial-exec variables |
161 |
+specifically for libGL, but other libcs including musl do not. |
162 |
+ |
163 |
+Keep initial-exec disabled on FreeBSD since it is apparently broken for |
164 |
+some reason: |
165 |
+ |
166 |
+https://gitlab.freedesktop.org/mesa/mesa/-/issues/966#note_394512 |
167 |
+https://github.com/jbeich/mesa/commit/81dbdb15d55054242eded0eb2f32621d583c1aaf |
168 |
+ |
169 |
+Enable TLS on OpenBSD and Haiku based on the u_thread.h comment that |
170 |
+emutls is better than pthread_getspecific, which seems plausible given |
171 |
+that emutls has strictly more information to work with. |
172 |
+ |
173 |
+Fixes #966. |
174 |
+ |
175 |
+Acked-by: Tapani Pälli <tapani.palli@×××××.com> |
176 |
+Acked-by: Jesse Natalie <jenatali@×××××××××.com> |
177 |
+Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12722> |
178 |
+--- |
179 |
+ meson.build | 7 ++----- |
180 |
+ src/mapi/entry.c | 28 ++++++++++++++-------------- |
181 |
+ src/util/u_thread.h | 16 ++++++---------- |
182 |
+ 3 files changed, 22 insertions(+), 29 deletions(-) |
183 |
+ |
184 |
+diff --git a/meson.build b/meson.build |
185 |
+index cf2b5f4b939..a7ace23677c 100644 |
186 |
+--- a/meson.build |
187 |
++++ b/meson.build |
188 |
+@@ -508,15 +508,12 @@ foreach platform : _platforms |
189 |
+ pre_args += '-DHAVE_@0@_PLATFORM'.format(platform.to_upper()) |
190 |
+ endforeach |
191 |
+ |
192 |
+-# Android uses emutls for versions <= P/28. For USE_ELF_TLS we need ELF TLS. |
193 |
+ use_elf_tls = false |
194 |
+-if (not ['freebsd', 'openbsd', 'haiku'].contains(host_machine.system()) and |
195 |
+- (not with_platform_android or get_option('platform-sdk-version') >= 29) and |
196 |
+- (not with_platform_windows or not with_shared_glapi)) |
197 |
++if not with_platform_windows or not with_shared_glapi |
198 |
+ pre_args += '-DUSE_ELF_TLS' |
199 |
+ use_elf_tls = true |
200 |
+ |
201 |
+- if with_platform_android |
202 |
++ if with_platform_android and get_option('platform-sdk-version') >= 29 |
203 |
+ # By default the NDK compiler, at least, emits emutls references instead of |
204 |
+ # ELF TLS, even when building targeting newer API levels. Make it actually do |
205 |
+ # ELF TLS instead. |
206 |
+diff --git a/src/mapi/entry.c b/src/mapi/entry.c |
207 |
+index 7ff3c8f8c8c..b120eae31a1 100644 |
208 |
+--- a/src/mapi/entry.c |
209 |
++++ b/src/mapi/entry.c |
210 |
+@@ -31,6 +31,7 @@ |
211 |
+ #include "entry.h" |
212 |
+ #include "u_current.h" |
213 |
+ #include "util/u_endian.h" |
214 |
++#include "util/u_thread.h" |
215 |
+ |
216 |
+ #define _U_STRINGIFY(x) #x |
217 |
+ #define U_STRINGIFY(x) _U_STRINGIFY(x) |
218 |
+@@ -45,20 +46,19 @@ |
219 |
+ #define ENTRY_CURRENT_TABLE_GET U_STRINGIFY(u_current_get_table_internal) |
220 |
+ #endif |
221 |
+ |
222 |
+-#if defined(USE_X86_ASM) && defined(__GNUC__) |
223 |
+-# ifdef USE_ELF_TLS |
224 |
+-# include "entry_x86_tls.h" |
225 |
+-# else |
226 |
+-# include "entry_x86_tsd.h" |
227 |
+-# endif |
228 |
+-#elif defined(USE_X86_64_ASM) && defined(__GNUC__) && defined(USE_ELF_TLS) |
229 |
+-# include "entry_x86-64_tls.h" |
230 |
+-#elif defined(USE_PPC64LE_ASM) && defined(__GNUC__) && UTIL_ARCH_LITTLE_ENDIAN |
231 |
+-# ifdef USE_ELF_TLS |
232 |
+-# include "entry_ppc64le_tls.h" |
233 |
+-# else |
234 |
+-# include "entry_ppc64le_tsd.h" |
235 |
+-# endif |
236 |
++/* REALLY_INITIAL_EXEC implies USE_ELF_TLS and __GNUC__ */ |
237 |
++/* Use TSD stubs for non-IE ELF TLS even though first access is slower because |
238 |
++ * future accesses will be patched */ |
239 |
++#if defined(USE_X86_ASM) && defined(REALLY_INITIAL_EXEC) |
240 |
++#include "entry_x86_tls.h" |
241 |
++#elif defined(USE_X86_ASM) && !defined(GLX_X86_READONLY_TEXT) && defined(__GNUC__) |
242 |
++#include "entry_x86_tsd.h" |
243 |
++#elif defined(USE_X86_64_ASM) && defined(REALLY_INITIAL_EXEC) |
244 |
++#include "entry_x86-64_tls.h" |
245 |
++#elif defined(USE_PPC64LE_ASM) && UTIL_ARCH_LITTLE_ENDIAN && defined(REALLY_INITIAL_EXEC) |
246 |
++#include "entry_ppc64le_tls.h" |
247 |
++#elif defined(USE_PPC64LE_ASM) && UTIL_ARCH_LITTLE_ENDIAN && defined(__GNUC__) |
248 |
++#include "entry_ppc64le_tsd.h" |
249 |
+ #else |
250 |
+ |
251 |
+ static inline const struct _glapi_table * |
252 |
+diff --git a/src/util/u_thread.h b/src/util/u_thread.h |
253 |
+index 0fb474f32ba..a4215452d35 100644 |
254 |
+--- a/src/util/u_thread.h |
255 |
++++ b/src/util/u_thread.h |
256 |
+@@ -75,19 +75,15 @@ |
257 |
+ * still want to use normal TLS (which involves a function call, but not the |
258 |
+ * expensive pthread_getspecific() or its equivalent). |
259 |
+ */ |
260 |
++#ifdef USE_ELF_TLS |
261 |
+ #ifdef _MSC_VER |
262 |
+ #define __THREAD_INITIAL_EXEC __declspec(thread) |
263 |
+-#elif defined(ANDROID) |
264 |
+-/* Android 29 gained ELF TLS support, but it doesn't support initial-exec and |
265 |
+- * it will throw: |
266 |
+- * |
267 |
+- * dlopen failed: TLS symbol "(null)" in dlopened |
268 |
+- * "/vendor/lib64/egl/libEGL_mesa.so" referenced from |
269 |
+- * "/vendor/lib64/egl/libEGL_mesa.so" using IE access model. |
270 |
+- */ |
271 |
+-#define __THREAD_INITIAL_EXEC __thread |
272 |
+-#else |
273 |
++#elif defined(__GLIBC__) |
274 |
+ #define __THREAD_INITIAL_EXEC __thread __attribute__((tls_model("initial-exec"))) |
275 |
++#define REALLY_INITIAL_EXEC |
276 |
++#else |
277 |
++#define __THREAD_INITIAL_EXEC __thread |
278 |
++#endif |
279 |
+ #endif |
280 |
+ |
281 |
+ static inline int |
282 |
+-- |
283 |
+GitLab |
284 |
+ |
285 |
|
286 |
diff --git a/media-libs/mesa/mesa-21.2.6.ebuild b/media-libs/mesa/mesa-21.3.4.ebuild |
287 |
similarity index 96% |
288 |
rename from media-libs/mesa/mesa-21.2.6.ebuild |
289 |
rename to media-libs/mesa/mesa-21.3.4.ebuild |
290 |
index dfa0eb93..ec0dad18 100644 |
291 |
--- a/media-libs/mesa/mesa-21.2.6.ebuild |
292 |
+++ b/media-libs/mesa/mesa-21.3.4.ebuild |
293 |
@@ -17,7 +17,7 @@ if [[ ${PV} == 9999 ]]; then |
294 |
inherit git-r3 |
295 |
else |
296 |
SRC_URI="https://archive.mesa3d.org/${MY_P}.tar.xz" |
297 |
- KEYWORDS="amd64 arm arm64 ~mips ppc ppc64 x86" |
298 |
+ KEYWORDS="amd64 arm arm64 ~mips ~ppc ~ppc64 x86" |
299 |
fi |
300 |
|
301 |
LICENSE="MIT" |
302 |
@@ -33,18 +33,15 @@ for card in ${VIDEO_CARDS}; do |
303 |
done |
304 |
|
305 |
IUSE="${IUSE_VIDEO_CARDS} |
306 |
- +classic cpu_flags_x86_sse2 d3d9 debug +egl +gallium +gbm gles1 +gles2 +llvm |
307 |
+ +classic cpu_flags_x86_sse2 d3d9 debug +gallium gles1 +gles2 +llvm |
308 |
lm-sensors opencl osmesa selinux test unwind vaapi valgrind vdpau vulkan |
309 |
vulkan-overlay wayland +X xa xvmc zink +zstd" |
310 |
|
311 |
REQUIRED_USE=" |
312 |
d3d9? ( || ( video_cards_iris video_cards_r300 video_cards_r600 video_cards_radeonsi video_cards_nouveau video_cards_vmware ) ) |
313 |
- gles1? ( egl ) |
314 |
- gles2? ( egl ) |
315 |
osmesa? ( gallium ) |
316 |
vulkan? ( video_cards_radeonsi? ( llvm ) ) |
317 |
vulkan-overlay? ( vulkan ) |
318 |
- wayland? ( egl gbm ) |
319 |
video_cards_crocus? ( gallium ) |
320 |
video_cards_freedreno? ( gallium ) |
321 |
video_cards_intel? ( classic ) |
322 |
@@ -64,7 +61,7 @@ REQUIRED_USE=" |
323 |
video_cards_v3d? ( gallium ) |
324 |
video_cards_vc4? ( gallium ) |
325 |
video_cards_virgl? ( gallium ) |
326 |
- video_cards_vivante? ( gallium gbm ) |
327 |
+ video_cards_vivante? ( gallium ) |
328 |
video_cards_vmware? ( gallium ) |
329 |
xa? ( X ) |
330 |
xvmc? ( X ) |
331 |
@@ -224,7 +221,7 @@ BDEPEND=" |
332 |
sys-devel/flex |
333 |
virtual/pkgconfig |
334 |
$(python_gen_any_dep ">=dev-python/mako-0.8.0[\${PYTHON_USEDEP}]") |
335 |
- wayland? ( dev-util/wayland-scanner[${MULTILIB_USEDEP}] ) |
336 |
+ wayland? ( dev-util/wayland-scanner ) |
337 |
" |
338 |
|
339 |
S="${WORKDIR}/${MY_P}" |
340 |
@@ -241,7 +238,8 @@ x86? ( |
341 |
)" |
342 |
|
343 |
PATCHES=( |
344 |
- "${FILESDIR}"/${PN}-21.1.4-add-disable-tls-support.patch |
345 |
+ "${FILESDIR}"/mesa-tls.patch |
346 |
+ "${FILESDIR}"/mesa-tls-2.patch |
347 |
) |
348 |
|
349 |
llvm_check_deps() { |
350 |
@@ -388,17 +386,6 @@ multilib_src_configure() { |
351 |
use wayland && platforms+=",wayland" |
352 |
emesonargs+=(-Dplatforms=${platforms#,}) |
353 |
|
354 |
- if use X || use egl; then |
355 |
- emesonargs+=(-Dglvnd=true) |
356 |
- else |
357 |
- emesonargs+=(-Dglvnd=false) |
358 |
- fi |
359 |
- |
360 |
- # Disable glx tls support on musl |
361 |
- if use elibc_musl; then |
362 |
- emesonargs+=( -Duse-elf-tls=false ) |
363 |
- fi |
364 |
- |
365 |
if use gallium; then |
366 |
emesonargs+=( |
367 |
$(meson_feature llvm) |
368 |
@@ -521,8 +508,9 @@ multilib_src_configure() { |
369 |
-Dglx=$(usex X dri disabled) |
370 |
-Dshared-glapi=enabled |
371 |
-Ddri3=enabled |
372 |
- $(meson_feature egl) |
373 |
- $(meson_feature gbm) |
374 |
+ -Degl=true |
375 |
+ -Dgbm=true |
376 |
+ -Dglvnd=true |
377 |
$(meson_feature gles1) |
378 |
$(meson_feature gles2) |
379 |
$(meson_use osmesa) |
380 |
|
381 |
diff --git a/media-libs/mesa/metadata.xml b/media-libs/mesa/metadata.xml |
382 |
index 2b18aba1..b181eed2 100644 |
383 |
--- a/media-libs/mesa/metadata.xml |
384 |
+++ b/media-libs/mesa/metadata.xml |
385 |
@@ -8,9 +8,7 @@ |
386 |
<use> |
387 |
<flag name="classic">Build drivers based on the classic architecture.</flag> |
388 |
<flag name="d3d9">Enable Direct 3D9 API through Nine state tracker. Can be used together with patched wine.</flag> |
389 |
- <flag name="egl">Enable EGL support.</flag> |
390 |
<flag name="gallium">Build drivers based on Gallium3D, the new architecture for 3D graphics drivers.</flag> |
391 |
- <flag name="gbm">Enable the Graphics Buffer Manager for EGL on KMS.</flag> |
392 |
<flag name="gles1">Enable GLESv1 support.</flag> |
393 |
<flag name="gles2">Enable GLESv2 support.</flag> |
394 |
<flag name="llvm">Enable LLVM backend for Gallium3D.</flag> |