From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/7770 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] When building, don't use flags which cause compiler warning Date: Tue, 26 May 2015 14:18:30 -0400 Message-ID: <20150526181830.GD17573@brightrain.aerifal.cx> References: <1432662694-13524-1-git-send-email-alexinbeijing@gmail.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1432664360 24134 80.91.229.3 (26 May 2015 18:19:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 26 May 2015 18:19:20 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-7782-gllmg-musl=m.gmane.org@lists.openwall.com Tue May 26 20:19:12 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1YxJR7-0002CU-BC for gllmg-musl@m.gmane.org; Tue, 26 May 2015 20:18:45 +0200 Original-Received: (qmail 5418 invoked by uid 550); 26 May 2015 18:18:43 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 5398 invoked from network); 26 May 2015 18:18:43 -0000 Content-Disposition: inline In-Reply-To: <1432662694-13524-1-git-send-email-alexinbeijing@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:7770 Archived-At: 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