mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: "Dmitry V. Levin" <ldv@altlinux.org>
Cc: config-patches@gnu.org, musl@lists.openwall.com
Subject: [musl] Re: OS detection wrong on Alpine Linux 3.10
Date: Sun, 20 Sep 2020 13:19:13 +0200	[thread overview]
Message-ID: <1721942.iyVTE8TspN@omega> (raw)
In-Reply-To: <20200920101249.GA29409@altlinux.org>

[-- Attachment #1: Type: text/plain, Size: 791 bytes --]

Dmitry V. Levin wrote:
> Is this __DEFINED_va_list macro the official way of detecting musl?

No, but in a world where the musl people don't want to provide an official
way [1][2] and the Alpine Linux people break their previously working way of
detecting musl [3], we (GNU) need to use our own heuristics to fulfil the
practical need of programs (especially test suites) to distinguish musl
systems from glibc systems.

> It looks very fragile to me.

Indeed, config.guess would be less fragile if we combined both heuristics.
Patch attached. It's a trade-off between code size and robustness.

Bruno

[1] https://wiki.musl-libc.org/faq.html
[2] https://lists.gnu.org/archive/html/bug-gnulib/2018-02/msg00079.html
[3] https://lists.gnu.org/archive/html/config-patches/2020-09/msg00002.html

[-- Attachment #2: 0001-config.guess-Combine-two-heuristics-to-detect-musl-l.patch --]
[-- Type: text/x-patch, Size: 1637 bytes --]

From 78ceae822bde047eea1db841a5feeba94f57fe7d Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 20 Sep 2020 13:17:12 +0200
Subject: [PATCH] * config.guess: Combine two heuristics to detect musl libc.

Reported by Dmitry V. Levin.
---
 ChangeLog    |  5 +++++
 config.guess | 10 +++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 834f4e5..63101b8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2020-09-20  Bruno Haible  <bruno@clisp.org>
+
+	* config.guess: Combine two heuristics to detect musl libc.
+	Reported by Dmitry V. Levin.
+
 2020-09-19  Bruno Haible  <bruno@clisp.org>
 
 	* config.guess: Don't use 'ldd --version' to determine the presence of
diff --git a/config.guess b/config.guess
index 8d70ec2..cd8a0a3 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-09-19'
+timestamp='2020-09-20'
 
 # 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
@@ -151,6 +151,7 @@ Linux|GNU|GNU/*)
 	LIBC=dietlibc
 	#else
 	#include <stdarg.h>
+	/* First heuristic to detect musl libc.  */
 	#ifdef __DEFINED_va_list
 	LIBC=musl
 	#else
@@ -159,6 +160,13 @@ Linux|GNU|GNU/*)
 	#endif
 	EOF
 	eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`"
+
+	# Second heuristic to detect musl libc.
+	if command -v ldd >/dev/null && \
+		ldd --version 2>&1 | grep -q ^musl
+	then
+	    LIBC=musl
+	fi
 	;;
 esac
 
-- 
2.7.4


  reply	other threads:[~2020-09-20 11:19 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4768019.hHWyC0TzgU@omega>
2020-09-20 10:12 ` Dmitry V. Levin
2020-09-20 11:19   ` Bruno Haible [this message]
2020-09-20 12:18     ` Ariadne Conill
2020-09-20 13:56     ` Szabolcs Nagy
2020-09-20 17:14       ` Rich Felker
2020-09-20 19:21         ` Bruno Haible
2020-09-20 20:58           ` Hadrien Lacour
2020-09-21  6:53           ` A. Wilcox
2020-09-21 11:46             ` Florian Weimer
2020-09-22 18:46           ` Rich Felker
2020-09-22 20:18             ` Bruno Haible
2020-09-22 20:33               ` Jeffrey Walton
2020-09-22 20:39             ` Jeffrey Walton
2020-09-22 21:04               ` Laurent Bercot
2020-09-22 21:17                 ` Jeffrey Walton
2020-09-23  8:49                   ` Laurent Bercot
2020-09-23 13:13                     ` James Y Knight
2020-09-23 16:08                       ` Rich Felker
2020-09-23 16:16                         ` Jeffrey Walton
2020-09-23 16:26                           ` Ariadne Conill
2020-09-23 16:57                             ` Jeffrey Walton
2020-09-23 16:36                           ` Rich Felker
2020-09-20 12:19   ` Ariadne Conill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1721942.iyVTE8TspN@omega \
    --to=bruno@clisp.org \
    --cc=config-patches@gnu.org \
    --cc=ldv@altlinux.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).