Re: Compiling git with -Werror
- From
Jeff King <peff@peff.net>
- Date
- Apr 27, 2012, 10:07 UTC
- Message-ID
- <20120427100731.GC19918@sigill.intra.peff.net>
- In-Reply-To
- <4F9A6AB0.1050504@alum.mit.edu>
On Fri, Apr 27, 2012 at 11:45:20AM +0200, Michael Haggerty wrote:
> I like to develop with errors and warnings turned up as strict as > possible. For example, I would like to use > > CFLAGS="-g -O2 -Wall -Werror -Wdeclaration-after-statement"
That's more or less how I compile git.
Show 5 quoted lines
> I thought this would be as simple as > > git clean -fdx > make configure > ./configure CFLAGS="-g -O2 -Wall -Werror -Wdeclaration-after-statement"
I don't use our autoconf at all, though. I put settings like that into config.mak, which gets sourced by the Makefile (right after config.mak.autogen, which is what configure produces).
Show 7 quoted lines
> The cause of the problem is that the CFLAGS variable is used by > ./configure when it is running its tests, and some of the tests don't > work correctly (they produce results that are not correct for the > platform) when run with the strict CFLAGS. > [...] > Is there some other mechanism to set strict CFLAGS parameters for the > build without confusing ./configure?
Try putting "CFLAGS += -Werror" in config.mak.
> Is this a bug in how the git project is using autoconf? > > Is it a bug in autoconf itself?
I think autoconf. Our configure input is just using AC_CHECK_FUNC(strtok_r) to generate the test. Which would mean that it's a bad interaction of autoconf's code and your CFLAGS. So I would be surprised if other packages didn't have similar problems.
And indeed, googling for 'autoconf cflags "-Werror"' turns up:
http://lists.gnu.org/archive/html/bug-autoconf/2012-03/msg00070.html
Summary: don't do that. We could add a special option to turn on warnings, but given how easy the config.mak trick above is, I don't know that it's necessary.
-Peff