0
0
mirror of https://github.com/termux/termux-packages.git synced 2025-10-31 22:45:59 +00:00
Files
termux-packages/packages/mesa/0015-fix-detection-memfd_create-getrandom.patch
Robert Kirkman 411745ec37 bump(main/mesa): 25.2.4
- Fixes https://github.com/termux/termux-packages/issues/26526

- Fixes https://github.com/termux/termux-packages/issues/25371

- All patches seemed to only need minor rebasing and no other errors

- Tested working on Samsung Galaxy S9 SM-G960U with Adreno 630

- Add unofficial Adreno 710+720 support found here https://gitlab.freedesktop.org/mesa/mesa/-/issues/13036 and here db9f6d0b31

- After 3294cad341, a new change is required in order to preserve GPU acceleration in the edge case of **EGL+Zink+Turnip+Termux:X11+Adreno 630**. I have named this change `0018-preserve-egl-support-in-zink.patch` and it is an original creation based on my ~2 years of experience developing EGL software for running inside Termux:X11 on Samsung Galaxy S9 SM-G96U with Adreno 630. **Unfortunately, I do not know what the effects of this patch will be on other devices that I do not have, so please tell me ASAP if it appears to break Zink on your device**.

- After 622612f67e, the default behavior of Zink is to enable the "general layout" mode whenever Turnip is detected. In testing in Termux:X11 on Samsung Galaxy A70 SM-A705FN, that change is incorrect and results in severe artifacts in Firefox when Firefox has `gfx.webrender.all=true` and `gfx.x11-egl.force-disabled=true` set in `about:config`, so `0019-disable-general-layout-in-zink-for-turnip.patch` must be created to forcibly stop Zink from enabling "general layout" mode when Turnip is detected.
2025-10-14 11:06:16 -05:00

61 lines
3.0 KiB
Diff

From 42a78a1aae19f855b049462d7714cd1f07ca12e4 Mon Sep 17 00:00:00 2001
From: Fafa Kitten <tacokoneko@gmail.com>
Date: Tue, 30 Sep 2025 01:42:57 -0500
Subject: [PATCH] meson: detect `memfd_create()` and `getrandom()` from
headers, not system libraries
When compiling Mesa on Android targeting Android, under some conditions `memfd_create()` and `getrandom()` are detected as available when they are not, so they should not be assumed to be available unless they are detected by Meson as available in the appropriate header passed in the `prefix` argument to Meson's `has_function()` method.
`memfd_create()` is not available unless the target Android API level is 30 (Android 11) or higher and the define `_GNU_SOURCE` (which in turn sets the define `__USE_GNU`) is set, and Mesa does set `_GNU_SOURCE`, so by setting `args: pre_args` in the appropriate call to `has_function()` (which causes `-D_GNU_SOURCE` to be added to the arguments used by Meson to check the header only if it was detected as necessary for `pre_args` in the earlier condition), `memfd_create()` will be correctly detected as available when targeting (only) Android 11 or newer (and other operating systems that support `memfd_create()`) after this PR,
and `getrandom()` is not available unless the target Android API level is 28 (Android 9) or higher, so `getrandom()` will be detected as available when targeting (only) Android 9 or newer (and other operating systems that support `getrandom()`) after this PR.
Related information:
https://android.googlesource.com/platform/bionic/+/refs/heads/android15-release/libc/include/sys/mman.h#186
https://android.googlesource.com/platform/bionic/+/refs/heads/android15-release/libc/include/sys/random.h#55
https://android.googlesource.com/platform/bionic/+/refs/heads/android15-release/libc/include/sys/cdefs.h#182
https://gitlab.freedesktop.org/mesa/mesa/-/blob/927f65caf359a2e0dda87dd5167fe18d153a9a32/meson.build#L1074
https://github.com/mesonbuild/meson/blob/cab3b67cfe04d0e06d4e7c2f50fb4f99cd0dd7eb/docs/markdown/Compiler-properties.md#does-a-function-exist
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13566
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37630>
---
meson.build | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/meson.build b/meson.build
index 4d0cf1714f234..dab44ad805786 100644
--- a/meson.build
+++ b/meson.build
@@ -1400,11 +1400,11 @@ endforeach
functions_to_detect = {
'strtof': '',
'mkostemp': '',
- 'memfd_create': '',
+ 'memfd_create': '#include <sys/mman.h>',
'random_r': '',
'flock': '',
'strtok_r': '',
- 'getrandom': '',
+ 'getrandom': '#include <sys/random.h>',
'qsort_s': '',
'posix_fallocate': '',
'secure_getenv': '',
@@ -1412,7 +1412,7 @@ functions_to_detect = {
}
foreach f, prefix: functions_to_detect
- if cc.has_function(f, prefix: prefix)
+ if cc.has_function(f, args: pre_args, prefix: prefix)
pre_args += '-DHAVE_@0@'.format(f.to_upper())
endif
endforeach
--
GitLab