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
Comments
From @bulk88Created by @bulk88I'll put the patch up separate bc spam filter. This is intended for Perl Info
|
From @bulk88On Mon, 16 Apr 2018 10:46:04 -0700, bulk88 wrote:
-- |
From @bulk880001-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
|
From @steve-m-hayOn 16 April 2018 at 18:47, bulk88 via RT <perlbug-followup@perl.org> wrote:
Thanks for the patch. However, there are still problems with recent - Probably for superstitious reasons (?!) Microsoft skipped version - VS2017 contains VC14.1 rather than VC15. The CCTYPE in our makefiles VS2010 contains VC10, cl.exe version 16. CCTYPE=MSVC100 |
The RT System itself - Status changed from 'new' to 'open' |
From @bulk88Created by @bulk88See attached patch. This is intended for 5.28. Maybe backport too. Maybe Perl Info
|
From @bulk880001-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
|
From @iabynOn Thu, Apr 19, 2018 at 10:24:15PM -0700, bulk88 wrote:
The patch you attached appears to have been rot13'ed. For ease of other people reviewing, I've attached the decoded version Just as an aside, your commit message is very hard to read and comprehend, - 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 With better commit messages, you are likely to get quicker feedback -- |
From @iabyn0001-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
|
The RT System itself - Status changed from 'new' to 'open' |
From @iabynOn Sat, Apr 21, 2018 at 03:38:45PM +0100, Dave Mitchell wrote:
I can't tell from the patch description whether this is a critical Can you clarify, thanks. -- |
From @bulk88On Wed, 25 Apr 2018 03:47:05 -0700, davem wrote:
This is a dupe of https://rt-archive.perl.org/perl5/Ticket/Display.html?id=133117 . -- |
From @bulk88On Thu, 19 Apr 2018 05:54:49 -0700, shay 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. -- |
From @bulk880001-fix-version-autodetect-for-Visual-C-64bit-edition.patchFrom 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
|
From @khwilliamsonOn 04/25/2018 10:12 PM, bulk88 via RT wrote:
merged into that |
From @bulk88On Wed, 25 Apr 2018 21:15:27 -0700, bulk88 wrote:
Patch revised again, I fixed the bug that "make info" without ANY compiler in PATH didn't print the error message in "info" target. -- |
From @bulk880001-fix-version-autodetect-for-Visual-C-64bit-edition.patchFrom 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
|
From @bulk88On Wed, 25 Apr 2018 03:47:05 -0700, davem wrote:
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. -- |
From @iabynOn Wed, Apr 25, 2018 at 10:21:07PM -0700, bulk88 via RT wrote:
Ok, I'll remove from the blockers list. -- |
From @steve-m-hayOn Wed, 25 Apr 2018 22:16:43 -0700, bulk88 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). 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 C:\Dev\Git\perl\win32>dmake info 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. |
From @bulk88On Tue, 10 Jul 2018 06:00:45 -0700, shay wrote:
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.
Can you retry the latest patch for GCCTARGET var? For me GCCTARGET is identical between dmake and gmake C:\perl528\srcnew\win32>gmake info C:\perl528\srcnew\win32>dmake info C:\perl528\srcnew\win32> -- |
From @bulk880001-fix-version-autodetect-for-Visual-C-64bit-edition.patchFrom 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
|
From @bulk88On 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. -- |
From @steve-m-hayOn Sat, 28 Jul 2018 12:19:29 -0700, bulk88 wrote:
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. |
@steve-m-hay - Status changed from 'open' to 'pending release' |
From @khwilliamsonThank 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 Perl 5.30.0 may be downloaded via: If you find that the problem persists, feel free to reopen this ticket. |
@khwilliamson - Status changed from 'pending release' to 'resolved' |
Migrated from rt.perl.org#133117 (status was 'resolved')
Searchable as RT133117$
The text was updated successfully, but these errors were encountered: