0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 9.1.0656: MS-Windows: MSVC Makefile CPU handling can be improved

Problem:  MS-Windows: MSVC Makefile CPU handling can be improved
Solution: Update Makefile and also remove some old code
          (Ken Takata)

* The variable `ASSEMBLY_ARCHITECTURE` was originally used to generate
  the manifest file. However, this was removed in v7.0.198.  Remove
  `ASSEMBLY_ARCHITECTURE` and use `CPU` instead.
* `/arch:AVX512` is available starting from Visual C++ 2017.
* ARM64 was not considered when validating CPUNR.
  Skip the validation for ARM64 for now.
* Remove old code for VC6/7 and Win9x.

closes: #15422

Signed-off-by: Ken Takata <kentkt@csc.jp>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Ken Takata 2024-08-03 14:34:33 +02:00 committed by Christian Brabandt
parent 0aa65b48fb
commit cdf1c7a73a
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
3 changed files with 75 additions and 67 deletions

View File

@ -19,25 +19,24 @@ WINVER = 0x0601
NODEBUG = 1 NODEBUG = 1
!endif !endif
!ifdef PROCESSOR_ARCHITECTURE !ifndef CPU
# On Windows NT
! ifndef CPU
CPU = i386 CPU = i386
! if !defined(PLATFORM) && defined(TARGET_CPU) ! ifndef PLATFORM
! ifdef TARGET_CPU
PLATFORM = $(TARGET_CPU) PLATFORM = $(TARGET_CPU)
! endif ! elseif defined(VSCMD_ARG_TGT_ARCH)
! ifdef PLATFORM PLATFORM = $(VSCMD_ARG_TGT_ARCH)
! if ("$(PLATFORM)" == "x64") || ("$(PLATFORM)" == "X64") ! endif
CPU = AMD64 ! endif
! elseif ("$(PLATFORM)" == "arm64") || ("$(PLATFORM)" == "ARM64") ! ifdef PLATFORM
CPU = ARM64 ! if ("$(PLATFORM)" == "x64") || ("$(PLATFORM)" == "X64")
! elseif ("$(PLATFORM)" != "x86") && ("$(PLATFORM)" != "X86") CPU = AMD64
! error *** ERROR Unknown target platform "$(PLATFORM)". Make aborted. ! elseif ("$(PLATFORM)" == "arm64") || ("$(PLATFORM)" == "ARM64")
! endif CPU = ARM64
! elseif ("$(PLATFORM)" != "x86") && ("$(PLATFORM)" != "X86")
! error *** ERROR Unknown target platform "$(PLATFORM)". Make aborted.
! endif ! endif
! endif ! endif
!else
CPU = i386
!endif !endif
!ifdef SDK_INCLUDE_DIR !ifdef SDK_INCLUDE_DIR
@ -80,7 +79,6 @@ all: gvimext.dll
gvimext.dll: gvimext.obj \ gvimext.dll: gvimext.obj \
gvimext.res gvimext.res
$(link) $(lflags) -dll -def:gvimext.def -base:$(OFFSET) -out:$*.dll $** $(olelibsdll) shell32.lib comctl32.lib -subsystem:$(SUBSYSTEM) $(link) $(lflags) -dll -def:gvimext.def -base:$(OFFSET) -out:$*.dll $** $(olelibsdll) shell32.lib comctl32.lib -subsystem:$(SUBSYSTEM)
if exist $*.dll.manifest mt -nologo -manifest $*.dll.manifest -outputresource:$*.dll;2
gvimext.obj: gvimext.h gvimext.obj: gvimext.h
@ -96,4 +94,3 @@ clean:
- if exist gvimext.exp del gvimext.exp - if exist gvimext.exp del gvimext.exp
- if exist gvimext.obj del gvimext.obj - if exist gvimext.obj del gvimext.obj
- if exist gvimext.res del gvimext.res - if exist gvimext.res del gvimext.res
- if exist gvimext.dll.manifest del gvimext.dll.manifest

View File

@ -127,10 +127,15 @@
# #
# Optimization: OPTIMIZE=[SPACE, SPEED, MAXSPEED] (default is MAXSPEED) # Optimization: OPTIMIZE=[SPACE, SPEED, MAXSPEED] (default is MAXSPEED)
# #
# Processor Version: CPUNR=[any, i686, sse, sse2, avx, avx2] (default is # Processor Version:
# sse2) # For x86: CPUNR=[any, i686, sse, sse2, avx, avx2, avx512]
# For x64: CPUNR=[sse2, avx, avx2, avx512]
# (default is sse2 (both x86 and x64))
# avx is available on Visual C++ 2010 and after. # avx is available on Visual C++ 2010 and after.
# avx2 is available on Visual C++ 2013 Update 2 and after. # avx2 is available on Visual C++ 2013 Update 2 and after.
# avx512 is available on Visual C++ 2017 and after.
# For ARM64:
# See: https://learn.microsoft.com/en-us/cpp/build/reference/arch-arm64
# #
# Version Support: WINVER=[0x0601, 0x0602, 0x0603, 0x0A00] (default is # Version Support: WINVER=[0x0601, 0x0602, 0x0603, 0x0A00] (default is
# 0x0601) # 0x0601)
@ -257,38 +262,29 @@ OBJDIR = $(OBJDIR)V
OBJDIR = $(OBJDIR)d OBJDIR = $(OBJDIR)d
!endif !endif
!ifdef PROCESSOR_ARCHITECTURE !ifdef CPU
# We're on Windows NT or using VC 6+ ! if "$(CPU)" == "I386"
! ifdef CPU
ASSEMBLY_ARCHITECTURE = $(CPU)
# Using I386 for $ASSEMBLY_ARCHITECTURE doesn't work for VC7.
! if "$(CPU)" == "I386"
CPU = i386 CPU = i386
! endif
! else # !CPU
CPU = i386
! ifndef PLATFORM
! ifdef TARGET_CPU
PLATFORM = $(TARGET_CPU)
! elseif defined(VSCMD_ARG_TGT_ARCH)
PLATFORM = $(VSCMD_ARG_TGT_ARCH)
! endif
! endif
! ifdef PLATFORM
! if ("$(PLATFORM)" == "x64") || ("$(PLATFORM)" == "X64")
CPU = AMD64
! elseif ("$(PLATFORM)" == "arm64") || ("$(PLATFORM)" == "ARM64")
CPU = ARM64
! elseif ("$(PLATFORM)" != "x86") && ("$(PLATFORM)" != "X86")
! error *** ERROR Unknown target platform "$(PLATFORM)". Make aborted.
! endif
! endif # !PLATFORM
! endif ! endif
!else # !PROCESSOR_ARCHITECTURE !else # !CPU
# We're on Windows 95
CPU = i386 CPU = i386
!endif # !PROCESSOR_ARCHITECTURE ! ifndef PLATFORM
ASSEMBLY_ARCHITECTURE = $(CPU) ! ifdef TARGET_CPU
PLATFORM = $(TARGET_CPU)
! elseif defined(VSCMD_ARG_TGT_ARCH)
PLATFORM = $(VSCMD_ARG_TGT_ARCH)
! endif
! endif
! ifdef PLATFORM
! if ("$(PLATFORM)" == "x64") || ("$(PLATFORM)" == "X64")
CPU = AMD64
! elseif ("$(PLATFORM)" == "arm64") || ("$(PLATFORM)" == "ARM64")
CPU = ARM64
! elseif ("$(PLATFORM)" != "x86") && ("$(PLATFORM)" != "X86")
! error *** ERROR Unknown target platform "$(PLATFORM)". Make aborted.
! endif
! endif # !PLATFORM
!endif
OBJDIR = $(OBJDIR)$(CPU) OBJDIR = $(OBJDIR)$(CPU)
# Build a retail version by default # Build a retail version by default
@ -553,40 +549,53 @@ INTDIR = $(OBJDIR)
OUTDIR = $(OBJDIR) OUTDIR = $(OBJDIR)
### Validate CPUNR ### Validate CPUNR
!ifndef CPUNR !if "$(CPU)" == "i386" || "$(CPU)" == "AMD64"
! ifndef CPUNR
# default to SSE2 # default to SSE2
CPUNR = sse2 CPUNR = sse2
!elseif "$(CPUNR)" == "i386" || "$(CPUNR)" == "i486" || "$(CPUNR)" == "i586" ! elseif "$(CPU)" == "i386" \
&& ("$(CPUNR)" == "i386" || "$(CPUNR)" == "i486" || "$(CPUNR)" == "i586")
# alias i386, i486 and i586 to i686 # alias i386, i486 and i586 to i686
! message *** WARNING CPUNR=$(CPUNR) is not a valid target architecture. ! message *** WARNING CPUNR=$(CPUNR) is not a valid target architecture.
! message Windows 7 is the minimum target OS, with a minimum target ! message Windows 7 is the minimum target OS, with a minimum target
! message architecture of i686. ! message architecture of i686.
! message Retargeting to i686 ! message Retargeting to i686
CPUNR = i686 CPUNR = i686
!elseif "$(CPUNR)" == "pentium4" ! elseif "$(CPUNR)" == "pentium4"
# alias pentium4 to sse2 # alias pentium4 to sse2
! message *** WARNING CPUNR=pentium4 is deprecated in favour of sse2. ! message *** WARNING CPUNR=pentium4 is deprecated in favour of sse2.
! message Retargeting to sse2. ! message Retargeting to sse2.
CPUNR = sse2 CPUNR = sse2
!elseif "$(CPUNR)" != "any" && "$(CPUNR)" != "i686" \ ! elseif ("$(CPU)" != "i386" \
&& "$(CPUNR)" != "sse" && "$(CPUNR)" != "sse2" \ || ("$(CPUNR)" != "any" && "$(CPUNR)" != "i686" \
&& "$(CPUNR)" != "avx" && "$(CPUNR)" != "avx2" && "$(CPUNR)" != "sse" )) \
! error *** ERROR Unknown target architecture "$(CPUNR)". Make aborted. && "$(CPUNR)" != "sse2" && "$(CPUNR)" != "avx" \
&& "$(CPUNR)" != "avx2" && "$(CPUNR)" != "avx512"
! error *** ERROR Unknown target architecture "$(CPUNR)". Make aborted.
! endif
!elseif "$(CPU)" == "ARM64"
# TODO: Validate CPUNR.
!endif !endif
# Convert processor ID to MVC-compatible number # Convert processor ID to MVC-compatible number
!if "$(CPU)" == "i386" || "$(CPU)" == "AMD64"
# IA32/SSE/SSE2 are only supported on x86 # IA32/SSE/SSE2 are only supported on x86
!if "$(ASSEMBLY_ARCHITECTURE)" == "i386" \ ! if "$(CPU)" == "i386" \
&& ("$(CPUNR)" == "i686" || "$(CPUNR)" == "any") && ("$(CPUNR)" == "i686" || "$(CPUNR)" == "any")
CPUARG = /arch:IA32 CPUARG = /arch:IA32
!elseif "$(ASSEMBLY_ARCHITECTURE)" == "i386" && "$(CPUNR)" == "sse" ! elseif "$(CPU)" == "i386" && "$(CPUNR)" == "sse"
CPUARG = /arch:SSE CPUARG = /arch:SSE
!elseif "$(ASSEMBLY_ARCHITECTURE)" == "i386" && "$(CPUNR)" == "sse2" ! elseif "$(CPU)" == "i386" && "$(CPUNR)" == "sse2"
CPUARG = /arch:SSE2 CPUARG = /arch:SSE2
!elseif "$(CPUNR)" == "avx" ! elseif "$(CPUNR)" == "avx"
CPUARG = /arch:AVX CPUARG = /arch:AVX
!elseif "$(CPUNR)" == "avx2" ! elseif "$(CPUNR)" == "avx2"
CPUARG = /arch:AVX2 CPUARG = /arch:AVX2
! elseif "$(CPUNR)" == "avx512"
CPUARG = /arch:AVX512
! endif
!elseif "$(CPU)" == "ARM64" && defined(CPUNR)
CPUARG = /arch:$(CPUNR)
!endif !endif
# Pass CPUARG to GvimExt, to avoid using version-dependent defaults # Pass CPUARG to GvimExt, to avoid using version-dependent defaults
@ -594,7 +603,7 @@ MAKEFLAGS_GVIMEXT = $(MAKEFLAGS_GVIMEXT) CPUARG="$(CPUARG)"
!if "$(VIMDLL)" == "yes" !if "$(VIMDLL)" == "yes"
VIMDLLBASE = vim VIMDLLBASE = vim
! if "$(ASSEMBLY_ARCHITECTURE)" == "i386" ! if "$(CPU)" == "i386"
VIMDLLBASE = $(VIMDLLBASE)32 VIMDLLBASE = $(VIMDLLBASE)32
! else ! else
VIMDLLBASE = $(VIMDLLBASE)64 VIMDLLBASE = $(VIMDLLBASE)64

View File

@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
656,
/**/ /**/
655, 655,
/**/ /**/