Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jeffhostetler opened this issue Jun 3, 2020 · 5 comments · Fixed by #276
Closed

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

jeffhostetler opened this issue Jun 3, 2020 · 5 comments · Fixed by #276

Comments

@jeffhostetler
Copy link
Collaborator

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??

@jeffhostetler
Copy link
Collaborator Author

jeffhostetler@7533abb

This the -E hack. Use it with make MSVC=1 DEBUG=1 CFLAGS="-E".
I'm not creating a PR for this now, since the real fix should be upstream rather than here.
And this hack could go with it.

@dscho
Copy link
Member

dscho commented Jun 3, 2020

Where does that -I/mingw64/include come from? That should not be there, MSVC cannot handle those headers.

@jeffhostetler
Copy link
Collaborator Author

Either of these lines, I think.
https://github.com/microsoft/git/blob/vfs-2.27.0/Makefile#L1366
https://github.com/microsoft/git/blob/vfs-2.27.0/Makefile#L1379

Here's what I get when I look at curl-config:

$ curl-config --cflags
-I/mingw64/include

So we get that stuck into CURL_CFLAGS and that gets appended onto BASIC_CFLAGS
at https://github.com/microsoft/git/blob/vfs-2.27.0/Makefile#L1381 .

@jeffhostetler
Copy link
Collaborator Author

So the resulting command line looks like this. I suggest that the -I is coming from the
CURL block because it appears between the HAVE_ALLOCA_H and the USE_CURL_FOR_IMAP_SEND terms.

www.txt:8040:compat/vcbuild/scripts/clink.pl -o fuzz-commit-graph.o -c
-nologo -I. -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H
-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -I"C:\work\msft\compat\vcbuild\vcpkg\installed\x64-windows\include"
-I"C:/Program Files (x86)/Windows Kits/10/Include/10.0.18362.0/ucrt"
-I"C:/Program Files (x86)/Windows Kits/10/Include/10.0.18362.0/um"
-I"C:/Program Files (x86)/Windows Kits/10/Include/10.0.18362.0/shared"
-I"C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.26.28801/INCLUDE"
-L"C:\work\msft\compat\vcbuild\vcpkg\installed\x64-windows\debug\lib"
-L"C:/Program Files (x86)/Windows Kits/10/lib/10.0.18362.0/ucrt/x64"
-L"C:/Program Files (x86)/Windows Kits/10/lib/10.0.18362.0/um/x64"
-L"C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.26.28801/lib/x64"
-Zi -MDd -DDEBUG -D_DEBUG -DGIT_HOST_CPU="\"x86_64\""
-DHAVE_ALLOCA_H -I/mingw64/include -DUSE_CURL_FOR_IMAP_SEND -DNO_ST_BLOCKS_IN_STRUCT_STAT
-DNO_SYMLINK_HEAD -DNO_GETTEXT -DNO_POLL_H -DNO_SYS_POLL_H -DNO_INTTYPES_H -DMMAP_PREVENTS_DELETE
-DNO_IPV6 -DNO_UNIX_SOCKETS -DNO_POSIX_GOODIES -DSHA1_DC -DSHA1DC_NO_STANDARD_INCLUDES
-DSHA1DC_INIT_SAFE_HASH_DEFAULT=0 -DSHA1DC_CUSTOM_INCLUDE_SHA1_C="\"cache.h\""
-DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="\"git-compat-util.h\"" -DSHA256_BLK  -DUNRELIABLE_FSTAT
-DNATIVE_CRLF -DHAVE_WPGMPTR -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DENSURE_MSYSTEM_IS_SET
-DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
-DNO_LIBGEN_H -DNO_POLL -Icompat/poll -DNO_STRCASESTR -DNO_STRLCPY -DNO_STRTOUMAX -DNO_SETENV -DNO_MKDTEMP
-DUSE_WIN32_MMAP -DOBJECT_CREATION_MODE=1 -DNO_PREAD -DNO_MEMMEM
-DRUNTIME_PREFIX -Icompat/regex -DSHELL_PATH='"/bin/sh"' -DDEFAULT_HELP_FORMAT='"html"'
-DPAGER_ENV='"LESS=FRX LV=-c"'
fuzz-commit-graph.c

@dscho
Copy link
Member

dscho commented Jun 3, 2020

[...] it appears between the HAVE_ALLOCA_H and the USE_CURL_FOR_IMAP_SEND terms.

Ah, it's most likely caused by https://github.com/git-for-windows/git/blob/v2.27.0.windows.1/Makefile#L1374.

As this was kind of intentional, maybe our best bet is to add an if clause before https://github.com/git-for-windows/git/blob/v2.27.0.windows.1/compat/vcbuild/scripts/clink.pl#L26 that skips -I/mingw{32,64}/...?

dscho added a commit to dscho/git that referenced this issue Jun 4, 2020
In 897d68e (Makefile: use curl-config --cflags, 2020-03-26), we
taught the build process to use `curl-config --cflags` to make sure that
it can find cURL's headers.

In the MSVC build, this is completely bogus because we're running in a
Git for Windows SDK whose `curl-config` supports the _GCC_ build.

Let's just ignore each and every `-I<path>` option where `<path>` points
to GCC/Clang specific headers.

Reported by Jeff Hostetler in
microsoft#275.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho dscho closed this as completed in #276 Jun 4, 2020
dscho added a commit to dscho/git that referenced this issue Jun 4, 2020
In 897d68e (Makefile: use curl-config --cflags, 2020-03-26), we
taught the build process to use `curl-config --cflags` to make sure that
it can find cURL's headers.

In the MSVC build, this is completely bogus because we're running in a
Git for Windows SDK whose `curl-config` supports the _GCC_ build.

Let's just ignore each and every `-I<path>` option where `<path>` points
to GCC/Clang specific headers.

Reported by Jeff Hostetler in
microsoft#275.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/git that referenced this issue Jun 4, 2020
In 897d68e (Makefile: use curl-config --cflags, 2020-03-26), we
taught the build process to use `curl-config --cflags` to make sure that
it can find cURL's headers.

In the MSVC build, this is completely bogus because we're running in a
Git for Windows SDK whose `curl-config` supports the _GCC_ build.

Let's just ignore each and every `-I<path>` option where `<path>` points
to GCC/Clang specific headers.

Reported by Jeff Hostetler in
microsoft#275.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
git-for-windows-ci pushed a commit to git-for-windows/git that referenced this issue Jun 4, 2020
In 897d68e (Makefile: use curl-config --cflags, 2020-03-26), we
taught the build process to use `curl-config --cflags` to make sure that
it can find cURL's headers.

In the MSVC build, this is completely bogus because we're running in a
Git for Windows SDK whose `curl-config` supports the _GCC_ build.

Let's just ignore each and every `-I<path>` option where `<path>` points
to GCC/Clang specific headers.

Reported by Jeff Hostetler in
microsoft#275.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
git-for-windows-ci pushed a commit to git-for-windows/git that referenced this issue Jun 4, 2020
In 897d68e (Makefile: use curl-config --cflags, 2020-03-26), we
taught the build process to use `curl-config --cflags` to make sure that
it can find cURL's headers.

In the MSVC build, this is completely bogus because we're running in a
Git for Windows SDK whose `curl-config` supports the _GCC_ build.

Let's just ignore each and every `-I<path>` option where `<path>` points
to GCC/Clang specific headers.

Reported by Jeff Hostetler in
microsoft#275.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
git-for-windows-ci pushed a commit to git-for-windows/git that referenced this issue Jun 4, 2020
In 897d68e (Makefile: use curl-config --cflags, 2020-03-26), we
taught the build process to use `curl-config --cflags` to make sure that
it can find cURL's headers.

In the MSVC build, this is completely bogus because we're running in a
Git for Windows SDK whose `curl-config` supports the _GCC_ build.

Let's just ignore each and every `-I<path>` option where `<path>` points
to GCC/Clang specific headers.

Reported by Jeff Hostetler in
microsoft#275.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
gitster pushed a commit to git/git that referenced this issue Jun 4, 2020
In 897d68e (Makefile: use curl-config --cflags, 2020-03-26), we
taught the build process to use `curl-config --cflags` to make sure that
it can find cURL's headers.

In the MSVC build, this is completely bogus because we're running in a
Git for Windows SDK whose `curl-config` supports the _GCC_ build.

Let's just ignore each and every `-I<path>` option where `<path>` points
to GCC/Clang specific headers.

Reported by Jeff Hostetler in
microsoft#275.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-for-windows-ci pushed a commit to git-for-windows/git that referenced this issue Jun 6, 2020
In 897d68e (Makefile: use curl-config --cflags, 2020-03-26), we
taught the build process to use `curl-config --cflags` to make sure that
it can find cURL's headers.

In the MSVC build, this is completely bogus because we're running in a
Git for Windows SDK whose `curl-config` supports the _GCC_ build.

Let's just ignore each and every `-I<path>` option where `<path>` points
to GCC/Clang specific headers.

Reported by Jeff Hostetler in
microsoft#275.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
git-for-windows-ci pushed a commit to git-for-windows/git that referenced this issue Jun 6, 2020
In 897d68e (Makefile: use curl-config --cflags, 2020-03-26), we
taught the build process to use `curl-config --cflags` to make sure that
it can find cURL's headers.

In the MSVC build, this is completely bogus because we're running in a
Git for Windows SDK whose `curl-config` supports the _GCC_ build.

Let's just ignore each and every `-I<path>` option where `<path>` points
to GCC/Clang specific headers.

Reported by Jeff Hostetler in
microsoft#275.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
git-for-windows-ci pushed a commit to git-for-windows/git that referenced this issue Jun 6, 2020
In 897d68e (Makefile: use curl-config --cflags, 2020-03-26), we
taught the build process to use `curl-config --cflags` to make sure that
it can find cURL's headers.

In the MSVC build, this is completely bogus because we're running in a
Git for Windows SDK whose `curl-config` supports the _GCC_ build.

Let's just ignore each and every `-I<path>` option where `<path>` points
to GCC/Clang specific headers.

Reported by Jeff Hostetler in
microsoft#275.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
git-for-windows-ci pushed a commit to git-for-windows/git that referenced this issue Jun 8, 2020
In 897d68e (Makefile: use curl-config --cflags, 2020-03-26), we
taught the build process to use `curl-config --cflags` to make sure that
it can find cURL's headers.

In the MSVC build, this is completely bogus because we're running in a
Git for Windows SDK whose `curl-config` supports the _GCC_ build.

Let's just ignore each and every `-I<path>` option where `<path>` points
to GCC/Clang specific headers.

Reported by Jeff Hostetler in
microsoft#275.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
git-for-windows-ci pushed a commit to git-for-windows/git that referenced this issue Jun 8, 2020
In 897d68e (Makefile: use curl-config --cflags, 2020-03-26), we
taught the build process to use `curl-config --cflags` to make sure that
it can find cURL's headers.

In the MSVC build, this is completely bogus because we're running in a
Git for Windows SDK whose `curl-config` supports the _GCC_ build.

Let's just ignore each and every `-I<path>` option where `<path>` points
to GCC/Clang specific headers.

Reported by Jeff Hostetler in
microsoft#275.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
git-for-windows-ci pushed a commit to git-for-windows/git that referenced this issue Jun 8, 2020
In 897d68e (Makefile: use curl-config --cflags, 2020-03-26), we
taught the build process to use `curl-config --cflags` to make sure that
it can find cURL's headers.

In the MSVC build, this is completely bogus because we're running in a
Git for Windows SDK whose `curl-config` supports the _GCC_ build.

Let's just ignore each and every `-I<path>` option where `<path>` points
to GCC/Clang specific headers.

Reported by Jeff Hostetler in
microsoft#275.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
git-for-windows-ci pushed a commit to git-for-windows/git that referenced this issue Jun 9, 2020
In 897d68e (Makefile: use curl-config --cflags, 2020-03-26), we
taught the build process to use `curl-config --cflags` to make sure that
it can find cURL's headers.

In the MSVC build, this is completely bogus because we're running in a
Git for Windows SDK whose `curl-config` supports the _GCC_ build.

Let's just ignore each and every `-I<path>` option where `<path>` points
to GCC/Clang specific headers.

Reported by Jeff Hostetler in
microsoft#275.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
git-for-windows-ci pushed a commit to git-for-windows/git that referenced this issue Jun 9, 2020
In 897d68e (Makefile: use curl-config --cflags, 2020-03-26), we
taught the build process to use `curl-config --cflags` to make sure that
it can find cURL's headers.

In the MSVC build, this is completely bogus because we're running in a
Git for Windows SDK whose `curl-config` supports the _GCC_ build.

Let's just ignore each and every `-I<path>` option where `<path>` points
to GCC/Clang specific headers.

Reported by Jeff Hostetler in
microsoft#275.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
git-for-windows-ci pushed a commit to git-for-windows/git that referenced this issue Jun 9, 2020
In 897d68e (Makefile: use curl-config --cflags, 2020-03-26), we
taught the build process to use `curl-config --cflags` to make sure that
it can find cURL's headers.

In the MSVC build, this is completely bogus because we're running in a
Git for Windows SDK whose `curl-config` supports the _GCC_ build.

Let's just ignore each and every `-I<path>` option where `<path>` points
to GCC/Clang specific headers.

Reported by Jeff Hostetler in
microsoft#275.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
git-for-windows-ci pushed a commit to git-for-windows/git that referenced this issue Jun 12, 2020
In 897d68e (Makefile: use curl-config --cflags, 2020-03-26), we
taught the build process to use `curl-config --cflags` to make sure that
it can find cURL's headers.

In the MSVC build, this is completely bogus because we're running in a
Git for Windows SDK whose `curl-config` supports the _GCC_ build.

Let's just ignore each and every `-I<path>` option where `<path>` points
to GCC/Clang specific headers.

Reported by Jeff Hostetler in
microsoft#275.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
git-for-windows-ci pushed a commit to git-for-windows/git that referenced this issue Jun 16, 2020
In 897d68e (Makefile: use curl-config --cflags, 2020-03-26), we
taught the build process to use `curl-config --cflags` to make sure that
it can find cURL's headers.

In the MSVC build, this is completely bogus because we're running in a
Git for Windows SDK whose `curl-config` supports the _GCC_ build.

Let's just ignore each and every `-I<path>` option where `<path>` points
to GCC/Clang specific headers.

Reported by Jeff Hostetler in
microsoft#275.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
git-for-windows-ci pushed a commit to git-for-windows/git that referenced this issue Jun 16, 2020
In 897d68e (Makefile: use curl-config --cflags, 2020-03-26), we
taught the build process to use `curl-config --cflags` to make sure that
it can find cURL's headers.

In the MSVC build, this is completely bogus because we're running in a
Git for Windows SDK whose `curl-config` supports the _GCC_ build.

Let's just ignore each and every `-I<path>` option where `<path>` points
to GCC/Clang specific headers.

Reported by Jeff Hostetler in
microsoft#275.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
git-for-windows-ci pushed a commit to git-for-windows/git that referenced this issue Jun 18, 2020
In 897d68e (Makefile: use curl-config --cflags, 2020-03-26), we
taught the build process to use `curl-config --cflags` to make sure that
it can find cURL's headers.

In the MSVC build, this is completely bogus because we're running in a
Git for Windows SDK whose `curl-config` supports the _GCC_ build.

Let's just ignore each and every `-I<path>` option where `<path>` points
to GCC/Clang specific headers.

Reported by Jeff Hostetler in
microsoft#275.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to git-for-windows/git that referenced this issue Jul 2, 2020
In 897d68e (Makefile: use curl-config --cflags, 2020-03-26), we
taught the build process to use `curl-config --cflags` to make sure that
it can find cURL's headers.

In the MSVC build, this is completely bogus because we're running in a
Git for Windows SDK whose `curl-config` supports the _GCC_ build.

Let's just ignore each and every `-I<path>` option where `<path>` points
to GCC/Clang specific headers.

Reported by Jeff Hostetler in
microsoft#275.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
git-for-windows-ci pushed a commit to git-for-windows/git that referenced this issue Jul 3, 2020
In 897d68e (Makefile: use curl-config --cflags, 2020-03-26), we
taught the build process to use `curl-config --cflags` to make sure that
it can find cURL's headers.

In the MSVC build, this is completely bogus because we're running in a
Git for Windows SDK whose `curl-config` supports the _GCC_ build.

Let's just ignore each and every `-I<path>` option where `<path>` points
to GCC/Clang specific headers.

Reported by Jeff Hostetler in
microsoft#275.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to git-for-windows/git that referenced this issue Jul 8, 2020
In 897d68e (Makefile: use curl-config --cflags, 2020-03-26), we
taught the build process to use `curl-config --cflags` to make sure that
it can find cURL's headers.

In the MSVC build, this is completely bogus because we're running in a
Git for Windows SDK whose `curl-config` supports the _GCC_ build.

Let's just ignore each and every `-I<path>` option where `<path>` points
to GCC/Clang specific headers.

Reported by Jeff Hostetler in
microsoft#275.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to git-for-windows/git that referenced this issue Jul 17, 2020
In 897d68e (Makefile: use curl-config --cflags, 2020-03-26), we
taught the build process to use `curl-config --cflags` to make sure that
it can find cURL's headers.

In the MSVC build, this is completely bogus because we're running in a
Git for Windows SDK whose `curl-config` supports the _GCC_ build.

Let's just ignore each and every `-I<path>` option where `<path>` points
to GCC/Clang specific headers.

Reported by Jeff Hostetler in
microsoft#275.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants