Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200920101249.GA29409@altlinux.org>
Date: Sun, 20 Sep 2020 13:12:49 +0300
From: "Dmitry V. Levin" <ldv@...linux.org>
To: Bruno Haible <bruno@...sp.org>
Cc: config-patches@....org, musl@...ts.openwall.com
Subject: Re: OS detection wrong on Alpine Linux 3.10

On Sat, Sep 19, 2020 at 03:30:54PM +0200, Bruno Haible wrote:
> The value of $host_os, determined by the current config.guess, is:
>   - On Alpine Linux 3.9: linux-musl
>   - On Alpine Linux 3.10: linux-gnu
>   - On Alpine Linux 3.12: linux-musl
> 
> The reason is that config.guess tests 'ldd --version'. However, in
> Alpine Linux 3.10, /usr/bin/ldd has been replaced with a shell script
> that does not understand the --version option:
> 
> $ cat /usr/bin/ldd
> #!/bin/sh
> exec /lib/ld-musl-x86_64.so.1 --list -- "$@"
> $ /usr/bin/ldd --version 2>&1
> /lib/ld-musl-x86_64.so.1: cannot load --version: No such file or directory
> 
> Find attached a proposed fix. More details in
> <https://lists.gnu.org/archive/html/bug-gnulib/2020-09/msg00098.html>.
> 
> Bruno

> >From 6e8da56c68ad94175d67acfc6257e614fe74e01d Mon Sep 17 00:00:00 2001
> From: Bruno Haible <bruno@...sp.org>
> Date: Sat, 19 Sep 2020 15:24:59 +0200
> Subject: [PATCH] * config.guess: Fix determination of musl libc on Alpine
>  Linux 3.10.
> 
> ---
>  ChangeLog    |  5 +++++
>  config.guess | 14 ++++++--------
>  2 files changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/ChangeLog b/ChangeLog
> index 4f106db..834f4e5 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,8 @@
> +2020-09-19  Bruno Haible  <bruno@...sp.org>
> +
> +	* config.guess: Don't use 'ldd --version' to determine the presence of
> +	musl libc, as this fails on Alpine Linux 3.10.
> +
>  2020-09-08  Elad Lahav  <e2lahav@...il.com>
>  	    Ben Elliston  <bje@....org>
>  
> diff --git a/config.guess b/config.guess
> index 9aff91c..8d70ec2 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-08-17'
> +timestamp='2020-09-19'
>  
>  # 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
> @@ -150,17 +150,15 @@ Linux|GNU|GNU/*)
>  	#elif defined(__dietlibc__)
>  	LIBC=dietlibc
>  	#else
> +	#include <stdarg.h>
> +	#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'`"
> -
> -	# If ldd exists, use it to detect musl libc.
> -	if command -v ldd >/dev/null && \
> -		ldd --version 2>&1 | grep -q ^musl
> -	then
> -	    LIBC=musl
> -	fi
>  	;;
>  esac
>  

Is this __DEFINED_va_list macro the official way of detecting musl?
It looks very fragile to me.


-- 
ldv

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.