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

Breakage (?) in configure and git_vsnprintf()

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Dec 11, 2011, 18:42 UTC
Message-ID
<4EE4F97B.9000202@alum.mit.edu>

I found a mysterious bunch of test suite failures when I compiled git on a 64-bit Linux 3.0.0 using gcc 4.6.1:

    git clean -f -x -d
    make clean
    make configure
    ./configure --prefix=$HOME CFLAGS='-g -O0 -std=c89 -Wall -Werror'
    make test

The failure unexpectedly depended on the presence of all three compiler options "-std=c89 -Wall -Werror". There is no difference between -O0 and -O2. The breakage is in v1.7.7, v1.7.8, and master (I didn't try older versions).

I have been using "-std=c89" when compiling to avoid accidentally using newer C features. Perhaps that is unwise :-)

The same test succeeds on 32-bit Linux 2.6.32 using gcc 4.4.3.
There seem to be two levels to the problem:
1. With this choice of compiler options, configure incorrectly convinces
itself that the system's snprintf() is broken and sets
SNPRINTF_RETURNS_BOGUS.  From config.log:

configure:5368: checking whether snprintf() and/or vsnprintf() return bogus value configure:5406: cc -o conftest -g -O0 --std=c89 -Wall -Werror conftest.c >&5 conftest.c: In function 'test_vsnprintf': conftest.c:62:5: error: implicit declaration of function 'vsnprintf' [-Werror=implicit-function-declaration] conftest.c: In function 'main': conftest.c:72:5: error: implicit declaration of function 'snprintf' [-Werror=implicit-function-declaration] cc1: all warnings being treated as errors

configure:5406: $? = 1 configure: program exited with status 1

According to the manpage, snprintf() and vsnprintf() are truly not supported for "-std=c89" and indeed they are not declared by any of the files included by the test program that configure is using. (Oddly, although they are nominally not supported, vsnprintf() is used anyway in the definition of git_vsnprintf().)

If I leave off any of the compilation options "-std=c89 -Wall -Werror" or if I toggle the "#ifdef SNPRINTF_RETURNS_BOGUS" line in git-compat-util.h off, the problem goes away.

2. The configure problem causes git_vsnprintf() to be wrapped around the
C library version.  This leads to many failures in the test suite.  I
suppose that git_vsnprintf() is broken in some way.

I'm kindof busy with my ref-api patch series so I won't have time to look further into this problem in the near future. But perhaps somebody with experience with the configuration system and/or git_vsnprintf() is interested.

Michael
-- 
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/
Next: Jeff King
Message 1 of 10 in “Breakage (?) in configure and git_vsnprintf()”
  1. Michael HaggertyDec 11, 2011
  2. Jeff KingDec 12, 2011
  3. Johannes SixtDec 12, 2011
  4. Jeff KingDec 12, 2011
  5. Junio C HamanoDec 12, 2011
  6. Andreas SchwabDec 12, 2011
  7. Jeff KingDec 12, 2011
  8. Brandon CaseyDec 12, 2011
  9. Michael HaggertyDec 12, 2011
  10. Jonathan NiederDec 12, 2011

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.