git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Thomas Rast
Message 3 of 3 in “Compiling git with -Werror”
  1. Michael HaggertyApr 27, 2012
  2. Thomas RastApr 27, 2012
  3. Jeff KingApr 27, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.