On some platforms (tested on the following), Valgrind 3.13.0 will fail to configure/compile/link against the MUSL 1.1.16 library. Other versions have not been tested, though other versions may also be affected. MUSL provides a GCC wrapper called 'musl-gcc' which loads a GCC '.conf' file on top of the system GCC, though these changes are not actually printed when the '-dumpversion' flag is used. This flag is used to test whether MUSL is being used; and in this case, the configure script(s) fail to detect MUSL and die with an error about not having glibc >= 2.2. A simple workaround is provided below, following the steps to replicate the issue. $ uname -a Linux hostname 3.10.0-514.21.1.el7.x86_64 #1 SMP Thu May 25 17:04:51 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux $ gcc --version gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-11) (1) Compile and install MUSL 1.1.16: $ wget http://www.musl-libc.org/releases/musl-1.1.16.tar.gz $ tar -xf musl-1.1.16.tar.gz $ cd musl-1.1.16 $ ./configure --prefix=$HOME/musl --disable-shared $ make -j`nproc` install (2) Attempt to compile Valgrind 3.13.0: $ wget ftp://sourceware.org/pub/valgrind/valgrind-3.13.0.tar.bz2 $ tar -xjf valgrind-3.13.0.tar.bz2 $ cd valgrind-3.13.0 $ CC=$HOME/musl/bin/musl-gcc \ ./configure --prefix=$HOME/valgrind (3) Observe that it prints the following, then exits: configure: error: Valgrind requires glibc version 2.2 or later, uClibc, (4) To remedy the issue, run: $ sed -e 's@-dumpmachine |@-v |\&@' -i configure* # gets .ac too $ CC=$HOME/musl/bin/musl-gcc \ ./configure --prefix=$HOME/valgrind $ make -j`nproc` install (5) Observe that Valgrind is successfully configured, compiled, installed. Z
This diff seems to be more portable diff --git a/configure.ac b/configure.ac index b83787291..93b57504c 100755 --- a/configure.ac +++ b/configure.ac @@ -1085,7 +1085,7 @@ fi # GLIBC_VERSION is empty if a musl libc is used, so use the toolchain tuple # in this case. if test x$GLIBC_VERSION = x; then - if $CC -dumpmachine | grep -q musl; then + if $CC -v 2>&1 | grep -q musl; then GLIBC_VERSION=musl fi fi (The proposed modification does not work on Alpine Linux, presumably because the shell doesn't support csh redirection syntax.
I am not sure how well musl libc is supported in the first place. It seems alpine linux is the only distro that has it as default, so if your change doesn't work for them then that seems not good. There must be a better way to detect musl at configure time. Since we need to know about various internals of the C library to properly function, it would be nice to have a more solid test.
From what I've seen on Alpine, the basic musl support is there (e.g., for memcheck) but there are quite a few issues (regtest build failures, helgrind totally broken). The musl detection on Alpine seems OK at the moment. This item is for running musl on glibc systems - I tried it on Fedora 33 amd64. In this case musl provides a GCC wrapper which I imagine just adds -nostdlib and all tghe lib options for musl. It's this wrapper that configure is failing to detect. The patch uses stderr redirection that only works with bash (and maybe zsh), and it looks like Alpine is using ash. I used "2>&1 |" instead, which I think works on all of the bourne family that autoconf might be using. I'll look a bit more at making the grep pattern a bit safer.