1 From 50859f3577418cc42f76e1319e699202a615bbe1 Mon Sep 17 00:00:00 2001
2 From: Peter Seiderer <ps.report@gmx.net>
3 Date: Sat, 31 Oct 2015 19:45:04 +0100
4 Subject: [PATCH] Fixes for musl libc.
6 - add musl libc detection (prevents configure error)
7 - adjust preload and symbol names (based on the OpenWrt
10 [1] https://dev.openwrt.org/browser/trunk/package/devel/valgrind/patches/200-musl_fix.patch?rev=46302
12 Signed-off-by: Peter Seiderer <ps.report@gmx.net>
14 configure.ac | 16 ++++++++++++++--
15 coregrind/vg_preloaded.c | 2 +-
16 include/pub_tool_redir.h | 9 ++++++++-
17 3 files changed, 23 insertions(+), 4 deletions(-)
19 diff --git a/configure.ac b/configure.ac
20 index 8ab7f9b..e865bf5 100644
23 @@ -1009,6 +1009,13 @@ if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
24 GLIBC_VERSION="solaris"
27 +# GLIBC_VERSION is empty if a musl libc is used, so use the toolchain tuple
29 +if test x$GLIBC_VERSION = x; then
30 + if $CC -dumpmachine | grep -q musl; then
35 AC_MSG_CHECKING([the glibc version])
37 @@ -1064,10 +1071,15 @@ case "${GLIBC_VERSION}" in
38 # DEFAULT_SUPP set in host_os switch-case above.
39 # No other suppression file is used.
43 + AC_DEFINE([MUSL_LIBC], 1, [Define to 1 if you're using Musl libc])
44 + # no DEFAULT_SUPP file yet for musl libc.
47 AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
48 - AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later,])
49 - AC_MSG_ERROR([Darwin libc, Bionic libc or Solaris libc])
50 + AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later, uClibc,])
51 + AC_MSG_ERROR([musl libc, Darwin libc, Bionic libc or Solaris libc])
55 diff --git a/coregrind/vg_preloaded.c b/coregrind/vg_preloaded.c
56 index 2ea7a7a..7b51aba 100644
57 --- a/coregrind/vg_preloaded.c
58 +++ b/coregrind/vg_preloaded.c
60 void VG_NOTIFY_ON_LOAD(freeres)( void );
61 void VG_NOTIFY_ON_LOAD(freeres)( void )
63 -# if !defined(__UCLIBC__) \
64 +# if !defined(__UCLIBC__) && !defined(MUSL_LIBC) \
65 && !defined(VGPV_arm_linux_android) \
66 && !defined(VGPV_x86_linux_android) \
67 && !defined(VGPV_mips32_linux_android) \
68 diff --git a/include/pub_tool_redir.h b/include/pub_tool_redir.h
69 index bac00d7..babcf9a 100644
70 --- a/include/pub_tool_redir.h
71 +++ b/include/pub_tool_redir.h
73 /* --- Soname of the standard C library. --- */
75 #if defined(VGO_linux) || defined(VGO_solaris)
76 +# if defined(MUSL_LIBC)
77 +# define VG_Z_LIBC_SONAME libcZdZa // libc.*
79 # define VG_Z_LIBC_SONAME libcZdsoZa // libc.so*
82 #elif defined(VGO_darwin) && (DARWIN_VERS <= DARWIN_10_6)
83 # define VG_Z_LIBC_SONAME libSystemZdZaZddylib // libSystem.*.dylib
86 /* --- Soname of the pthreads library. --- */
88 #if defined(VGO_linux)
89 +# if defined(MUSL_LIBC)
90 +# define VG_Z_LIBPTHREAD_SONAME libcZdZa // libc.*
92 # define VG_Z_LIBPTHREAD_SONAME libpthreadZdsoZd0 // libpthread.so.0
94 #elif defined(VGO_darwin)
95 # define VG_Z_LIBPTHREAD_SONAME libSystemZdZaZddylib // libSystem.*.dylib
96 #elif defined(VGO_solaris)