Issue 11706: Build from hg fails in Modules/getbuildinfo.c when built using ancient hg version (0.9.3) (original) (raw)

With hg/mercurial 0.9.3, the build of CPython fails with this error:

gcc -pthread -c -fno-strict-aliasing -g -O0 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -DPy_BUILD_CORE
-DHGVERSION=""LC_ALL=C hg id -i .""
-DHGTAG=""LC_ALL=C hg id -t .""
-DHGBRANCH=""LC_ALL=C hg id -b .""
-o Modules/getbuildinfo.o ./Modules/getbuildinfo.c hg identify: option -i not recognized hg identify: option -t not recognized hg identify: option -b not recognized ./Modules/getbuildinfo.c: In function ‘Py_GetBuildInfo’: ./Modules/getbuildinfo.c:37: error: missing terminating " character ./Modules/getbuildinfo.c:37: error: expected expression before ‘)’ token ./Modules/getbuildinfo.c:38: error: missing terminating " character ./Modules/getbuildinfo.c:38: error: missing terminating " character ./Modules/getbuildinfo.c:39: error: missing terminating " character ./Modules/getbuildinfo.c:39: error: missing terminating " character ./Modules/getbuildinfo.c:45: error: ‘buildinfo’ undeclared (first use in this function) ./Modules/getbuildinfo.c:45: error: (Each undeclared identifier is reported only once ./Modules/getbuildinfo.c:45: error: for each function it appears in.) ./Modules/getbuildinfo.c:49: warning: control reaches end of non-void function ./Modules/getbuildinfo.c: In function ‘_Py_hgversion’: ./Modules/getbuildinfo.c:54: error: missing terminating " character ./Modules/getbuildinfo.c:54: warning: ‘return’ with no value, in function returning non-void ./Modules/getbuildinfo.c: In function ‘_Py_hgidentifier’: ./Modules/getbuildinfo.c:61: error: missing terminating " character ./Modules/getbuildinfo.c:61: error: expected expression before ‘;’ token ./Modules/getbuildinfo.c:65: error: missing terminating " character ./Modules/getbuildinfo.c:65: error: expected expression before ‘;’ token make: *** [Modules/getbuildinfo.o] Error 1

What's happening is that "hg id" doesn't recognize the given options, and thus the various HG macros get set to insane multi-line strings containing usage information, but without quote characters, rather than to empty string literals [1]. This means that the post-processed code isn't valid C.

The workaround presumably is to upgrade to a more recent version of mercurial. I'm reporting this here in the bug tracker in case anyone else runs into this problem.

[1] Adding "-v" to the gcc invocation demonstrates that the values being passed are:

-DHGVERSION="hg identify

print information about the working copy

Print a short summary of the current state of the repo.

This summary identifies the repository state using one or two parent
hash identifiers, followed by a "+" if there are uncommitted changes
in the working directory, followed by a list of tags for this revision.

aliases: id" -DHGTAG="hg identify

print information about the working copy

Print a short summary of the current state of the repo.

This summary identifies the repository state using one or two parent
hash identifiers, followed by a "+" if there are uncommitted changes
in the working directory, followed by a list of tags for this revision.

aliases: id" -DHGBRANCH="hg identify

print information about the working copy

Print a short summary of the current state of the repo.

This summary identifies the repository state using one or two parent
hash identifiers, followed by a "+" if there are uncommitted changes
in the working directory, followed by a list of tags for this revision.

aliases: id"

Works OK with mercurial 1.3.1 (specifically, this is on a RHEL5 box, using mercurial-1.3.1-3.el5.i386.rpm from EPEL5)

Closing this out, and changing title to help people searching for this. Not sure of the exact version of mercurial that's required.