From bb9b79145aa56e6ae3fb9438690f3f678342d7f8 Mon Sep 17 00:00:00 2001 From: Hugo Osvaldo Barrera Date: Sat, 15 Aug 2026 20:45:18 +0200 Subject: [PATCH] Enable builds with musl Implement a few minor tweaks so this builds on musl. Should not affect glibc builds in any way. --- configure.ac | 6 ++++++ dlls/ntdll/unix/loader.c | 5 +++++ dlls/winegstreamer/media-converter/media-converter.h | 1 + loader/preloader.c | 3 +++ 4 files changed, 15 insertions(+) diff --git a/configure.ac b/configure.ac index db3f479e3168..203410c88c83 100644 --- a/configure.ac +++ b/configure.ac @@ -1074,6 +1074,12 @@ case $host_os in esac ;; esac + + # Stamp $ORIGIN in the default rpath so musl loads sibling DLLs. glibc doesn't need this: the + # DLLs were already loaded by absolute path and glibc recognises them as the same (based on + # basename). + # Must come last. Value ends up in a makefile, hence the double dollar. + WINE_TRY_CFLAGS([-Wl,-rpath,\\\$ORIGIN],[UNIXLDFLAGS="$UNIXLDFLAGS '-Wl,-rpath,\$\$ORIGIN'"]) ;; esac diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index 4deeac79c286..8ea787e7a798 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -39,6 +39,11 @@ #include #include #include +#ifndef M_PERTURB +/* musl does not implement mallopt(). Only used for debugging; use a no-op. */ +#define M_PERTURB 0 +static inline int mallopt( int param, int value ) { return 1; } +#endif #include #ifdef HAVE_PWD_H # include diff --git a/dlls/winegstreamer/media-converter/media-converter.h b/dlls/winegstreamer/media-converter/media-converter.h index d06534eb991d..b05da9dc301c 100644 --- a/dlls/winegstreamer/media-converter/media-converter.h +++ b/dlls/winegstreamer/media-converter/media-converter.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include "unix_private.h" diff --git a/loader/preloader.c b/loader/preloader.c index 115821337bf9..75c3c59d9075 100644 --- a/loader/preloader.c +++ b/loader/preloader.c @@ -1515,7 +1515,10 @@ void* wld_start( void **stack ) /* expose ld.so _r_debug as a separate namespace in r_next */ ld_so_r_debug = find_symbol( &ld_so_map, "_r_debug", STT_OBJECT ); if (ld_so_r_debug) _r_debug.r_next = (struct wld_r_debug_extended *)ld_so_r_debug; +#ifdef __GLIBC__ + /* musl has no _r_debug; ignore */ else wld_printf( "_r_debug not found in ld.so\n" ); +#endif _r_debug_state(); /* notify GDB that _r_debug is ready */