Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 26 May 2015 14:18:30 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: [PATCH] When building, don't use flags which cause
 compiler warning

On Tue, May 26, 2015 at 07:51:34PM +0200, Alex Dowad wrote:
> A number of gcc flags are ignored by clang, and it prints annoying warnings
> to let you know. There is no reason to use these flags with a compiler which
> doesn't support them.
> ---
> 
> Dear muslers,
> 
> Not sure what you'll think of this... but please have a look.
> 
> Thanks,
> Alex Dowad
> 
>  configure | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/configure b/configure
> index cf9227a..30daa97 100755
> --- a/configure
> +++ b/configure
> @@ -80,11 +80,16 @@ fi
>  tryflag () {
>  printf "checking whether compiler accepts %s... " "$2"
>  echo "typedef int x;" > "$tmpc"
> -if $CC $2 -c -o /dev/null "$tmpc" >/dev/null 2>&1 ; then
> -printf "yes\n"
> -eval "$1=\"\${$1} \$2\""
> -eval "$1=\${$1# }"
> -return 0
> +if output=$($CC $2 -c -o /dev/null "$tmpc" 2>&1) ; then
> +  if fnmatch '*warning*' "$output"; then
> +    printf "disabled due to compiler warning\n"
> +    return 1
> +  else
> +    printf "yes\n"
> +    eval "$1=\"\${$1} \$2\""
> +    eval "$1=\${$1# }"
> +    return 0
> +  fi
>  else
>  printf "no\n"
>  return 1

I don't like parsing output rather than relying on exit status unless
it's for a really important purpose. The above is dangerous and could
break detection of options we actually need if a spurious warning
somehow arises, which is really common on alternate compilers that add
all sorts of warnings by default. Is there any way to convince clang
to error out on unknown options? Perhaps something like
-Werror=unknown-options?

Rich

Powered by blists - more mailing lists

Your e-mail address:

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