diff options
author | Daniel Dragan <bulk88@hotmail.com> | 2018-07-27 16:44:26 -0400 |
---|---|---|
committer | Steve Hay <steve.m.hay@googlemail.com> | 2018-07-30 08:19:59 +0100 |
commit | b2029bebc5407a6527c355dec9c3e96aef8df9fc (patch) | |
tree | 541fa0830552ecb4546154d418d822f14ad2dffb /win32/GNUmakefile | |
parent | eedb5413d38c92327bdf70ff2594f164f2610d0c (diff) | |
download | perl-b2029bebc5407a6527c355dec9c3e96aef8df9fc.tar.gz |
fix version autodetect for Visual C 64bit edition
-replace *= with := in makefile.mk because we dont want to run
"gcc.exe -dumpmachine" multiple times
-64 bit Visual C has the major version number at 1 "token" less than
32 bit edition, so the autodetect code was saying VC 2005 64b was
CCTYPE="MSVC-60" because shell var %i was "00" in the "set /A", VC 2005
32b wasn't affected, MS when they created 64 bit VC took some liberties
in changing the version string, rumor has it many legacy code bases do a
string test for "80x86", so that is why it was never updated by MS. I
think detecting 64b VC version numbers has been broken since day 1 of
the autodetect code that I wrote in commit ca30c090c3 . I just never
tested it on 64b before.
-copy the "info" target from GNUMakefile to makefile.mk for debugging
reasons, mostly so I can verify this revised autodetect logic works but
since the target uses alot of CPU/IO/many procs launched to compute the
version and many cmd.exes are launched for all those echo line, dont by
default execute the "info" target from "all" target on dmake makefile.mk
to save build time. Copying "info" target also reduces diff-ness between
the 2 makefiles. Maybe one day remove running the info target by dafault
on a target "all" from GNUmakefile too, but not in this commit.
-consolidate the recipe lines for "info" target so less cmd.exe procs are
launched by the make tools, unroll echo CCTYPE into both branches. For
me with dmake, the "info" targets execution time went from 398ms to 141 ms
-there was a skip of "VC" version vs "cl.exe" version between VC 2013 aka
VC 12 and VC 2015 aka VC 14, so at cl.exe ver 19 the skip must be
accounted for, also starting in VC 2017, the MINOR version number started
being relevent since MS stopped ticking up the MAJOR version number so
take the "X" from AB.XY.CD.EF and append it to the version number, the 2nd
number in "tokens" sets %j var to be that number, but dont look at minor
number for older VCs since the only old "AB.10" VC compiler, which is
VC 2003 aka 7.10 and VC 2002 aka 7.00 are treated identically and combined
to 7.00 for perl purposes
-fixed a bug that a console without gcc and without vc in the PATH
autodetected to a gibberish MSVC version instead of erroring to the user
Diffstat (limited to 'win32/GNUmakefile')
-rw-r--r-- | win32/GNUmakefile | 56 |
1 files changed, 41 insertions, 15 deletions
diff --git a/win32/GNUmakefile b/win32/GNUmakefile index 7429b86451..a016a391d2 100644 --- a/win32/GNUmakefile +++ b/win32/GNUmakefile @@ -354,12 +354,32 @@ GCCTARGET := $(shell $(GCCBIN) -dumpmachine 2>NUL) ifneq ($(GCCTARGET),) CCTYPE := GCC else +WIN64 := $(shell for /f "tokens=3 delims=.^ " \ + %%i in ('cl ^2^>^&1') do @if "%%i" == "32-bit" echo undef) +#major version of CL has diff position based on 32 vs 64 +#Microsoft (R) C/C++ Optimizing Compiler Version 15.00.30729.01 for x64 +#Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86 #use var to capture 1st line only, not 8th token of lines 2 & 3 in cl.exe output -#rmving the cmd /c causes the var2b undef4echo but!4"set MSVCVER", cmd.exe bug? -MSVCVER := $(shell (set MSVCVER=) & (for /f "tokens=8 delims=.^ " \ - %%i in ('cl ^2^>^&1') do if not defined MSVCVER set /A "MSVCVER=%%i-6") \ - & cmd /c echo %%MSVCVER%%) -CCTYPE := MSVC$(MSVCVER)0 +#removing the cmd /c (extra scope) on the echo causes the env var to be undef +#when echo executes but it isn't undef for the "set MSVCVER", gmake or +#cmd.exe bug? +ifeq ($(WIN64),undef) +MSVCVER := $(shell (set MSVCVER=) & (for /f "tokens=8,9 delims=.^ " \ + %%i in ('cl ^2^>^&1') do if not defined MSVCVER if %%i%% geq 19 \ + (set /A "MSVCVER=((%%i-5)*10)+(%%j/10)") \ + else (set /A "MSVCVER=(%%i-6)*10")) & cmd /c echo %%MSVCVER%%) +else +MSVCVER := $(shell (set MSVCVER=) & (for /f "tokens=7,8 delims=.^ " \ + %%i in ('cl ^2^>^&1') do if not defined MSVCVER if %%i%% geq 19 \ + (set /A "MSVCVER=((%%i-5)*10)+(%%j/10)") \ + else (set /A "MSVCVER=(%%i-6)*10")) & cmd /c echo %%MSVCVER%%) +endif +#autodetect failed, reset to empty string +ifeq ($(MSVCVER),-50) +CCTYPE := +else +CCTYPE := MSVC$(MSVCVER) +endif endif endif @@ -1179,17 +1199,23 @@ CFG_VARS = \ all : info rebasePE Extensions_nonxs $(PERLSTATIC) PostExt info : - @echo # CCTYPE=$(CCTYPE) ifeq ($(CCTYPE),GCC) - @echo # GCCBIN=$(GCCBIN) - @echo # GCCVER=$(GCCVER1).$(GCCVER2).$(GCCVER3) - @echo # GCCTARGET=$(GCCTARGET) - @echo # GCCCROSS=$(GCCCROSS) -endif - @echo # WIN64=$(WIN64) - @echo # ARCHITECTURE=$(ARCHITECTURE) - @echo # ARCHNAME=$(ARCHNAME) - @echo # MAKE=$(PLMAKE) + @echo # CCTYPE=$(CCTYPE)&& \ + echo # GCCBIN=$(GCCBIN)&& \ + echo # GCCVER=$(GCCVER1).$(GCCVER2).$(GCCVER3)&& \ + echo # GCCTARGET=$(GCCTARGET)&& \ + echo # GCCCROSS=$(GCCCROSS)&& \ + echo # WIN64=$(WIN64)&& \ + echo # ARCHITECTURE=$(ARCHITECTURE)&& \ + echo # ARCHNAME=$(ARCHNAME)&& \ + echo # MAKE=$(PLMAKE) +else + @echo # CCTYPE=$(CCTYPE)&& \ + echo # WIN64=$(WIN64)&& \ + echo # ARCHITECTURE=$(ARCHITECTURE)&& \ + echo # ARCHNAME=$(ARCHNAME)&& \ + echo # MAKE=$(PLMAKE) +endif ifeq ($(CCTYPE),) @echo Unable to detect gcc and/or architecture! @exit 1 |