mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [PATCH] When building, don't use flags which cause compiler warning
Date: Tue, 26 May 2015 14:18:30 -0400	[thread overview]
Message-ID: <20150526181830.GD17573@brightrain.aerifal.cx> (raw)
In-Reply-To: <1432662694-13524-1-git-send-email-alexinbeijing@gmail.com>

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


  reply	other threads:[~2015-05-26 18:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-26 17:51 Alex Dowad
2015-05-26 18:18 ` Rich Felker [this message]
2015-05-26 18:36   ` [PATCH v2] When building, don't use compiler flags which cause warnings Alex Dowad
2015-05-26 18:47     ` Rich Felker
2015-05-26 18:55       ` Alex Dowad
2015-05-26 19:36         ` Rich Felker
2015-05-26 19:57           ` Alex Dowad
2015-05-27  2:22             ` Shiz
2015-05-27  3:14               ` Rich Felker
2015-05-27 12:30                 ` Shiz

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=20150526181830.GD17573@brightrain.aerifal.cx \
    --to=dalias@libc.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).