mesa: Add hack for overriding libc funcs in shared libs
See https://github.com/termux/x11-packages/issues/638#issuecomment-1070790946.
This commit is contained in:
parent
94efd571b5
commit
671b39bc2c
@ -4,7 +4,7 @@ TERMUX_PKG_LICENSE="MIT"
|
||||
TERMUX_PKG_LICENSE_FILE="docs/license.rst"
|
||||
TERMUX_PKG_MAINTAINER="@termux"
|
||||
TERMUX_PKG_VERSION=21.3.7
|
||||
TERMUX_PKG_REVISION=1
|
||||
TERMUX_PKG_REVISION=2
|
||||
TERMUX_PKG_SRCURL=https://archive.mesa3d.org/mesa-${TERMUX_PKG_VERSION}.tar.xz
|
||||
TERMUX_PKG_SHA256=b4fa9db7aa61bf209ef0b40bef83080999d86ad98df8b8b4fada7c128a1efc3d
|
||||
TERMUX_PKG_DEPENDS="libandroid-shmem, libc++, libx11, libxext, zlib, libexpat"
|
||||
@ -28,7 +28,7 @@ TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
|
||||
|
||||
termux_step_pre_configure() {
|
||||
CPPFLAGS+=" -D__USE_GNU"
|
||||
LDFLAGS+=" -landroid-shmem"
|
||||
# Note: -landroid-shmem in LDFLAGS is not needed because it is dlopen()ed
|
||||
}
|
||||
|
||||
termux_step_post_massage() {
|
||||
|
84
x11-packages/mesa/src-mesa-drivers-x11-xm_buffer.c.patch
Normal file
84
x11-packages/mesa/src-mesa-drivers-x11-xm_buffer.c.patch
Normal file
@ -0,0 +1,84 @@
|
||||
--- a/src/mesa/drivers/x11/xm_buffer.c
|
||||
+++ b/src/mesa/drivers/x11/xm_buffer.c
|
||||
@@ -45,6 +45,81 @@
|
||||
#if defined(USE_XSHM)
|
||||
static volatile int mesaXErrorFlag = 0;
|
||||
|
||||
+#ifdef __ANDROID__
|
||||
+
|
||||
+#include <dlfcn.h>
|
||||
+
|
||||
+typedef int (*shmctl_func_t)(int, int, struct shmid_ds *);
|
||||
+typedef int (*shmget_func_t)(key_t, size_t, int);
|
||||
+typedef void *(*shmat_func_t)(int, void const *, int);
|
||||
+typedef int (*shmdt_func_t)(void const *);
|
||||
+static shmctl_func_t shmctl_func;
|
||||
+static shmget_func_t shmget_func;
|
||||
+static shmat_func_t shmat_func;
|
||||
+static shmdt_func_t shmdt_func;
|
||||
+#undef shmctl
|
||||
+#undef shmget
|
||||
+#undef shmat
|
||||
+#undef shmdt
|
||||
+static int libandroid_shmem_funcs_initialized;
|
||||
+
|
||||
+static void
|
||||
+libandroid_shmem_initialize(void)
|
||||
+{
|
||||
+ if (!libandroid_shmem_funcs_initialized) {
|
||||
+ void *libandroid_shmem_handle = dlopen("libandroid-shmem.so", RTLD_NOW);
|
||||
+ if (libandroid_shmem_handle != NULL) {
|
||||
+ shmctl_func = dlsym(libandroid_shmem_handle, "shmctl");
|
||||
+ shmget_func = dlsym(libandroid_shmem_handle, "shmget");
|
||||
+ shmat_func = dlsym(libandroid_shmem_handle, "shmat");
|
||||
+ shmdt_func = dlsym(libandroid_shmem_handle, "shmdt");
|
||||
+ }
|
||||
+ libandroid_shmem_funcs_initialized = 1;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+#pragma GCC visibility push(hidden)
|
||||
+
|
||||
+int
|
||||
+shmctl(int shmid, int cmd, struct shmid_ds *buf)
|
||||
+{
|
||||
+ if (!libandroid_shmem_funcs_initialized) {
|
||||
+ libandroid_shmem_initialize();
|
||||
+ }
|
||||
+ return shmctl_func(shmid, cmd, buf);
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+shmget(key_t key, size_t size, int shmflg)
|
||||
+{
|
||||
+ if (!libandroid_shmem_funcs_initialized) {
|
||||
+ libandroid_shmem_initialize();
|
||||
+ }
|
||||
+ return shmget_func(key, size, shmflg);
|
||||
+}
|
||||
+
|
||||
+void *
|
||||
+shmat(int shmid, void const *shmaddr, int shmflg)
|
||||
+{
|
||||
+ if (!libandroid_shmem_funcs_initialized) {
|
||||
+ libandroid_shmem_initialize();
|
||||
+ }
|
||||
+ return shmat_func(shmid, shmaddr, shmflg);
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+shmdt(void const *shmaddr)
|
||||
+{
|
||||
+ if (!libandroid_shmem_funcs_initialized) {
|
||||
+ libandroid_shmem_initialize();
|
||||
+ }
|
||||
+ return shmdt_func(shmaddr);
|
||||
+}
|
||||
+
|
||||
+#pragma GCC visibility pop
|
||||
+
|
||||
+#endif /* __ANDROID__ */
|
||||
+
|
||||
/**
|
||||
* Catches potential Xlib errors.
|
||||
*/
|
Loading…
Reference in New Issue
Block a user