From edcc7bbb5ddcc0794f920471251cad192ca63fc0 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Thu, 5 Nov 2020 08:00:00 +0000 Subject: [PATCH] config.guess: combine two heuristics to detect musl libc Apparently, this is needed to correctly detect musl libc in different versions of Alpine Linux. According to https://lists.gnu.org/archive/html/config-patches/2020-09/msg00002.html, the ldd based check does not work for some old versions of the Alpine Linux, and, according to https://lists.gnu.org/archive/html/config-patches/2020-11/msg00002.html, the compiler may not be available in a fresh Alpine container. The ldd based check is essentially the same as the check that was introduced by commit 3d00f60242f1726fc6eaa38e09435a969ee7ebe5, it is performed iff the compiler based check could not give a definitive answer. Reported-by: Cheng XU Signed-off-by: Dmitry V. Levin --- ChangeLog | 4 ++++ config.guess | 24 ++++++++++++++++++------ config.sub | 2 +- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6d7ce74..665054d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2020-11-17 Dmitry V. Levin + + * config.guess: Combine two heuristics to detect musl libc. + 2020-11-07 Ben Elliston * config.sub, config.guess: Replace backtick `..` substitutions diff --git a/config.guess b/config.guess index 0fc11ed..31f610c 100755 --- a/config.guess +++ b/config.guess @@ -2,7 +2,7 @@ # Attempt to guess a canonical system name. # Copyright 1992-2020 Free Software Foundation, Inc. -timestamp='2020-11-07' +timestamp='2020-11-17' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -138,9 +138,7 @@ UNAME_VERSION=$( (uname -v) 2>/dev/null) || UNAME_VERSION=unknown case "$UNAME_SYSTEM" in Linux|GNU|GNU/*) - # If the system lacks a compiler, then just pick glibc. - # We could probably try harder. - LIBC=gnu + LIBC=unknown set_cc_for_build cat <<-EOF > "$dummy.c" @@ -149,16 +147,30 @@ Linux|GNU|GNU/*) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc + #elif defined(__GLIBC__) + LIBC=gnu #else #include + /* First heuristic to detect musl libc. */ #ifdef __DEFINED_va_list LIBC=musl - #else - LIBC=gnu #endif #endif EOF eval "$($CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g')" + + # Second heuristic to detect musl libc. + if [ "$LIBC" = unknown ] && + command -v ldd >/dev/null && + ldd --version 2>&1 | grep -q ^musl; then + LIBC=musl + fi + + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + if [ "$LIBC" = unknown ]; then + LIBC=gnu + fi ;; esac diff --git a/config.sub b/config.sub index c874b7a..e676896 100755 --- a/config.sub +++ b/config.sub @@ -2,7 +2,7 @@ # Configuration validation subroutine script. # Copyright 1992-2020 Free Software Foundation, Inc. -timestamp='2020-11-07' +timestamp='2020-11-17' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by