Skip to content

Odd compile error with RES_STARTEND and regex.h version on MSVC build #275

@jeffhostetler

Description

@jeffhostetler

I think I've found a problem in the Makefile for v2.27.0. (I haven't tracked it back to when it first appeared yet.)

Basically, when building the MSVC version (using make MSVC=1 DEBUG=1) I'm seeing an error

...
fuzz-commit-graph.c
C:\work\msft\git-compat-util.h(1135): fatal error C1189:
    #error:  "Git requires REG_STARTEND support. Compile with NO_REGEX=NeedsStartEnd"
...

However, we're already defining that symbol in config.mak.uname in the MSVC section.

Hacking the Makefile to include -E and looking at the CPP output shows that the compiler is
finding the wrong version of regex.h. It is finding:

...
__pragma(pack(pop))
#line 189 "C:\\work\\msft\\git-compat-util.h"
#line 1 "C:\\git-sdk-64\\mingw64\\include\\regex.h"
...

and NOT the one in ./compat/regex/regex.h

Note that the MSVC section in config.mak.uname is adding -Icompat -Icompat/regex to COMPAT_FLAGS at https://github.com/microsoft/git/blob/vfs-2.27.0/config.mak.uname#L451 (and later again at https://github.com/microsoft/git/blob/vfs-2.27.0/Makefile#L1793 )

Later, COMPAT_CFLAGS gets appended to BASIC_CFLAGS at https://github.com/microsoft/git/blob/vfs-2.27.0/Makefile#L2004

BUT At https://github.com/microsoft/git/blob/vfs-2.27.0/Makefile#L1357-L1381
(and when CURLDIR is mingw64) we append -I/mingw64/include to BASIC_CFLAGS,
but this happens before COMPAT_CFLAGS is appended.

Therefore, the compiler sees ... -I/mingw64/include -Icompat -Icompat/regex ...
and tries to use the wrong version of regex.h which leads to the compiler error.

I'm not sure if this problem is unique to a conflict with CURL. It looks like it Expat, ZLib,
IConv, and a few others could similarly update BASIC_CFLAGS before the values from
COMPAT_CFLAGS are brought in.

Thoughts??

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions