From 30a1bfa3be92330deec39636d3b7123fb745163f Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 30 Oct 2025 17:19:20 -0600 Subject: [PATCH] libdrm: fix compilation --- recipes/wip/x11/libdrm/recipe.toml | 9 ++++ recipes/wip/x11/libdrm/redox.patch | 80 ++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 recipes/wip/x11/libdrm/redox.patch diff --git a/recipes/wip/x11/libdrm/recipe.toml b/recipes/wip/x11/libdrm/recipe.toml index f2775b034..7627cf899 100644 --- a/recipes/wip/x11/libdrm/recipe.toml +++ b/recipes/wip/x11/libdrm/recipe.toml @@ -1,6 +1,15 @@ # TODO: Port sys/ioccom.h just like BSD? [source] tar = "https://gitlab.freedesktop.org/mesa/libdrm/-/archive/libdrm-2.4.125/libdrm-libdrm-2.4.125.tar.gz" +blake3 = "33e6448252639f4ff8a8cd30129b335c5d85356c1c93f8d77a79221003b14f66" +patches = ["redox.patch"] [build] template = "meson" +mesonflags = [ + "-Damdgpu=disabled", + "-Dintel=disabled", + "-Dnouveau=disabled", + "-Dradeon=disabled", + "-Dvmwgfx=disabled", +] \ No newline at end of file diff --git a/recipes/wip/x11/libdrm/redox.patch b/recipes/wip/x11/libdrm/redox.patch new file mode 100644 index 000000000..8d1e755ae --- /dev/null +++ b/recipes/wip/x11/libdrm/redox.patch @@ -0,0 +1,80 @@ +diff -ruwN source-old/include/drm/drm.h source/include/drm/drm.h +--- source-old/include/drm/drm.h 2025-06-08 06:27:53.000000000 -0600 ++++ source/include/drm/drm.h 2025-10-30 17:17:33.654234959 -0600 +@@ -44,7 +44,11 @@ + #else /* One of the BSDs */ + + #include ++#if defined(__redox__) ++#include ++#else + #include ++#endif + #include + typedef int8_t __s8; + typedef uint8_t __u8; +diff -ruwN source-old/xf86drm.c source/xf86drm.c +--- source-old/xf86drm.c 2025-06-08 06:27:53.000000000 -0600 ++++ source/xf86drm.c 2025-10-30 17:18:58.374958567 -0600 +@@ -57,6 +57,19 @@ + #ifdef MAJOR_IN_SYSMACROS + #include + #endif ++#if defined(__redox__) ++// From musl sys/sysmacros.h ++#define major(x) \ ++ ((unsigned)( (((x)>>31>>1) & 0xfffff000) | (((x)>>8) & 0x00000fff) )) ++#define minor(x) \ ++ ((unsigned)( (((x)>>12) & 0xffffff00) | ((x) & 0x000000ff) )) ++ ++#define makedev(x,y) ( \ ++ (((x)&0xfffff000ULL) << 32) | \ ++ (((x)&0x00000fffULL) << 8) | \ ++ (((y)&0xffffff00ULL) << 12) | \ ++ (((y)&0x000000ffULL)) ) ++#endif + #if HAVE_SYS_SYSCTL_H + #include + #endif +@@ -304,9 +317,14 @@ + char *modifier_name = NULL; + bool result = false; + ++#if defined(__redox__) ++ fprintf(stderr, "open_memstream not available on Redox\n"); ++ return NULL; ++#else + fp = open_memstream(&modifier_name, &size); + if (!fp) + return NULL; ++#endif + + switch (type) { + case DRM_FORMAT_MOD_ARM_TYPE_AFBC: +@@ -409,9 +427,14 @@ + char *mod_amd = NULL; + size_t size = 0; + ++#if defined(__redox__) ++ fprintf(stderr, "open_memstream not available on Redox\n"); ++ return NULL; ++#else + fp = open_memstream(&mod_amd, &size); + if (!fp) + return NULL; ++#endif + + switch (tile_version) { + case AMD_FMT_MOD_TILE_VER_GFX9: +diff -ruwN source-old/xf86drm.h source/xf86drm.h +--- source-old/xf86drm.h 2025-06-08 06:27:53.000000000 -0600 ++++ source/xf86drm.h 2025-10-30 17:17:33.655115281 -0600 +@@ -47,7 +47,7 @@ + #define DRM_MAX_MINOR 64 /* deprecated */ + #endif + +-#if defined(__linux__) ++#if defined(__linux__) || defined(__redox__) + + #define DRM_IOCTL_NR(n) _IOC_NR(n) + #define DRM_IOC_VOID _IOC_NONE