0001-linux-fix-build-against-musl.patch (2745B)
1 From fa6fabb9c078dca6b67c7a4168f0e536812da225 Mon Sep 17 00:00:00 2001 2 From: Randy Palamar <randy@rnpnr.xyz> 3 Date: Tue, 4 Mar 2025 15:12:11 -0700 4 Subject: [PATCH 1/2] linux: fix build against musl 5 6 --- 7 renderdoc/3rdparty/plthook/plthook_elf.c | 6 +++++- 8 renderdoc/os/os_specific.h | 1 + 9 renderdoc/os/posix/linux/linux_callstack.cpp | 3 +-- 10 renderdoc/os/posix/linux/linux_hook.cpp | 4 ++++ 11 4 files changed, 11 insertions(+), 3 deletions(-) 12 13 diff --git a/renderdoc/3rdparty/plthook/plthook_elf.c b/renderdoc/3rdparty/plthook/plthook_elf.c 14 index 6fc2ac6e3..3926ef6d0 100644 15 --- a/renderdoc/3rdparty/plthook/plthook_elf.c 16 +++ b/renderdoc/3rdparty/plthook/plthook_elf.c 17 @@ -236,7 +236,11 @@ int plthook_open_by_address(plthook_t **plthook_out, void *address) 18 struct link_map *lmap = NULL; 19 20 *plthook_out = NULL; 21 +#ifdef __GLIBC__ 22 if (dladdr1(address, &info, (void**)&lmap, RTLD_DL_LINKMAP) == 0) { 23 +#else 24 + if (dladdr(address, &info) == 0) { 25 +#endif 26 set_errmsg("dladdr error"); 27 return PLTHOOK_FILE_NOT_FOUND; 28 } 29 @@ -246,7 +250,7 @@ int plthook_open_by_address(plthook_t **plthook_out, void *address) 30 31 static int plthook_open_executable(plthook_t **plthook_out) 32 { 33 -#if defined __linux__ 34 +#if defined __linux__ && defined __GLIBC__ 35 return plthook_open_real(plthook_out, _r_debug.r_map); 36 #elif defined __sun 37 const char *auxv_file = "/proc/self/auxv"; 38 diff --git a/renderdoc/os/os_specific.h b/renderdoc/os/os_specific.h 39 index a11dec357..882c30e5a 100644 40 --- a/renderdoc/os/os_specific.h 41 +++ b/renderdoc/os/os_specific.h 42 @@ -31,6 +31,7 @@ 43 44 #pragma once 45 46 +#include <time.h> 47 #include <stdarg.h> 48 #include <stddef.h> 49 #include <stdint.h> 50 diff --git a/renderdoc/os/posix/linux/linux_callstack.cpp b/renderdoc/os/posix/linux/linux_callstack.cpp 51 index e6151a7e5..a70648684 100644 52 --- a/renderdoc/os/posix/linux/linux_callstack.cpp 53 +++ b/renderdoc/os/posix/linux/linux_callstack.cpp 54 @@ -27,7 +27,6 @@ 55 #define _GNU_SOURCE 56 #endif 57 58 -#include <execinfo.h> 59 #include <link.h> 60 #include <stdio.h> 61 #include <string.h> 62 @@ -66,7 +65,7 @@ private: 63 { 64 void *addrs_ptr[ARRAY_COUNT(addrs)]; 65 66 - int ret = backtrace(addrs_ptr, ARRAY_COUNT(addrs)); 67 + int ret = 0; 68 69 numLevels = 0; 70 if(ret > 0) 71 diff --git a/renderdoc/os/posix/linux/linux_hook.cpp b/renderdoc/os/posix/linux/linux_hook.cpp 72 index 6e6a781a8..56ec173c1 100644 73 --- a/renderdoc/os/posix/linux/linux_hook.cpp 74 +++ b/renderdoc/os/posix/linux/linux_hook.cpp 75 @@ -36,6 +36,10 @@ 76 #include "plthook/plthook.h" 77 #include "strings/string_utils.h" 78 79 +#ifndef __GLIBC__ 80 +#define RTLD_DEEPBIND 0 81 +#endif 82 + 83 Threading::CriticalSection libLock; 84 85 RDOC_EXTERN_CONFIG(bool, Linux_Debug_PtraceLogging); 86 -- 87 2.45.2 88