Re: Setting -Werror in CFLAGS

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Peter Geoghegan <peter(at)2ndquadrant(dot)com>
Cc: PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Setting -Werror in CFLAGS
Date: 2012-01-18 19:30:47
Message-ID: 1326915047.9180.12.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On ons, 2012-01-04 at 00:39 +0000, Peter Geoghegan wrote:
> This should work:
>
> ./configure --prefix=/home/peter/pgsql CFLAGS="-Werror
> -Wno-error=unused-but-set-variable"
>
> However, it does not (with or without the -Wno-error):
>
> checking whether getpwuid_r takes a fifth argument... no
> checking whether strerror_r returns int... no
> checking test program... ok
> checking whether long int is 64 bits... no
> checking whether long long int is 64 bits... no
> configure: error: Cannot find a working 64-bit integer type.
>
> Obviously it breaks this one configure test. However, I got it to work
> in 2 minutes by hacking up config.log. It would be nice if someone
> could fix the test (and possibly later ones) so that it doesn't
> produce a warning/error when invoking the compiler, and it finds a
> 64-bit int type as expected.

I've tried this in the past, it's pretty difficult to make this work
throughout. I think and easier approach would be to filter out -Werror
out of CFLAGS early in configure and put it back at the end.

> That way, it could sort of become folk wisdom that you should build
> Postgres with those flags during
> development, and maybe even, on some limited basis, on the build farm,
> and we'd all be sightly better off.

I think in practice many developers do this anyway, so you do get that
level of testing already.

> There is an entry in the parser Makefile to support this sort of use,
> which makes it look like my -Wno-error=unused-but-set-variable use
> would be redundant if it worked:
>
> # Latest flex causes warnings in this file.
> ifeq ($(GCC),yes)
> gram.o: CFLAGS += -Wno-error
> endif
>
> (although we could discriminate better within the parse here by using my flag).

The -Wno-error=something flag doesn't work in older versions of GCC.
But feel free to research which ones.

> As if to prove my point, I found this warning which I didn't
> previously notice, just from 5 minutes of playing around:
>
> hashovfl.c: In function ‘_hash_freeovflpage’:
> hashovfl.c:394:10: error: variable ‘bucket’ set but not used
> [-Werror=unused-but-set-variable]
> cc1: all warnings being treated as errors
>
> (plus others)

See thread "[HACKERS] lots of unused variable warnings in assert-free
builds" for the reason.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2012-01-18 19:31:49 Re: Command Triggers
Previous Message Andres Freund 2012-01-18 19:25:48 Re: Command Triggers