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

[PATCH] fix version autodetect for Visual C 64bit edition #16509

Closed
p5pRT opened this issue Apr 16, 2018 · 27 comments
Closed

[PATCH] fix version autodetect for Visual C 64bit edition #16509

p5pRT opened this issue Apr 16, 2018 · 27 comments

Comments

@p5pRT
Copy link

@p5pRT p5pRT commented Apr 16, 2018

Migrated from rt.perl.org#133117 (status was 'resolved')

Searchable as RT133117$

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Apr 16, 2018

From @bulk88

Created by @bulk88

I'll put the patch up separate bc spam filter. This is intended for
5.28. Maybe backport too. Maybe
needs a perldelta entry too. 6th attempt to send bc spam filter.

Perl Info
---
Flags:
                    category=core
                    severity=low
---
Site configuration information for perl 5.27.9:

Configured by Administrator at Tue Jan 30 20:34:30 2018.

Summary of my perl5 (revision 5 version 27 subversion 9) configuration:

                  Platform:
                    osname=MSWin32
                    osvers=5.2.3790
                    archname=MSWin32-x86-multi-thread
                    uname=''
                    config_args='undef'
                    hint=recommended
                    useposix=true
                    d_sigaction=undef
                    useithreads=define
                    usemultiplicity=define
                    use64bitint=undef
                    use64bitall=undef
                    uselongdouble=undef
                    usemymalloc=n
                    default_inc_excludes_dot=define
                    bincompat5005=undef
                  Compiler:
                    cc='cl'
                    ccflags ='-nologo -GF -W3 -O1 -MD -Zi -DNDEBUG -GL
-DWIN32
-D_CONSOLE -DNO_STRICT -D_CRT_SECURE_NO_DEPRECATE
-D_CRT_NONSTDC_NO_DEPRECATE  -DPERL_TEXTMODE_SCRIPTS
-DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DWIN32_NO_REGISTRY'
                    optimize='-O1 -MD -Zi -DNDEBUG -GL'
                    cppflags='-DWIN32'
                    ccversion='15.00.30729.01'
                    gccversion=''
                    gccosandvers=''
                    intsize=4
                    longsize=4
                    ptrsize=4
                    doublesize=8
                    byteorder=1234
                    doublekind=3
                    d_longlong=undef
                    longlongsize=8
                    d_longdbl=define
                    longdblsize=8
                    longdblkind=0
                    ivtype='long'
                    ivsize=4
                    nvtype='double'
                    nvsize=8
                    Off_t='__int64'
                    lseeksize=8
                    alignbytes=8
                    prototype=define
                  Linker and Libraries:
                    ld='link'
                    ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf 
-ltcg
-libpath:"c:\perl\lib\CORE"        -machine:x86'
                    libpth="C:\Program Files (x86)\Microsoft Visual Studio
9.0\VC\lib"
                    libs=oldnames.lib kernel32.lib user32.lib gdi32.lib
winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib
netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib
odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
                    perllibs=oldnames.lib kernel32.lib user32.lib gdi32.lib
winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib
netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib
odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
                    libc=msvcrt.lib
                    so=dll
                    useshrplib=true
                    libperl=perl527.lib
                    gnulibc_version=''
                  Dynamic Linking:
                    dlsrc=dl_win32.xs
                    dlext=dll
                    d_dlsymun=undef
                    ccdlflags=' '
                    cccdlflags=' '
                    lddlflags='-dll -nologo -nodefaultlib -debug 
-opt:ref,icf
-ltcg
                    -libpath:"c:\perl\lib\CORE"        -machine:x86'


---
@INC for perl 5.27.9:
                    lib
                    C:/p527/srcnew/lib

---
Environment for perl 5.27.9:
                    CYGWIN=tty
                    HOME (unset)
                    LANG (unset)
                    LANGUAGE (unset)
                    LD_LIBRARY_PATH=/usr/lib/x86:/usr/X11R6/lib
                    LOGDIR (unset)
                    PATH=C:\WINDOWS\system32;C:\Program Files 
(x86)\Microsoft
Visual
Studio 9.0\VC\BIN;C:\Program Files\Microsoft
SDKs\Windows\v6.0A\bin;C:\Perl\bin;C:\WINDOWS;C:\Program Files
(x86)\Microsoft Visual Studio 9.0\Common7\IDE;C:\Program Files
(x86)\Git\bin;C:\sp3220\c\bin;
                    PERL_BADLANG (unset)
                    SHELL (unset)








@p5pRT
Copy link
Author

@p5pRT p5pRT commented Apr 16, 2018

From @bulk88

On Mon, 16 Apr 2018 10​:46​:04 -0700, bulk88 wrote​:

This is a bug report for perl from bulk88@​hotmail.com,
generated with the help of perlbug 1.41 running under perl 5.27.9.

-----------------------------------------------------------------
[Please describe your issue here]
I'll put the patch up separate bc spam filter. This is intended for
5.28. Maybe backport too. Maybe
needs a perldelta entry too. 6th attempt to send bc spam filter.

--
bulk88 ~ bulk88 at hotmail.com

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Apr 16, 2018

From @bulk88

0001-fix-version-autodetect-for-Visual-C-64bit-edition.patch
>From 1d57d348b844ececc5abcece995a1e919a1288e2 Mon Sep 17 00:00:00 2001
From: Daniel Dragan <bulk88@hotmail.com>
Date: Tue, 10 Apr 2018 17:36:19 -0400
Subject: [PATCH] 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 detect 64b VC ver num has been broken since day 1 of the autodetect
 code that I wrote in commit ca30c090c3 . I just nvr tested 64b before.
-copy the info target from GNUMakefile to dmake mkf 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 2 compute ver and many
 cmd.exes launched for all those echo line, dont by default execute info
 target from all target on dmake mkf to save build time. This also reduced
 diff-ness between the 2 mkfs. Maybe one day remove the info target from
 gmake mkf too, but not in this commit.
---
 win32/GNUmakefile | 11 +++++++++++
 win32/makefile.mk | 39 +++++++++++++++++++++++++++++++++++++--
 2 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/win32/GNUmakefile b/win32/GNUmakefile
index 9c89a98..f3695eb 100644
--- a/win32/GNUmakefile
+++ b/win32/GNUmakefile
@@ -348,11 +348,22 @@ 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?
+ifeq ($(WIN64),undef)
 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%%)
+else
+MSVCVER		:= $(shell (set MSVCVER=) & (for /f "tokens=7 delims=.^ " \
+	%%i in ('cl ^2^>^&1') do if not defined MSVCVER set /A "MSVCVER=%%i-6") \
+	& cmd /c echo %%MSVCVER%%)
+endif
 CCTYPE		:= MSVC$(MSVCVER)0
 endif
 endif
diff --git a/win32/makefile.mk b/win32/makefile.mk
index 58cc579..7060988 100644
--- a/win32/makefile.mk
+++ b/win32/makefile.mk
@@ -348,14 +348,24 @@ BUILDOPT	+= -DWIN32_NO_REGISTRY
 
 #no explicit CCTYPE given, do auto detection
 .IF "$(CCTYPE)" == ""
-GCCTARGET	*= $(shell gcc -dumpmachine 2>NUL & exit /b 0)
+GCCTARGET	:= $(shell gcc -dumpmachine 2>NUL & exit /b 0)
 #do we have a GCC?
 .IF "$(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
+.IF "$(WIN64)" == "undef"
 MSVCVER		:= $(shell (set MSVCVER=) & (for /f "tokens=8 delims=.^ " \
 	%i in ('cl ^2^>^&1') do @if not defined MSVCVER set /A "MSVCVER=%i-6"))
+.ELSE
+MSVCVER		:= $(shell (set MSVCVER=) & (for /f "tokens=7 delims=.^ " \
+	%i in ('cl ^2^>^&1') do @if not defined MSVCVER set /A "MSVCVER=%i-6"))
+.ENDIF
 CCTYPE		:= MSVC$(MSVCVER)0
 .ENDIF
 .ENDIF
@@ -523,7 +533,14 @@ BUILDOPT        += -D__USE_MINGW_ANSI_STDIO
 MINIBUILDOPT    += -D__USE_MINGW_ANSI_STDIO
 .ENDIF
 
-GCCWRAPV *= $(shell for /f "delims=. tokens=1,2,3" %i in ('$(CC) -dumpversion') do @if "%i"=="4" (if "%j" geq "3" echo define) else if "%i" geq "5" (echo define))
+GCCVER1:= $(shell for /f "delims=. tokens=1,2,3" %i in ('gcc -dumpversion') do @echo %i)
+GCCVER2:= $(shell for /f "delims=. tokens=1,2,3" %i in ('gcc -dumpversion') do @echo %j)
+GCCVER3:= $(shell for /f "delims=. tokens=1,2,3" %i in ('gcc -dumpversion') do @echo %k)
+
+# If you are using GCC, 4.3 or later by default we add the -fwrapv option.
+# See https://rt.perl.org/Ticket/Display.html?id=121505
+#
+GCCWRAPV *= $(shell if "$(GCCVER1)"=="4" (if "$(GCCVER2)" geq "3" echo define) else if "$(GCCVER1)" geq "5" (echo define))
 
 .IF "$(GCCWRAPV)" == "define"
 BUILDOPT        += -fwrapv
@@ -1139,6 +1156,24 @@ CFG_VARS	=					\
 
 all : CHECKDMAKE rebasePE Extensions_nonxs $(PERLSTATIC) PostExt
 
+info :
+	@echo # CCTYPE=$(CCTYPE)
+.IF "$(CCTYPE)" == "GCC"
+	@echo # CC=$(CC)
+	@echo # GCCVER=$(GCCVER1).$(GCCVER2).$(GCCVER3)
+	@echo # GCCTARGET=$(GCCTARGET)
+	@echo # GCCCROSS=$(GCCCROSS)
+.ENDIF
+	@echo # WIN64=$(WIN64)
+	@echo # ARCHITECTURE=$(ARCHITECTURE)
+	@echo # ARCHNAME=$(ARCHNAME)
+	@echo # MAKE=$(PLMAKE)
+.IF "$(CCTYPE)" == ""
+	@echo Unable to detect gcc and/or architecture!
+	@exit 1
+.ENDIF
+
+
 ..\regcomp$(o) : ..\regnodes.h ..\regcharclass.h
 
 ..\regexec$(o) : ..\regnodes.h ..\regcharclass.h
-- 
2.5.0.windows.1

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Apr 19, 2018

From @steve-m-hay

On 16 April 2018 at 18​:47, bulk88 via RT <perlbug-followup@​perl.org> wrote​:

On Mon, 16 Apr 2018 10​:46​:04 -0700, bulk88 wrote​:

This is a bug report for perl from bulk88@​hotmail.com,
generated with the help of perlbug 1.41 running under perl 5.27.9.

-----------------------------------------------------------------
[Please describe your issue here]
I'll put the patch up separate bc spam filter. This is intended for
5.28. Maybe backport too. Maybe
needs a perldelta entry too. 6th attempt to send bc spam filter.

Thanks for the patch. However, there are still problems with recent
versions of VC, which mean that the wrong CCTYPE is set for VC2015 and
VC2017​:

- Probably for superstitious reasons (?!) Microsoft skipped version
13, so the next version after VC12 (in VS2013) is VC14 (in VS2015)
rather than VC13. However, the version number output by cl.exe did NOT
similarly skip a number, so from VC14 onwards we need to subtract 5
rather than 6 from the cl.exe version.

- VS2017 contains VC14.1 rather than VC15. The CCTYPE in our makefiles
is MSVC141.

VS2010 contains VC10, cl.exe version 16. CCTYPE=MSVC100
VS2012 contains VC11, cl.exe version 17. CCTYPE=MSVC110
VS2013 contains VC12, cl.exe version 18. CCTYPE=MSVC120
VS2015 contains VC14, cl.exe version 19.00. CCTYPE=MSVC140
VS2017 contains VC14.1, cl.exe version 19.11. CCTYPE=MSVC141

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Apr 19, 2018

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Apr 20, 2018

From @bulk88

Created by @bulk88

See attached patch. This is intended for 5.28. Maybe backport too. Maybe
needs a perldelta entry too. 3rd attempt to send bc spam filter. Lets
see if the attachment is caught or not this time.

Perl Info
---
Flags:
                  category=core
                  severity=low
---
Site configuration information for perl 5.27.9:

Configured by Administrator at Tue Jan 30 20:34:30 2018.

Summary of my perl5 (revision 5 version 27 subversion 9) configuration:

                Platform:
                  osname=MSWin32
                  osvers=5.2.3790
                  archname=MSWin32-x86-multi-thread
                  uname=''
                  config_args='undef'
                  hint=recommended
                  useposix=true
                  d_sigaction=undef
                  useithreads=define
                  usemultiplicity=define
                  use64bitint=undef
                  use64bitall=undef
                  uselongdouble=undef
                  usemymalloc=n
                  default_inc_excludes_dot=define
                  bincompat5005=undef
                Compiler:
                  cc='cl'
                  ccflags ='-nologo -GF -W3 -O1 -MD -Zi -DNDEBUG -GL -DWIN32
-D_CONSOLE -DNO_STRICT -D_CRT_SECURE_NO_DEPRECATE
-D_CRT_NONSTDC_NO_DEPRECATE  -DPERL_TEXTMODE_SCRIPTS
-DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DWIN32_NO_REGISTRY'
                  optimize='-O1 -MD -Zi -DNDEBUG -GL'
                  cppflags='-DWIN32'
                  ccversion='15.00.30729.01'
                  gccversion=''
                  gccosandvers=''
                  intsize=4
                  longsize=4
                  ptrsize=4
                  doublesize=8
                  byteorder=1234
                  doublekind=3
                  d_longlong=undef
                  longlongsize=8
                  d_longdbl=define
                  longdblsize=8
                  longdblkind=0
                  ivtype='long'
                  ivsize=4
                  nvtype='double'
                  nvsize=8
                  Off_t='__int64'
                  lseeksize=8
                  alignbytes=8
                  prototype=define
                Linker and Libraries:
                  ld='link'
                  ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf -ltcg
-libpath:"c:\perl\lib\CORE"        -machine:x86'
                  libpth="C:\Program Files (x86)\Microsoft Visual Studio
9.0\VC\lib"
                  libs=oldnames.lib kernel32.lib user32.lib gdi32.lib
winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib
netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib
odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
                  perllibs=oldnames.lib kernel32.lib user32.lib gdi32.lib
winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib
netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib
odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
                  libc=msvcrt.lib
                  so=dll
                  useshrplib=true
                  libperl=perl527.lib
                  gnulibc_version=''
                Dynamic Linking:
                  dlsrc=dl_win32.xs
                  dlext=dll
                  d_dlsymun=undef
                  ccdlflags=' '
                  cccdlflags=' '
                  lddlflags='-dll -nologo -nodefaultlib -debug -opt:ref,icf
-ltcg
                  -libpath:"c:\perl\lib\CORE"        -machine:x86'


---
@INC for perl 5.27.9:
                  lib
                  C:/p527/srcnew/lib

---
Environment for perl 5.27.9:
                  CYGWIN=tty
                  HOME (unset)
                  LANG (unset)
                  LANGUAGE (unset)
                  LD_LIBRARY_PATH=/usr/lib/x86:/usr/X11R6/lib
                  LOGDIR (unset)
                  PATH=C:\WINDOWS\system32;C:\Program Files (x86)\Microsoft
Visual
Studio 9.0\VC\BIN;C:\Program Files\Microsoft
SDKs\Windows\v6.0A\bin;C:\Perl\bin;C:\WINDOWS;C:\Program Files
(x86)\Microsoft Visual Studio 9.0\Common7\IDE;C:\Program Files
(x86)\Git\bin;C:\sp3220\c\bin;
                  PERL_BADLANG (unset)
                  SHELL (unset)






@p5pRT
Copy link
Author

@p5pRT p5pRT commented Apr 20, 2018

From @bulk88

0001-fix-version-autodetect-for-Visual-C-64bit-edition.patch
>Sebz 1q57q348o844rprpp5noprpr995n1r919n1288r2 Zba Frc 17 00:00:00 2001
Sebz: Qnavry Qentna <ohyx88@ubgznvy.pbz>
Qngr: Ghr, 10 Nce 2018 17:36:19 -0400
Fhowrpg: [CNGPU] svk irefvba nhgbqrgrpg sbe Ivfhny P 64ovg rqvgvba

-ercynpr *= jvgu := va znxrsvyr.zx orpnhfr jr qbag jnag gb eha
 "tpp.rkr -qhzcznpuvar" zhygvcyr gvzrf
-64 ovg Ivfhny P unf gur znwbe irefvba ahzore ng 1 "gbxra" yrff guna
 32 ovg rqvgvba, fb gur nhgbqrgrpg pbqr jnf fnlvat IP 2005 64o jnf
 PPGLCR="ZFIP-60" orpnhfr furyy ine %v jnf "00" va gur "frg /N", IP 2005
 32o jnfa'g nssrpgrq, ZF jura gurl perngrq 64 ovg IP gbbx fbzr yvoregvrf
 va punatvat gur irefvba fgevat, ehzbe unf vg znal yrtnpl pbqr onfrf qb n
 fgevat grfg sbe "80k86", fb gung vf jul vg jnf arire hcqngrq ol ZF. V
 guvax qrgrpg 64o IP ire ahz unf orra oebxra fvapr qnl 1 bs gur nhgbqrgrpg
 pbqr gung V jebgr va pbzzvg pn30p090p3 . V whfg aie grfgrq 64o orsber.
-pbcl gur vasb gnetrg sebz TAHZnxrsvyr gb qznxr zxs sbe qrohttvat ernfbaf,
 zbfgyl fb V pna irevsl guvf erivfrq nhgbqrgrpg ybtvp jbexf ohg fvapr gur
 gnetrg hfrf nybg bs PCH/VB/znal cebpf ynhapurq 2 pbzchgr ire naq znal
 pzq.rkrf ynhapurq sbe nyy gubfr rpub yvar, qbag ol qrsnhyg rkrphgr vasb
 gnetrg sebz nyy gnetrg ba qznxr zxs gb fnir ohvyq gvzr. Guvf nyfb erqhprq
 qvss-arff orgjrra gur 2 zxsf. Znlor bar qnl erzbir gur vasb gnetrg sebz
 tznxr zxs gbb, ohg abg va guvf pbzzvg.
---
 jva32/TAHznxrsvyr | 11 +++++++++++
 jva32/znxrsvyr.zx | 39 +++++++++++++++++++++++++++++++++++++--
 2 svyrf punatrq, 48 vafregvbaf(+), 2 qryrgvbaf(-)

qvss --tvg n/jva32/TAHznxrsvyr o/jva32/TAHznxrsvyr
vaqrk 9p89n98..s3695ro 100644
--- n/jva32/TAHznxrsvyr
+++ o/jva32/TAHznxrsvyr
@@ -348,11 +348,22 @@ TPPGNETRG	:= $(furyy $(TPPOVA) -qhzcznpuvar 2>AHY)
 vsard ($(TPPGNETRG),)
 PPGLCR		:= TPP
 ryfr
+JVA64		:= $(furyy sbe /s "gbxraf=3 qryvzf=.^ " \
+	%%v va ('py ^2^>^&1') qb @vs "%%v" == "32-ovg" rpub haqrs)
+#znwbe irefvba bs PY unf qvss cbfvgvba onfrq ba 32 if 64
+#Zvpebfbsg (E) P/P++ Bcgvzvmvat Pbzcvyre Irefvba 15.00.30729.01 sbe k64
+#Zvpebfbsg (E) 32-ovg P/P++ Bcgvzvmvat Pbzcvyre Irefvba 15.00.30729.01 sbe 80k86
 #hfr ine gb pncgher 1fg yvar bayl, abg 8gu gbxra bs yvarf 2 & 3 va py.rkr bhgchg
 #ezivat gur pzq /p pnhfrf gur ine2o haqrs4rpub ohg!4"frg ZFIPIRE", pzq.rkr oht?
+vsrd ($(JVA64),haqrs)
 ZFIPIRE		:= $(furyy (frg ZFIPIRE=) & (sbe /s "gbxraf=8 qryvzf=.^ " \
 	%%v va ('py ^2^>^&1') qb vs abg qrsvarq ZFIPIRE frg /N "ZFIPIRE=%%v-6") \
 	& pzq /p rpub %%ZFIPIRE%%)
+ryfr
+ZFIPIRE		:= $(furyy (frg ZFIPIRE=) & (sbe /s "gbxraf=7 qryvzf=.^ " \
+	%%v va ('py ^2^>^&1') qb vs abg qrsvarq ZFIPIRE frg /N "ZFIPIRE=%%v-6") \
+	& pzq /p rpub %%ZFIPIRE%%)
+raqvs
 PPGLCR		:= ZFIP$(ZFIPIRE)0
 raqvs
 raqvs
qvss --tvg n/jva32/znxrsvyr.zx o/jva32/znxrsvyr.zx
vaqrk 58pp579..7060988 100644
--- n/jva32/znxrsvyr.zx
+++ o/jva32/znxrsvyr.zx
@@ -348,14 +348,24 @@ OHVYQBCG	+= -QJVA32_AB_ERTVFGEL
 
 #ab rkcyvpvg PPGLCR tvira, qb nhgb qrgrpgvba
 .VS "$(PPGLCR)" == ""
-TPPGNETRG	*= $(furyy tpp -qhzcznpuvar 2>AHY & rkvg /o 0)
+TPPGNETRG	:= $(furyy tpp -qhzcznpuvar 2>AHY & rkvg /o 0)
 #qb jr unir n TPP?
 .VS "$(TPPGNETRG)" != ""
 PPGLCR		= TPP
 .RYFR
+JVA64		:= $(furyy sbe /s "gbxraf=3 qryvzf=.^ " \
+	%v va ('py ^2^>^&1') qb @vs "%v" == "32-ovg" rpub haqrs)
+#znwbe irefvba bs PY unf qvss cbfvgvba onfrq ba 32 if 64
+#Zvpebfbsg (E) P/P++ Bcgvzvmvat Pbzcvyre Irefvba 15.00.30729.01 sbe k64
+#Zvpebfbsg (E) 32-ovg P/P++ Bcgvzvmvat Pbzcvyre Irefvba 15.00.30729.01 sbe 80k86
 #hfr ine gb pncgher 1fg yvar bayl, abg 8gu gbxra bs yvarf 2 & 3 va py.rkr bhgchg
+.VS "$(JVA64)" == "haqrs"
 ZFIPIRE		:= $(furyy (frg ZFIPIRE=) & (sbe /s "gbxraf=8 qryvzf=.^ " \
 	%v va ('py ^2^>^&1') qb @vs abg qrsvarq ZFIPIRE frg /N "ZFIPIRE=%v-6"))
+.RYFR
+ZFIPIRE		:= $(furyy (frg ZFIPIRE=) & (sbe /s "gbxraf=7 qryvzf=.^ " \
+	%v va ('py ^2^>^&1') qb @vs abg qrsvarq ZFIPIRE frg /N "ZFIPIRE=%v-6"))
+.RAQVS
 PPGLCR		:= ZFIP$(ZFIPIRE)0
 .RAQVS
 .RAQVS
@@ -523,7 +533,14 @@ OHVYQBCG        += -Q__HFR_ZVATJ_NAFV_FGQVB
 ZVAVOHVYQBCG    += -Q__HFR_ZVATJ_NAFV_FGQVB
 .RAQVS
 
-TPPJENCI *= $(furyy sbe /s "qryvzf=. gbxraf=1,2,3" %v va ('$(PP) -qhzcirefvba') qb @vs "%v"=="4" (vs "%w" trd "3" rpub qrsvar) ryfr vs "%v" trd "5" (rpub qrsvar))
+TPPIRE1:= $(furyy sbe /s "qryvzf=. gbxraf=1,2,3" %v va ('tpp -qhzcirefvba') qb @rpub %v)
+TPPIRE2:= $(furyy sbe /s "qryvzf=. gbxraf=1,2,3" %v va ('tpp -qhzcirefvba') qb @rpub %w)
+TPPIRE3:= $(furyy sbe /s "qryvzf=. gbxraf=1,2,3" %v va ('tpp -qhzcirefvba') qb @rpub %x)
+
+# Vs lbh ner hfvat TPP, 4.3 be yngre ol qrsnhyg jr nqq gur -sjenci bcgvba.
+# Frr uggcf://eg.crey.bet/Gvpxrg/Qvfcynl.ugzy?vq=121505
+#
+TPPJENCI *= $(furyy vs "$(TPPIRE1)"=="4" (vs "$(TPPIRE2)" trd "3" rpub qrsvar) ryfr vs "$(TPPIRE1)" trd "5" (rpub qrsvar))
 
 .VS "$(TPPJENCI)" == "qrsvar"
 OHVYQBCG        += -sjenci
@@ -1139,6 +1156,24 @@ PST_INEF	=					\
 
 nyy : PURPXQZNXR eronfrCR Rkgrafvbaf_abakf $(CREYFGNGVP) CbfgRkg
 
+vasb :
+	@rpub # PPGLCR=$(PPGLCR)
+.VS "$(PPGLCR)" == "TPP"
+	@rpub # PP=$(PP)
+	@rpub # TPPIRE=$(TPPIRE1).$(TPPIRE2).$(TPPIRE3)
+	@rpub # TPPGNETRG=$(TPPGNETRG)
+	@rpub # TPPPEBFF=$(TPPPEBFF)
+.RAQVS
+	@rpub # JVA64=$(JVA64)
+	@rpub # NEPUVGRPGHER=$(NEPUVGRPGHER)
+	@rpub # NEPUANZR=$(NEPUANZR)
+	@rpub # ZNXR=$(CYZNXR)
+.VS "$(PPGLCR)" == ""
+	@rpub Hanoyr gb qrgrpg tpp naq/be nepuvgrpgher!
+	@rkvg 1
+.RAQVS
+
+
 ..\ertpbzc$(b) : ..\ertabqrf.u ..\ertpunepynff.u
 
 ..\ertrkrp$(b) : ..\ertabqrf.u ..\ertpunepynff.u
-- 
2.5.0.jvaqbjf.1


@p5pRT
Copy link
Author

@p5pRT p5pRT commented Apr 21, 2018

From @iabyn

On Thu, Apr 19, 2018 at 10​:24​:15PM -0700, bulk88 wrote​:

See attached patch. This is intended for 5.28. Maybe backport too. Maybe
needs a perldelta entry too. 3rd attempt to send bc spam filter. Lets
see if the attachment is caught or not this time.

The patch you attached appears to have been rot13'ed.

For ease of other people reviewing, I've attached the decoded version
here (along with CRLF -> LF conversion).

Just as an aside, your commit message is very hard to read and comprehend,
due to, amongst other things​:

- lack of paragraphs separated by a blank line;

- gratuitous use of abbreviations, such as "nvr" for "never";

- terse prose;

- lack of punctuation etc;

- and more fundamentally, being written in a way which doesn't make it
  easy to understand what problem(s) are being addressed, and how they
  are being fixed.

With better commit messages, you are likely to get quicker feedback
from p5p members, and it will make it easier for future developers
when trying to understand old commits.

--
Little fly, thy summer's play my thoughtless hand
has terminated with extreme prejudice.
  (with apologies to William Blake)

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Apr 21, 2018

From @iabyn

0001-fix-version-autodetect-for-Visual-C-64bit-edition.patch
>From 1d57d348b844ececc5abcece995a1e919a1288e2 Mon Sep 17 00:00:00 2001
From: Daniel Dragan <bulk88@hotmail.com>
Date: Tue, 10 Apr 2018 17:36:19 -0400
Subject: [PATCH] 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 detect 64b VC ver num has been broken since day 1 of the autodetect
 code that I wrote in commit ca30c090c3 . I just nvr tested 64b before.
-copy the info target from GNUMakefile to dmake mkf 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 2 compute ver and many
 cmd.exes launched for all those echo line, dont by default execute info
 target from all target on dmake mkf to save build time. This also reduced
 diff-ness between the 2 mkfs. Maybe one day remove the info target from
 gmake mkf too, but not in this commit.
---
 win32/GNUmakefile | 11 +++++++++++
 win32/makefile.mk | 39 +++++++++++++++++++++++++++++++++++++--
 2 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/win32/GNUmakefile b/win32/GNUmakefile
index 9c89a98..f3695eb 100644
--- a/win32/GNUmakefile
+++ b/win32/GNUmakefile
@@ -348,11 +348,22 @@ 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?
+ifeq ($(WIN64),undef)
 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%%)
+else
+MSVCVER		:= $(shell (set MSVCVER=) & (for /f "tokens=7 delims=.^ " \
+	%%i in ('cl ^2^>^&1') do if not defined MSVCVER set /A "MSVCVER=%%i-6") \
+	& cmd /c echo %%MSVCVER%%)
+endif
 CCTYPE		:= MSVC$(MSVCVER)0
 endif
 endif
diff --git a/win32/makefile.mk b/win32/makefile.mk
index 58cc579..7060988 100644
--- a/win32/makefile.mk
+++ b/win32/makefile.mk
@@ -348,14 +348,24 @@ BUILDOPT	+= -DWIN32_NO_REGISTRY
 
 #no explicit CCTYPE given, do auto detection
 .IF "$(CCTYPE)" == ""
-GCCTARGET	*= $(shell gcc -dumpmachine 2>NUL & exit /b 0)
+GCCTARGET	:= $(shell gcc -dumpmachine 2>NUL & exit /b 0)
 #do we have a GCC?
 .IF "$(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
+.IF "$(WIN64)" == "undef"
 MSVCVER		:= $(shell (set MSVCVER=) & (for /f "tokens=8 delims=.^ " \
 	%i in ('cl ^2^>^&1') do @if not defined MSVCVER set /A "MSVCVER=%i-6"))
+.ELSE
+MSVCVER		:= $(shell (set MSVCVER=) & (for /f "tokens=7 delims=.^ " \
+	%i in ('cl ^2^>^&1') do @if not defined MSVCVER set /A "MSVCVER=%i-6"))
+.ENDIF
 CCTYPE		:= MSVC$(MSVCVER)0
 .ENDIF
 .ENDIF
@@ -523,7 +533,14 @@ BUILDOPT        += -D__USE_MINGW_ANSI_STDIO
 MINIBUILDOPT    += -D__USE_MINGW_ANSI_STDIO
 .ENDIF
 
-GCCWRAPV *= $(shell for /f "delims=. tokens=1,2,3" %i in ('$(CC) -dumpversion') do @if "%i"=="4" (if "%j" geq "3" echo define) else if "%i" geq "5" (echo define))
+GCCVER1:= $(shell for /f "delims=. tokens=1,2,3" %i in ('gcc -dumpversion') do @echo %i)
+GCCVER2:= $(shell for /f "delims=. tokens=1,2,3" %i in ('gcc -dumpversion') do @echo %j)
+GCCVER3:= $(shell for /f "delims=. tokens=1,2,3" %i in ('gcc -dumpversion') do @echo %k)
+
+# If you are using GCC, 4.3 or later by default we add the -fwrapv option.
+# See https://rt.perl.org/Ticket/Display.html?id=121505
+#
+GCCWRAPV *= $(shell if "$(GCCVER1)"=="4" (if "$(GCCVER2)" geq "3" echo define) else if "$(GCCVER1)" geq "5" (echo define))
 
 .IF "$(GCCWRAPV)" == "define"
 BUILDOPT        += -fwrapv
@@ -1139,6 +1156,24 @@ CFG_VARS	=					\
 
 all : CHECKDMAKE rebasePE Extensions_nonxs $(PERLSTATIC) PostExt
 
+info :
+	@echo # CCTYPE=$(CCTYPE)
+.IF "$(CCTYPE)" == "GCC"
+	@echo # CC=$(CC)
+	@echo # GCCVER=$(GCCVER1).$(GCCVER2).$(GCCVER3)
+	@echo # GCCTARGET=$(GCCTARGET)
+	@echo # GCCCROSS=$(GCCCROSS)
+.ENDIF
+	@echo # WIN64=$(WIN64)
+	@echo # ARCHITECTURE=$(ARCHITECTURE)
+	@echo # ARCHNAME=$(ARCHNAME)
+	@echo # MAKE=$(PLMAKE)
+.IF "$(CCTYPE)" == ""
+	@echo Unable to detect gcc and/or architecture!
+	@exit 1
+.ENDIF
+
+
 ..\regcomp$(o) : ..\regnodes.h ..\regcharclass.h
 
 ..\regexec$(o) : ..\regnodes.h ..\regcharclass.h
-- 
2.5.0.windows.1


@p5pRT
Copy link
Author

@p5pRT p5pRT commented Apr 21, 2018

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Apr 25, 2018

From @iabyn

On Sat, Apr 21, 2018 at 03​:38​:45PM +0100, Dave Mitchell wrote​:

On Thu, Apr 19, 2018 at 10​:24​:15PM -0700, bulk88 wrote​:

See attached patch. This is intended for 5.28. Maybe backport too. Maybe
needs a perldelta entry too. 3rd attempt to send bc spam filter. Lets
see if the attachment is caught or not this time.

The patch you attached appears to have been rot13'ed.

For ease of other people reviewing, I've attached the decoded version
here (along with CRLF -> LF conversion).

I can't tell from the patch description whether this is a critical
build fix which needs to going into 5.28 despite the full code freeze,
or just some 'nice to have' that can wait till 5.29.

Can you clarify, thanks.

--
Standards (n). Battle insignia or tribal totems.

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Apr 26, 2018

From @bulk88

On Wed, 25 Apr 2018 03​:47​:05 -0700, davem wrote​:

On Sat, Apr 21, 2018 at 03​:38​:45PM +0100, Dave Mitchell wrote​:

On Thu, Apr 19, 2018 at 10​:24​:15PM -0700, bulk88 wrote​:

See attached patch. This is intended for 5.28. Maybe backport too. Maybe
needs a perldelta entry too. 3rd attempt to send bc spam filter. Lets
see if the attachment is caught or not this time.

The patch you attached appears to have been rot13'ed.

For ease of other people reviewing, I've attached the decoded version
here (along with CRLF -> LF conversion).

I can't tell from the patch description whether this is a critical
build fix which needs to going into 5.28 despite the full code freeze,
or just some 'nice to have' that can wait till 5.29.

Can you clarify, thanks.

This is a dupe of https://rt-archive.perl.org/perl5/Ticket/Display.html?id=133117 .

--
bulk88 ~ bulk88 at hotmail.com

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Apr 26, 2018

From @bulk88

On Thu, 19 Apr 2018 05​:54​:49 -0700, shay wrote​:

Thanks for the patch. However, there are still problems with recent
versions of VC, which mean that the wrong CCTYPE is set for VC2015 and
VC2017​:

- Probably for superstitious reasons (?!) Microsoft skipped version
13, so the next version after VC12 (in VS2013) is VC14 (in VS2015)
rather than VC13. However, the version number output by cl.exe did NOT
similarly skip a number, so from VC14 onwards we need to subtract 5
rather than 6 from the cl.exe version.

- VS2017 contains VC14.1 rather than VC15. The CCTYPE in our makefiles
is MSVC141.

VS2010 contains VC10, cl.exe version 16. CCTYPE=MSVC100
VS2012 contains VC11, cl.exe version 17. CCTYPE=MSVC110
VS2013 contains VC12, cl.exe version 18. CCTYPE=MSVC120
VS2015 contains VC14, cl.exe version 19.00. CCTYPE=MSVC140
VS2017 contains VC14.1, cl.exe version 19.11. CCTYPE=MSVC141

I've revised the patch description because of comments in https://rt-archive.perl.org/perl5/Ticket/Display.html?id=133126 and I added code to deal with VC 2015 and VC 2017 but I can't test it on a real VC 2015/2017. Test it please.

--
bulk88 ~ bulk88 at hotmail.com

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Apr 26, 2018

From @bulk88

0001-fix-version-autodetect-for-Visual-C-64bit-edition.patch
From 655ae589ae490029e5f118ecaf690f0a3de49468 Mon Sep 17 00:00:00 2001
From: Daniel Dragan <bulk88@hotmail.com>
Date: Thu, 26 Apr 2018 00:14:08 -0400
Subject: [PATCH] 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
---
 win32/GNUmakefile | 47 +++++++++++++++++++++++++++++++++--------------
 win32/makefile.mk | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 83 insertions(+), 19 deletions(-)

diff --git a/win32/GNUmakefile b/win32/GNUmakefile
index c41869a..01f61c4 100644
--- a/win32/GNUmakefile
+++ b/win32/GNUmakefile
@@ -348,12 +348,25 @@ 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
+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
+CCTYPE		:= MSVC$(MSVCVER)
 endif
 endif
 
@@ -1170,17 +1183,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
diff --git a/win32/makefile.mk b/win32/makefile.mk
index 74d6e04..f36fdee 100644
--- a/win32/makefile.mk
+++ b/win32/makefile.mk
@@ -348,15 +348,29 @@ BUILDOPT	+= -DWIN32_NO_REGISTRY
 
 #no explicit CCTYPE given, do auto detection
 .IF "$(CCTYPE)" == ""
-GCCTARGET	*= $(shell gcc -dumpmachine 2>NUL & exit /b 0)
+GCCTARGET	:= $(shell gcc -dumpmachine 2>NUL & exit /b 0)
 #do we have a GCC?
 .IF "$(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
-MSVCVER		:= $(shell (set MSVCVER=) & (for /f "tokens=8 delims=.^ " \
-	%i in ('cl ^2^>^&1') do @if not defined MSVCVER set /A "MSVCVER=%i-6"))
-CCTYPE		:= MSVC$(MSVCVER)0
+.IF "$(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")))
+.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")))
+.ENDIF
+CCTYPE		:= MSVC$(MSVCVER)
 .ENDIF
 .ENDIF
 
@@ -523,7 +537,14 @@ BUILDOPT        += -D__USE_MINGW_ANSI_STDIO
 MINIBUILDOPT    += -D__USE_MINGW_ANSI_STDIO
 .ENDIF
 
-GCCWRAPV *= $(shell for /f "delims=. tokens=1,2,3" %i in ('$(CC) -dumpversion') do @if "%i"=="4" (if "%j" geq "3" echo define) else if "%i" geq "5" (echo define))
+GCCVER1:= $(shell for /f "delims=. tokens=1,2,3" %i in ('gcc -dumpversion') do @echo %i)
+GCCVER2:= $(shell for /f "delims=. tokens=1,2,3" %i in ('gcc -dumpversion') do @echo %j)
+GCCVER3:= $(shell for /f "delims=. tokens=1,2,3" %i in ('gcc -dumpversion') do @echo %k)
+
+# If you are using GCC, 4.3 or later by default we add the -fwrapv option.
+# See https://rt.perl.org/Ticket/Display.html?id=121505
+#
+GCCWRAPV *= $(shell if "$(GCCVER1)"=="4" (if "$(GCCVER2)" geq "3" echo define) else if "$(GCCVER1)" geq "5" (echo define))
 
 .IF "$(GCCWRAPV)" == "define"
 BUILDOPT        += -fwrapv
@@ -1140,6 +1161,30 @@ CFG_VARS	=					\
 
 all : CHECKDMAKE rebasePE Extensions_nonxs $(PERLSTATIC) PostExt
 
+info :
+.IF "$(CCTYPE)" == "GCC"
+	@echo # CCTYPE=$(CCTYPE)&& \
+	echo # CC=$(CC)&& \
+	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
+.IF "$(CCTYPE)" == ""
+	@echo Unable to detect gcc and/or architecture!
+	@exit 1
+.ENDIF
+
+
 ..\regcomp$(o) : ..\regnodes.h ..\regcharclass.h
 
 ..\regexec$(o) : ..\regnodes.h ..\regcharclass.h
-- 
2.5.0.windows.1

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Apr 26, 2018

From @khwilliamson

On 04/25/2018 10​:12 PM, bulk88 via RT wrote​:

On Wed, 25 Apr 2018 03​:47​:05 -0700, davem wrote​:

On Sat, Apr 21, 2018 at 03​:38​:45PM +0100, Dave Mitchell wrote​:

On Thu, Apr 19, 2018 at 10​:24​:15PM -0700, bulk88 wrote​:

See attached patch. This is intended for 5.28. Maybe backport too. Maybe
needs a perldelta entry too. 3rd attempt to send bc spam filter. Lets
see if the attachment is caught or not this time.

The patch you attached appears to have been rot13'ed.

For ease of other people reviewing, I've attached the decoded version
here (along with CRLF -> LF conversion).

I can't tell from the patch description whether this is a critical
build fix which needs to going into 5.28 despite the full code freeze,
or just some 'nice to have' that can wait till 5.29.

Can you clarify, thanks.

This is a dupe of https://rt-archive.perl.org/perl5/Ticket/Display.html?id=133117 .

merged into that

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Apr 26, 2018

From @bulk88

On Wed, 25 Apr 2018 21​:15​:27 -0700, bulk88 wrote​:

I've revised the patch description because of comments in
https://rt-archive.perl.org/perl5/Ticket/Display.html?id=133126 and I added code to
deal with VC 2015 and VC 2017 but I can't test it on a real VC
2015/2017. Test it please.

Patch revised again, I fixed the bug that "make info" without ANY compiler in PATH didn't print the error message in "info" target.

--
bulk88 ~ bulk88 at hotmail.com

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Apr 26, 2018

From @bulk88

0001-fix-version-autodetect-for-Visual-C-64bit-edition.patch
From d3424bc9f91646e06c7e1d4ef48533383e05c1a4 Mon Sep 17 00:00:00 2001
From: Daniel Dragan <bulk88@hotmail.com>
Date: Thu, 26 Apr 2018 01:03:01 -0400
Subject: [PATCH] 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
---
 win32/GNUmakefile | 52 ++++++++++++++++++++++++++++++++++-------------
 win32/makefile.mk | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 93 insertions(+), 19 deletions(-)

diff --git a/win32/GNUmakefile b/win32/GNUmakefile
index a81face..de34db2 100644
--- a/win32/GNUmakefile
+++ b/win32/GNUmakefile
@@ -353,12 +353,30 @@ 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
+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
 
@@ -1178,17 +1196,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
diff --git a/win32/makefile.mk b/win32/makefile.mk
index 0daeb79..be8c4b5 100644
--- a/win32/makefile.mk
+++ b/win32/makefile.mk
@@ -348,15 +348,34 @@ BUILDOPT	+= -DWIN32_NO_REGISTRY
 
 #no explicit CCTYPE given, do auto detection
 .IF "$(CCTYPE)" == ""
-GCCTARGET	*= $(shell gcc -dumpmachine 2>NUL & exit /b 0)
+GCCTARGET	:= $(shell gcc -dumpmachine 2>NUL & exit /b 0)
 #do we have a GCC?
 .IF "$(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
-MSVCVER		:= $(shell (set MSVCVER=) & (for /f "tokens=8 delims=.^ " \
-	%i in ('cl ^2^>^&1') do @if not defined MSVCVER set /A "MSVCVER=%i-6"))
-CCTYPE		:= MSVC$(MSVCVER)0
+.IF "$(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")))
+.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")))
+.ENDIF
+#autodetect failed, reset to empty string
+.IF "$(MSVCVER)" == "-50"
+CCTYPE		:= 
+.ELSE
+CCTYPE		:= MSVC$(MSVCVER)
+.ENDIF
 .ENDIF
 .ENDIF
 
@@ -523,7 +542,14 @@ BUILDOPT        += -D__USE_MINGW_ANSI_STDIO
 MINIBUILDOPT    += -D__USE_MINGW_ANSI_STDIO
 .ENDIF
 
-GCCWRAPV *= $(shell for /f "delims=. tokens=1,2,3" %i in ('$(CC) -dumpversion') do @if "%i"=="4" (if "%j" geq "3" echo define) else if "%i" geq "5" (echo define))
+GCCVER1:= $(shell for /f "delims=. tokens=1,2,3" %i in ('gcc -dumpversion') do @echo %i)
+GCCVER2:= $(shell for /f "delims=. tokens=1,2,3" %i in ('gcc -dumpversion') do @echo %j)
+GCCVER3:= $(shell for /f "delims=. tokens=1,2,3" %i in ('gcc -dumpversion') do @echo %k)
+
+# If you are using GCC, 4.3 or later by default we add the -fwrapv option.
+# See https://rt.perl.org/Ticket/Display.html?id=121505
+#
+GCCWRAPV *= $(shell if "$(GCCVER1)"=="4" (if "$(GCCVER2)" geq "3" echo define) else if "$(GCCVER1)" geq "5" (echo define))
 
 .IF "$(GCCWRAPV)" == "define"
 BUILDOPT        += -fwrapv
@@ -1140,6 +1166,30 @@ CFG_VARS	=					\
 
 all : CHECKDMAKE rebasePE Extensions_nonxs $(PERLSTATIC) PostExt
 
+info :
+.IF "$(CCTYPE)" == "GCC"
+	@echo # CCTYPE=$(CCTYPE)&& \
+	echo # CC=$(CC)&& \
+	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
+.IF "$(CCTYPE)" == ""
+	@echo Unable to detect gcc and/or architecture!
+	@exit 1
+.ENDIF
+
+
 ..\regcomp$(o) : ..\regnodes.h ..\regcharclass.h
 
 ..\regexec$(o) : ..\regnodes.h ..\regcharclass.h
-- 
2.5.0.windows.1

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Apr 26, 2018

From @bulk88

On Wed, 25 Apr 2018 03​:47​:05 -0700, davem wrote​:

I can't tell from the patch description whether this is a critical
build fix which needs to going into 5.28 despite the full code freeze,
or just some 'nice to have' that can wait till 5.29.

Can you clarify, thanks.

I dont care that much if its in 5.28.0 at this point. If its appropriate for 5.28.1 as a build fix (needs more testing from community), then it is appropriate. Its a bug fix for a bug that has been since day 1 of the code without complaints from anyone else. The build still works if you set all the info manually like everyone did since the Win32 perl port started years ago.

--
bulk88 ~ bulk88 at hotmail.com

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Apr 28, 2018

From @iabyn

On Wed, Apr 25, 2018 at 10​:21​:07PM -0700, bulk88 via RT wrote​:

I dont care that much if its in 5.28.0 at this point.

Ok, I'll remove from the blockers list.

--
More than any other time in history, mankind faces a crossroads. One path
leads to despair and utter hopelessness. The other, to total extinction.
Let us pray we have the wisdom to choose correctly.
  -- Woody Allen

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jul 10, 2018

From @steve-m-hay

On Wed, 25 Apr 2018 22​:16​:43 -0700, bulk88 wrote​:

On Wed, 25 Apr 2018 21​:15​:27 -0700, bulk88 wrote​:

I've revised the patch description because of comments in
https://rt-archive.perl.org/perl5/Ticket/Display.html?id=133126 and I added code to
deal with VC 2015 and VC 2017 but I can't test it on a real VC
2015/2017. Test it please.

Patch revised again, I fixed the bug that "make info" without ANY
compiler in PATH didn't print the error message in "info" target.

Please could you expand the following comment (in GNUmakefile) into more intelligible English?​:

#rmving the cmd /c causes the var2b undef4echo but!4"set MSVCVER", cmd.exe bug?

(or just remove it? - it isn't in the equivalent section of code in makefile.mk).

Testing - I get slightly different output from the info target when using gmake vs dmake with gcc compilers - the dmake output is missing GCCTARGET (e.g. with mingw-w64.org 7.1.0 x86)​:

C​:\Dev\Git\perl\win32>gmake info
# CCTYPE=GCC
# GCCBIN=gcc
# GCCVER=7.1.0
# GCCTARGET=i686-w64-mingw32
# GCCCROSS=
# WIN64=undef
# ARCHITECTURE=x86
# ARCHNAME=MSWin32-x86-multi-thread
# MAKE=gmake

C​:\Dev\Git\perl\win32>dmake info
# CCTYPE=GCC
# CC=gcc
# GCCVER=7.1.0
# GCCTARGET=
# GCCCROSS=
# WIN64=undef
# ARCHITECTURE=x86
# ARCHNAME=MSWin32-x86-multi-thread
# MAKE=dmake

Otherwise this is looking good - tested with several gccs (mingw.org and mingw-w64.org), VC6 x86 and VC10/11/12/14/141 x86/x64.

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jul 27, 2018

From @bulk88

On Tue, 10 Jul 2018 06​:00​:45 -0700, shay wrote​:

Please could you expand the following comment (in GNUmakefile) into
more intelligible English?​:

#rmving the cmd /c causes the var2b undef4echo but!4"set MSVCVER",
cmd.exe bug?

(or just remove it? - it isn't in the equivalent section of code in
makefile.mk).

No, without that cmd /c the makefile var is empty string or undef but only for gmake. The extra cmd /c isn't needed for dmake. IDK y.

Testing - I get slightly different output from the info target when
using gmake vs dmake with gcc compilers - the dmake output is missing
GCCTARGET (e.g. with mingw-w64.org 7.1.0 x86)​:

C​:\Dev\Git\perl\win32>gmake info
# CCTYPE=GCC
# GCCBIN=gcc
# GCCVER=7.1.0
# GCCTARGET=i686-w64-mingw32
# GCCCROSS=
# WIN64=undef
# ARCHITECTURE=x86
# ARCHNAME=MSWin32-x86-multi-thread
# MAKE=gmake

C​:\Dev\Git\perl\win32>dmake info
# CCTYPE=GCC
# CC=gcc
# GCCVER=7.1.0
# GCCTARGET=
# GCCCROSS=
# WIN64=undef
# ARCHITECTURE=x86
# ARCHNAME=MSWin32-x86-multi-thread
# MAKE=dmake

Otherwise this is looking good - tested with several gccs (mingw.org
and mingw-w64.org), VC6 x86 and VC10/11/12/14/141 x86/x64.

Can you retry the latest patch for GCCTARGET var? For me GCCTARGET is identical between dmake and gmake


C​:\perl528\srcnew\win32>gmake info
# CCTYPE=GCC
# GCCBIN=gcc
# GCCVER=4.9.2
# GCCTARGET=i686-w64-mingw32
# GCCCROSS=
# WIN64=undef
# ARCHITECTURE=x86
# ARCHNAME=MSWin32-x86-multi-thread
# MAKE=gmake

C​:\perl528\srcnew\win32>dmake info
# CCTYPE=GCC
# CC=gcc
# GCCVER=4.9.2
# GCCTARGET=i686-w64-mingw32
# GCCCROSS=
# WIN64=undef
# ARCHITECTURE=x86
# ARCHNAME=MSWin32-x86-multi-thread
# MAKE=dmake

C​:\perl528\srcnew\win32>


--
bulk88 ~ bulk88 at hotmail.com

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jul 27, 2018

From @bulk88

0001-fix-version-autodetect-for-Visual-C-64bit-edition.patch
From 9c174314f2bacdb818f7ac8c18bc8be948d3c2ff Mon Sep 17 00:00:00 2001
From: Daniel Dragan <bulk88@hotmail.com>
Date: Fri, 27 Jul 2018 16:44:26 -0400
Subject: [PATCH] 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
---
 win32/GNUmakefile | 56 +++++++++++++++++++++++++++++++++++++--------------
 win32/makefile.mk | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 96 insertions(+), 20 deletions(-)

diff --git a/win32/GNUmakefile b/win32/GNUmakefile
index 9384120..6f1ef26 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
diff --git a/win32/makefile.mk b/win32/makefile.mk
index 293abf9..9aad481 100644
--- a/win32/makefile.mk
+++ b/win32/makefile.mk
@@ -349,15 +349,34 @@ BUILDOPT	+= -DWIN32_NO_REGISTRY
 
 #no explicit CCTYPE given, do auto detection
 .IF "$(CCTYPE)" == ""
-GCCTARGET	*= $(shell gcc -dumpmachine 2>NUL & exit /b 0)
+GCCTARGET	:= $(shell gcc -dumpmachine 2>NUL & exit /b 0)
 #do we have a GCC?
 .IF "$(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
-MSVCVER		:= $(shell (set MSVCVER=) & (for /f "tokens=8 delims=.^ " \
-	%i in ('cl ^2^>^&1') do @if not defined MSVCVER set /A "MSVCVER=%i-6"))
-CCTYPE		:= MSVC$(MSVCVER)0
+.IF "$(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")))
+.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")))
+.ENDIF
+#autodetect failed, reset to empty string
+.IF "$(MSVCVER)" == "-50"
+CCTYPE		:= 
+.ELSE
+CCTYPE		:= MSVC$(MSVCVER)
+.ENDIF
 .ENDIF
 .ENDIF
 
@@ -524,7 +543,14 @@ BUILDOPT        += -D__USE_MINGW_ANSI_STDIO
 MINIBUILDOPT    += -D__USE_MINGW_ANSI_STDIO
 .ENDIF
 
-GCCWRAPV *= $(shell for /f "delims=. tokens=1,2,3" %i in ('$(CC) -dumpversion') do @if "%i"=="4" (if "%j" geq "3" echo define) else if "%i" geq "5" (echo define))
+GCCVER1:= $(shell for /f "delims=. tokens=1,2,3" %i in ('gcc -dumpversion') do @echo %i)
+GCCVER2:= $(shell for /f "delims=. tokens=1,2,3" %i in ('gcc -dumpversion') do @echo %j)
+GCCVER3:= $(shell for /f "delims=. tokens=1,2,3" %i in ('gcc -dumpversion') do @echo %k)
+
+# If you are using GCC, 4.3 or later by default we add the -fwrapv option.
+# See https://rt.perl.org/Ticket/Display.html?id=121505
+#
+GCCWRAPV *= $(shell if "$(GCCVER1)"=="4" (if "$(GCCVER2)" geq "3" echo define) else if "$(GCCVER1)" geq "5" (echo define))
 
 .IF "$(GCCWRAPV)" == "define"
 BUILDOPT        += -fwrapv
@@ -1141,6 +1167,30 @@ CFG_VARS	=					\
 
 all : CHECKDMAKE rebasePE Extensions_nonxs $(PERLSTATIC) PostExt
 
+info :
+.IF "$(CCTYPE)" == "GCC"
+	@echo # CCTYPE=$(CCTYPE)&& \
+	echo # CC=$(CC)&& \
+	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
+.IF "$(CCTYPE)" == ""
+	@echo Unable to detect gcc and/or architecture!
+	@exit 1
+.ENDIF
+
+
 ..\regcomp$(o) : ..\regnodes.h ..\regcharclass.h
 
 ..\regexec$(o) : ..\regnodes.h ..\regcharclass.h
-- 
2.5.0.windows.1

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jul 28, 2018

From @bulk88

On Fri, 27 Jul 2018 13​:48​:12 -0700, bulk88 wrote​:

Newest patch expanded on that gmake "cmd /c" makefile comment. That was the only change I did.

--
bulk88 ~ bulk88 at hotmail.com

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jul 30, 2018

From @steve-m-hay

On Sat, 28 Jul 2018 12​:19​:29 -0700, bulk88 wrote​:

On Fri, 27 Jul 2018 13​:48​:12 -0700, bulk88 wrote​:

Newest patch expanded on that gmake "cmd /c" makefile comment. That
was the only change I did.

Thanks for the updated comment. I found the problem with GCCTARGET not getting set in the dmake case​: It was because my environment already had CCTYPE set (to GCC). I copied a chunk from the gmake makefile to handle that and it all looks good now.

Now committed to blead in commits b2029be and 91584c7.

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jul 30, 2018

@steve-m-hay - Status changed from 'open' to 'pending release'

@p5pRT
Copy link
Author

@p5pRT p5pRT commented May 22, 2019

From @khwilliamson

Thank you for filing this report. You have helped make Perl better.

With the release today of Perl 5.30.0, this and 160 other issues have been
resolved.

Perl 5.30.0 may be downloaded via​:
https://metacpan.org/release/XSAWYERX/perl-5.30.0

If you find that the problem persists, feel free to reopen this ticket.

@p5pRT
Copy link
Author

@p5pRT p5pRT commented May 22, 2019

@khwilliamson - Status changed from 'pending release' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant