Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Hostetler <jeffhost@microsoft.com>2019-06-25 17:49:39 +0300
committerJunio C Hamano <gitster@pobox.com>2019-06-25 20:46:57 +0300
commitdce7d295514f0acebb897cc37a451963d60588f5 (patch)
treef4b6f4a0f6f23a5e362d6337c581ed8f5dd4192f /config.mak.uname
parentc444bf8cb6a881f4c249e904a12e201dae40b7d2 (diff)
msvc: support building Git using MS Visual C++
With this patch, Git can be built using the Microsoft toolchain, via: make MSVC=1 [DEBUG=1] Third party libraries are built from source using the open source "vcpkg" tool set. See https://github.com/Microsoft/vcpkg On a first build, the vcpkg tools and the third party libraries are automatically downloaded and built. DLLs for the third party libraries are copied to the top-level (and t/helper) directory to facilitate debugging. See compat/vcbuild/README. A series of .bat files are invoked by the Makefile to find the location of the installed version of Visual Studio and the associated compiler tools (essentially replicating the environment setup performed by a "Developer Command Prompt"). This should find the most recent VS2015 or VS2017 installation. Output from these scripts are used by the Makefile to define compiler and linker pathnames and -I and -L arguments. The build produces .pdb files for both debug and release builds. Note: This commit was squashed from an organic series of commits developed between 2016 and 2018 in Git for Windows' `master` branch. This combined commit eliminates the obsolete commits related to fetching NuGet packages for third party libraries. It is difficult to use NuGet packages for C/C++ sources because they may be built by earlier versions of the MSVC compiler and have CRT version and linking issues. Additionally, the C/C++ NuGet packages that we were using tended to not be updated concurrently with the sources. And in the case of cURL and OpenSSL, this could expose us to security issues. Helped-by: Yue Lin Ho <b8732003@student.nsysu.edu.tw> Helped-by: Philip Oakley <philipoakley@iee.org> Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.mak.uname')
-rw-r--r--config.mak.uname72
1 files changed, 62 insertions, 10 deletions
diff --git a/config.mak.uname b/config.mak.uname
index 473613a20d..b8c52e49d2 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -1,5 +1,9 @@
# Platform specific Makefile tweaks based on uname detection
+# Define NO_SAFESEH if you need MSVC/Visual Studio to ignore the lack of
+# Microsoft's Safe Exception Handling in libraries (such as zlib).
+# Typically required for VS2013+/32-bit compilation on Vista+ versions.
+
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
@@ -11,6 +15,19 @@ ifdef MSVC
# avoid the MingW and Cygwin configuration sections
uname_S := Windows
uname_O := Windows
+
+ # Generate and include makefile variables that point to the
+ # currently installed set of MSVC command line tools.
+compat/vcbuild/MSVC-DEFS-GEN: compat/vcbuild/find_vs_env.bat
+ @"$<" | tr '\\' / >"$@"
+include compat/vcbuild/MSVC-DEFS-GEN
+
+ # See if vcpkg and the vcpkg-build versions of the third-party
+ # libraries that we use are installed. We include the result
+ # to get $(vcpkg_*) variables defined for the Makefile.
+compat/vcbuild/VCPKG-DEFS: compat/vcbuild/vcpkg_install.bat
+ @"$<"
+include compat/vcbuild/VCPKG-DEFS
endif
# We choose to avoid "if .. else if .. else .. endif endif"
@@ -356,6 +373,19 @@ endif
ifeq ($(uname_S),Windows)
GIT_VERSION := $(GIT_VERSION).MSVC
pathsep = ;
+ # Assume that this is built in Git for Windows' SDK
+ ifeq (MINGW32,$(MSYSTEM))
+ prefix = /mingw32
+ else
+ prefix = /mingw64
+ endif
+ # Prepend MSVC 64-bit tool-chain to PATH.
+ #
+ # A regular Git Bash *does not* have cl.exe in its $PATH. As there is a
+ # link.exe next to, and required by, cl.exe, we have to prepend this
+ # onto the existing $PATH.
+ #
+ SANE_TOOL_PATH ?= $(msvc_bin_dir_msys)
HAVE_ALLOCA_H = YesPlease
NO_PREAD = YesPlease
NEEDS_CRYPTO_WITH_SSL = YesPlease
@@ -368,11 +398,14 @@ ifeq ($(uname_S),Windows)
NO_STRCASESTR = YesPlease
NO_STRLCPY = YesPlease
NO_MEMMEM = YesPlease
- # NEEDS_LIBICONV = YesPlease
- NO_ICONV = YesPlease
+ NEEDS_LIBICONV = YesPlease
NO_STRTOUMAX = YesPlease
NO_MKDTEMP = YesPlease
- SNPRINTF_RETURNS_BOGUS = YesPlease
+ NO_INTTYPES_H = YesPlease
+ # VS2015 with UCRT claims that snprintf and friends are C99 compliant,
+ # so we don't need this:
+ #
+ # SNPRINTF_RETURNS_BOGUS = YesPlease
NO_SVN_TESTS = YesPlease
RUNTIME_PREFIX = YesPlease
HAVE_WPGMPTR = YesWeDo
@@ -385,7 +418,6 @@ ifeq ($(uname_S),Windows)
NO_REGEX = YesPlease
NO_GETTEXT = YesPlease
NO_PYTHON = YesPlease
- BLK_SHA1 = YesPlease
ETAGS_TARGET = ETAGS
NO_POSIX_GOODIES = UnfortunatelyYes
NATIVE_CRLF = YesPlease
@@ -394,24 +426,44 @@ ifeq ($(uname_S),Windows)
CC = compat/vcbuild/scripts/clink.pl
AR = compat/vcbuild/scripts/lib.pl
CFLAGS =
- BASIC_CFLAGS = -nologo -I. -I../zlib -Icompat/vcbuild -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
+ BASIC_CFLAGS = -nologo -I. -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
COMPAT_OBJS = compat/msvc.o compat/winansi.o \
compat/win32/path-utils.o \
compat/win32/pthread.o compat/win32/syslog.o \
compat/win32/trace2_win32_process_info.o \
compat/win32/dirent.o
- COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
+ COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -ENTRY:wmainCRTStartup -SUBSYSTEM:CONSOLE
- EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj
+ # invalidcontinue.obj allows Git's source code to close the same file
+ # handle twice, or to access the osfhandle of an already-closed stdout
+ # See https://msdn.microsoft.com/en-us/library/ms235330.aspx
+ EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj kernel32.lib ntdll.lib
PTHREAD_LIBS =
lib =
+ BASIC_CFLAGS += $(vcpkg_inc) $(sdk_includes) $(msvc_includes)
+ifndef DEBUG
+ BASIC_CFLAGS += $(vcpkg_rel_lib)
+else
+ BASIC_CFLAGS += $(vcpkg_dbg_lib)
+endif
+ BASIC_CFLAGS += $(sdk_libs) $(msvc_libs)
+
BASIC_CFLAGS += -DPROTECT_NTFS_DEFAULT=1
+ # Always give "-Zi" to the compiler and "-debug" to linker (even in
+ # release mode) to force a PDB to be generated (like RelWithDebInfo).
+ BASIC_CFLAGS += -Zi
+ BASIC_LDFLAGS += -debug -Zf
+
+ifdef NO_SAFESEH
+ LDFLAGS += -SAFESEH:NO
+endif
+
ifndef DEBUG
- BASIC_CFLAGS += -GL -Os -MD
- BASIC_LDFLAGS += -LTCG
+ BASIC_CFLAGS += -GL -Gy -O2 -Oy- -MD -DNDEBUG
+ BASIC_LDFLAGS += -release -LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:CV,FIXUP
AR += -LTCG
else
- BASIC_CFLAGS += -Zi -MDd
+ BASIC_CFLAGS += -MDd -DDEBUG -D_DEBUG
endif
X = .exe