changeset 11510:deb9295dccda v8.0.0638

patch 8.0.0638: cannot build with new MSVC version commit https://github.com/vim/vim/commit/d7383881c8e9f474a909b54b21abb0aa2b412ba2 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jun 13 15:22:12 2017 +0200 patch 8.0.0638: cannot build with new MSVC version Problem: Cannot build with new MSVC version VS2017. Solution: Change the compiler arguments. (Leonardo Manera, closes https://github.com/vim/vim/issues/1731, closes #1747)
author Christian Brabandt <cb@256bit.org>
date Tue, 13 Jun 2017 15:30:03 +0200
parents 408e0db898d9
children d0ec98a59c07
files src/GvimExt/Makefile src/Make_mvc.mak src/version.c
diffstat 3 files changed, 119 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/GvimExt/Makefile
+++ b/src/GvimExt/Makefile
@@ -1,11 +1,14 @@
 # Makefile for GvimExt, using MSVC
 # Options:
 #   DEBUG=yes		Build debug version (for VC7 and maybe later)
+#   CPUARG=		/arch:IA32/AVX/etc, call from main makefile to set
+#   			automatically from CPUNR
 #
 
-TARGETOS=WINNT
+TARGETOS = WINNT
+
 !ifndef APPVER
-APPVER=5.0
+APPVER = 5.01
 !endif
 
 !if "$(DEBUG)" != "yes"
@@ -37,6 +40,9 @@ CPU = i386
 !include <Win32.mak>
 !endif
 
+# include CPUARG
+cflags = $(cflags) $(CPUARG)
+
 all: gvimext.dll
 
 gvimext.dll:    gvimext.obj	\
--- a/src/Make_mvc.mak
+++ b/src/Make_mvc.mak
@@ -1,7 +1,7 @@
 # Makefile for Vim on Win32 (Windows XP/2003/Vista/7/8/10) and Win64,
 # using the Microsoft Visual C++ compilers. Known to work with VC5, VC6 (VS98),
 # VC7.0 (VS2002), VC7.1 (VS2003), VC8 (VS2005), VC9 (VS2008), VC10 (VS2010),
-# VC11 (VS2012), VC12 (VS2013) and VC14 (VS2015)
+# VC11 (VS2012), VC12 (VS2013), VC14 (VS2015) and VC15 (VS2017)
 #
 # To build using other Windows compilers, see INSTALLpc.txt
 #
@@ -108,10 +108,15 @@
 #
 #	Optimization: OPTIMIZE=[SPACE, SPEED, MAXSPEED] (default is MAXSPEED)
 #
-#	Processor Version: CPUNR=[i386, i486, i586, i686, pentium4] (default is
-#	i386)
+#	Processor Version: CPUNR=[any, i586, i686, sse, sse2, avx, avx2] (default is
+#	any)
+#	  avx is available on Visual C++ 2010 and after.
+#	  avx2 is available on Visual C++ 2013 Update 2 and after.
 #
-#	Version Support: WINVER=[0x0501, 0x0600] (default is 0x0501)
+#	Version Support: WINVER=[0x0501, 0x0502, 0x0600, 0x0601, 0x0602,
+#	0x0603, 0x0A00] (default is 0x0501)
+#	Supported versions depends on your target SDK, check SDKDDKVer.h
+#	See https://docs.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt
 #
 #	Debug version: DEBUG=yes
 #	Mapfile: MAP=[no, yes or lines] (default is yes)
@@ -270,11 +275,31 @@ MAKEFLAGS_GVIMEXT = DEBUG=yes
 !if $(MSVCVER) < 1900
 MSVC_MAJOR = ($(MSVCVER) / 100 - 6)
 MSVCRT_VER = ($(MSVCVER) / 10 - 60)
+# Visual C++ 2017 needs special handling
+# it has an _MSC_VER of 1910->14.1, but is actually v15 with runtime v140
+!elseif $(MSVCVER) == 1910
+MSVC_MAJOR = 15
+MSVCRT_VER = 140
 !else
 MSVC_MAJOR = ($(MSVCVER) / 100 - 5)
 MSVCRT_VER = ($(MSVCVER) / 10 - 50)
 !endif
 
+# Calculate MSVC_FULL for Visual C++ 8 and up.
+!if $(MSVC_MAJOR) >= 8
+! if [echo MSVC_FULL=_MSC_FULL_VER> msvcfullver.c && $(CC) /EP msvcfullver.c > msvcfullver.~ 2> nul]
+!  message *** ERROR
+!  message Cannot run Visual C to determine its version. Make sure cl.exe is in your PATH.
+!  message This can usually be done by running "vcvarsall.bat", located in the bin directory where Visual Studio was installed.
+!  error Make aborted.
+! else
+!  include msvcfullver.~
+!  if [del msvcfullver.c msvcfullver.~]
+!  endif
+! endif
+!endif
+
+
 # Calculate MSVCRT_VER
 !if [(set /a MSVCRT_VER="$(MSVCRT_VER)" > nul) && set MSVCRT_VER > msvcrtver.~] == 0
 !include msvcrtver.~
@@ -446,27 +471,95 @@ DEL_TREE = rmdir /s /q
 INTDIR=$(OBJDIR)
 OUTDIR=$(OBJDIR)
 
+### Validate CPUNR
+!ifndef CPUNR
+# default to untargeted code
+CPUNR = any
+!elseif "$(CPUNR)" == "i386" || "$(CPUNR)" == "i486"
+# alias i386 and i486 to i586
+! message *** WARNING CPUNR=$(CPUNR) is not a valid target architecture.
+! message Windows XP is the minimum target OS, with a minimum target
+! message architecture of i586.
+! message Retargeting to i586
+CPUNR = i586
+!elseif "$(CPUNR)" == "pentium4"
+# alias pentium4 to sse2
+! message *** WARNING CPUNR=pentium4 is deprecated in favour of sse2.
+! message Retargeting to sse2.
+CPUNR = sse2
+!elseif "$(CPUNR)" != "any" && "$(CPUNR)" != "i586" && "$(CPUNR)" != "i686" && "$(CPUNR)" != "sse" && "$(CPUNR)" != "sse2" && "$(CPUNR)" != "avx" && "$(CPUNR)" != "avx2"
+! error *** ERROR Unknown target architecture "$(CPUNR)". Make aborted.
+!endif
+
 # Convert processor ID to MVC-compatible number
 !if $(MSVC_MAJOR) < 8
-!if "$(CPUNR)" == "i386"
-CPUARG = /G3
-!elseif "$(CPUNR)" == "i486"
-CPUARG = /G4
-!elseif "$(CPUNR)" == "i586"
+! if "$(CPUNR)" == "i586"
 CPUARG = /G5
-!elseif "$(CPUNR)" == "i686"
+! elseif "$(CPUNR)" == "i686"
 CPUARG = /G6
-!elseif "$(CPUNR)" == "pentium4"
+! elseif "$(CPUNR)" == "sse"
+CPUARG = /G6 /arch:SSE
+! elseif "$(CPUNR)" == "sse2"
+CPUARG = /G7 /arch:SSE2
+! elseif "$(CPUNR)" == "avx" || "$(CPUNR)" == "avx2"
+!  message AVX/AVX2 Instruction Sets are not supported by Visual C++ v$(MSVC_MAJOR)
+!  message Falling back to SSE2
 CPUARG = /G7 /arch:SSE2
-!else
+! elseif "$(CPUNR)" == "any"
 CPUARG =
-!endif
+! endif
 !else
-# VC8/9/10 only allows specifying SSE architecture but only for 32bit
-!if "$(ASSEMBLY_ARCHITECTURE)" == "i386" && "$(CPUNR)" == "pentium4"
+# IA32/SSE/SSE2 are only supported on x86
+! if "$(ASSEMBLY_ARCHITECTURE)" == "i386" && ("$(CPUNR)" == "i586" || "$(CPUNR)" == "i686" || "$(CPUNR)" == "any")
+# VC<11 generates fp87 code by default
+!  if $(MSVC_MAJOR) < 11
+CPUARG =
+# VC>=11 needs explicit insturctions to generate fp87 code
+!  else
+CPUARG = /arch:IA32
+!  endif
+! elseif "$(ASSEMBLY_ARCHITECTURE)" == "i386" && "$(CPUNR)" == "sse"
+CPUARG = /arch:SSE
+! elseif "$(ASSEMBLY_ARCHITECTURE)" == "i386" && "$(CPUNR)" == "sse2"
+CPUARG = /arch:SSE2
+! elseif "$(CPUNR)" == "avx"
+# AVX is only supported by VC 10 and up
+!  if $(MSVC_MAJOR) < 10
+!   message AVX Instruction Set is not supported by Visual C++ v$(MSVC_MAJOR)
+!   if "$(ASSEMBLY_ARCHITECTURE)" == "i386"
+!    message Falling back to SSE2
 CPUARG = /arch:SSE2
+!   else
+CPUARG =
+!   endif
+!  else
+CPUARG = /arch:AVX
+!  endif
+! elseif "$(CPUNR)" == "avx2"
+# AVX is only supported by VC 10 and up
+!  if $(MSVC_MAJOR) < 10
+!   message AVX2 Instruction Set is not supported by Visual C++ v$(MSVC_MAJOR)
+!   if "$(ASSEMBLY_ARCHITECTURE)" == "i386"
+!    message Falling back to SSE2
+CPUARG = /arch:SSE2
+!   else
+CPUARG =
+!   endif
+# AVX2 is only supported by VC 12U2 and up
+# 180030501 is the full version number for Visual Studio 2013/VC 12 Update 2
+!  elseif $(MSVC_FULL) < 180030501
+!   message AVX2 Instruction Set is not supported by Visual C++ v$(MSVC_MAJOR)-$(MSVC_FULL)
+!   message Falling back to AVX
+CPUARG = /arch:AVX
+!  else
+CPUARG = /arch:AVX2
+!  endif
+! endif
 !endif
-!endif
+
+# Pass CPUARG to GVimExt, to avoid using version-dependent defaults
+MAKEFLAGS_GVIMEXT = $(MAKEFLAGS_GVIMEXT) CPUARG="$(CPUARG)"
+
 
 LIBC =
 DEBUGINFO = /Zi
--- a/src/version.c
+++ b/src/version.c
@@ -765,6 +765,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    638,
+/**/
     637,
 /**/
     636,