-
Notifications
You must be signed in to change notification settings - Fork 542
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] win32: separate $Config{ccflags} and $Config{optimize} #17156
Comments
From @xenuOptimization flags don't belong in $Config{ccflags} and defines This change makes overriding optimization flags in Makefile.PL Additionally, don't define NDEBUG, perl.h already takes care of The patch will be attached to a reply. perl # circumvent perlbug's spamfilter |
From @xenuOn Sun, 22 Sep 2019 08:23:10 -0700
The patch is attached. |
From @xenu0001-win32-separate-Config-ccflags-and-Config-optimize.patchFrom 07dd43c03772f30d576adb42ea7bb9b05037368f Mon Sep 17 00:00:00 2001
From: Tomasz Konojacki <me@xenu.pl>
Date: Sun, 22 Sep 2019 14:43:09 +0200
Subject: [PATCH] win32: separate $Config{ccflags} and $Config{optimize}
Optimization flags don't belong in $Config{ccflags} and defines
don't belong in $Config{optimize}.
This change makes overriding optimization flags in Makefile.PL
and Build.PL on win32 just as easy as on unix-likes.
Additionally, don't define NDEBUG, perl.h already takes care of
that.
[perl #134445]
---
win32/GNUmakefile | 14 +++++++++-----
win32/Makefile | 10 ++++++----
win32/makefile.mk | 13 ++++++++-----
3 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/win32/GNUmakefile b/win32/GNUmakefile
index 59dbfdab08..27c5e39650 100644
--- a/win32/GNUmakefile
+++ b/win32/GNUmakefile
@@ -618,8 +618,9 @@ LIBFILES = $(LIBC) -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool \
-luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
ifeq ($(CFG),Debug)
-OPTIMIZE = -g -O2 -DDEBUGGING
+OPTIMIZE = -g -O2
LINK_DBG = -g
+DEFINES += -DDEBUGGING
else
OPTIMIZE = -s -O2
LINK_DBG = -s
@@ -713,8 +714,9 @@ LIBC = msvcrt.lib
endif
ifeq ($(CFG),Debug)
-OPTIMIZE = -Od -MD -Zi -DDEBUGGING
+OPTIMIZE = -Od -MD -Zi
LINK_DBG = -debug
+DEFINES += -DDEBUGGING
else ifeq ($(CFG),DebugSymbols)
OPTIMIZE = -Od -MD -Zi
LINK_DBG = -debug
@@ -728,11 +730,13 @@ LIBC = ucrtd.lib
else
LIBC = msvcrtd.lib
endif
-OPTIMIZE = -Od -MDd -Zi -D_DEBUG -DDEBUGGING
+OPTIMIZE = -Od -MDd -Zi
LINK_DBG = -debug
+DEFINES += -D_DEBUG -DDEBUGGING
+
else
# -O1 yields smaller code, which turns out to be faster than -O2 on x86 and x64
-OPTIMIZE = -O1 -MD -Zi -DNDEBUG
+OPTIMIZE = -O1 -MD -Zi
# we enable debug symbols in release builds also
LINK_DBG = -debug -opt:ref,icf
# you may want to enable this if you want COFF symbols in the executables
@@ -1209,7 +1213,7 @@ CFG_VARS = \
"archname=$(ARCHNAME)" \
"cc=$(CC)" \
"ld=$(LINK32)" \
- "ccflags=$(subst ",\",$(EXTRACFLAGS) $(OPTIMIZE) $(DEFINES) $(BUILDOPT))" \
+ "ccflags=$(subst ",\",$(EXTRACFLAGS) $(DEFINES) $(BUILDOPT))" \
"usecplusplus=$(USE_CPLUSPLUS)" \
"cf_email=$(EMAIL)" \
"d_mymalloc=$(PERL_MALLOC)" \
diff --git a/win32/Makefile b/win32/Makefile
index 29ae90d4f6..dbb431a11b 100644
--- a/win32/Makefile
+++ b/win32/Makefile
@@ -502,8 +502,9 @@ LIBC = msvcrt.lib
!ENDIF
!IF "$(CFG)" == "Debug"
-OPTIMIZE = -Od -MD -Zi -DDEBUGGING
+OPTIMIZE = -Od -MD -Zi
LINK_DBG = -debug
+DEFINES = $(DEFINES) -DDEBUGGING
!ELSEIF "$(CFG)" == "DebugSymbols"
OPTIMIZE = -Od -MD -Zi
LINK_DBG = -debug
@@ -513,11 +514,12 @@ LIBC = ucrtd.lib
! ELSE
LIBC = msvcrtd.lib
! ENDIF
-OPTIMIZE = -Od -MDd -Zi -D_DEBUG -DDEBUGGING
+OPTIMIZE = -Od -MDd -Zi
LINK_DBG = -debug
+DEFINES = $(DEFINES) -D_DEBUG -DDEBUGGING
!ELSE
# -O1 yields smaller code, which turns out to be faster than -O2 on x86 and x64
-OPTIMIZE = -O1 -MD -Zi -DNDEBUG
+OPTIMIZE = -O1 -MD -Zi
# we enable debug symbols in release builds also
LINK_DBG = -debug -opt:ref,icf
# you may want to enable this if you want COFF symbols in the executables
@@ -916,7 +918,7 @@ CFG_VARS = \
"archname=$(ARCHNAME)" \
"cc=$(CC)" \
"ld=$(LINK32)" \
- "ccflags=$(EXTRACFLAGS) $(OPTIMIZE:"=\") $(DEFINES) $(BUILDOPT)" \
+ "ccflags=$(EXTRACFLAGS) $(DEFINES) $(BUILDOPT)" \
"usecplusplus=$(USE_CPLUSPLUS)" \
"cf_email=$(EMAIL)" \
"d_mymalloc=$(PERL_MALLOC)" \
diff --git a/win32/makefile.mk b/win32/makefile.mk
index 9d40c6cfc5..f824efcee2 100644
--- a/win32/makefile.mk
+++ b/win32/makefile.mk
@@ -593,8 +593,9 @@ LIBFILES = $(LIBC) -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool \
-luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
.IF "$(CFG)" == "Debug"
-OPTIMIZE = -g -O2 -DDEBUGGING
+OPTIMIZE = -g -O2
LINK_DBG = -g
+DEFINES += -DDEBUGGING
.ELIF "$(CFG)" == "DebugSymbols"
OPTIMIZE = -g -O2
LINK_DBG = -g
@@ -682,8 +683,9 @@ LIBC = msvcrt.lib
.ENDIF
.IF "$(CFG)" == "Debug"
-OPTIMIZE = -Od -MD -Zi -DDEBUGGING
+OPTIMIZE = -Od -MD -Zi
LINK_DBG = -debug
+DEFINES += -DDEBUGGING
.ELIF "$(CFG)" == "DebugSymbols"
OPTIMIZE = -Od -MD -Zi
LINK_DBG = -debug
@@ -693,11 +695,12 @@ LIBC = ucrtd.lib
.ELSE
LIBC = msvcrtd.lib
.ENDIF
-OPTIMIZE = -Od -MDd -Zi -D_DEBUG -DDEBUGGING
+OPTIMIZE = -Od -MDd -Zi
LINK_DBG = -debug
+DEFINES += -D_DEBUG -DDEBUGGING
.ELSE
# -O1 yields smaller code, which turns out to be faster than -O2 on x86 and x64
-OPTIMIZE = -O1 -MD -Zi -DNDEBUG
+OPTIMIZE = -O1 -MD -Zi
# we enable debug symbols in release builds also
LINK_DBG = -debug -opt:ref,icf
# you may want to enable this if you want COFF symbols in the executables
@@ -1151,7 +1154,7 @@ CFG_VARS = \
archname=$(ARCHNAME) ~ \
cc=$(CC) ~ \
ld=$(LINK32) ~ \
- ccflags=$(EXTRACFLAGS) $(OPTIMIZE) $(DEFINES) $(BUILDOPT) ~ \
+ ccflags=$(EXTRACFLAGS) $(DEFINES) $(BUILDOPT) ~ \
usecplusplus=$(USE_CPLUSPLUS) ~ \
cf_email=$(EMAIL) ~ \
d_mymalloc=$(PERL_MALLOC) ~ \
--
2.21.0.windows.1
|
From @tonycozOn Sun, 22 Sep 2019 08:29:38 -0700, me@xenu.pl wrote:
I think this is a useful patch, but if you're trying to match POSIX-ish systems, I don't think -MD and its variants belong in optimize. There's no real equivalent, but while I might override -Od or -Zi to debug some XS module, overriding -MD would likely lead to unrelated breakage (XS and core might end up using a different errno for example.) -OPTIMIZE = -Od -MDd -Zi -D_DEBUG -DDEBUGGING -OPTIMIZE = -Od -MD -Zi -DDEBUGGING Tony |
The RT System itself - Status changed from 'new' to 'open' |
From @xenuOn Tue, 01 Oct 2019 16:04:08 -0700
Yes, you're right, I didn't think through the MSVC part of that patch. V2 is attached. |
From @xenu0001-win32-separate-Config-ccflags-and-Config-optimize.patchFrom f61865ec7b1bdff621c982fc300e3349574d2be5 Mon Sep 17 00:00:00 2001
From: Tomasz Konojacki <me@xenu.pl>
Date: Thu, 3 Oct 2019 13:13:20 +0200
Subject: [PATCH] win32: separate $Config{ccflags} and $Config{optimize}
Optimization flags don't belong in $Config{ccflags}, while
defines and CRT flags don't belong in $Config{optimize}.
This change makes overriding optimization flags in Makefile.PL
and Build.PL on win32 just as easy as on unix-likes.
Additionally, don't define NDEBUG, perl.h already takes care of
that.
[perl #134445]
---
win32/GNUmakefile | 22 +++++++++++++++-------
win32/Makefile | 19 ++++++++++++-------
win32/makefile.mk | 21 ++++++++++++++-------
3 files changed, 41 insertions(+), 21 deletions(-)
diff --git a/win32/GNUmakefile b/win32/GNUmakefile
index 59dbfdab08..3d456ef071 100644
--- a/win32/GNUmakefile
+++ b/win32/GNUmakefile
@@ -618,8 +618,9 @@ LIBFILES = $(LIBC) -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool \
-luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
ifeq ($(CFG),Debug)
-OPTIMIZE = -g -O2 -DDEBUGGING
+OPTIMIZE = -g -O2
LINK_DBG = -g
+DEFINES += -DDEBUGGING
else
OPTIMIZE = -s -O2
LINK_DBG = -s
@@ -701,6 +702,7 @@ INCLUDES = -I.\include -I. -I..
DEFINES = -DWIN32 -D_CONSOLE -DNO_STRICT
LOCDEFS = -DPERLDLL -DPERL_CORE
CXX_FLAG = -TP -EHsc
+EXTRACFLAGS = -nologo -GF -W3
ifeq ($(CCTYPE),MSVC140)
LIBC = ucrt.lib
@@ -713,11 +715,14 @@ LIBC = msvcrt.lib
endif
ifeq ($(CFG),Debug)
-OPTIMIZE = -Od -MD -Zi -DDEBUGGING
+OPTIMIZE = -Od -Zi
LINK_DBG = -debug
+DEFINES += -DDEBUGGING
+EXTRACFLAGS += -MD
else ifeq ($(CFG),DebugSymbols)
-OPTIMIZE = -Od -MD -Zi
+OPTIMIZE = -Od -Zi
LINK_DBG = -debug
+EXTRACFLAGS += -MD
else ifeq ($(CFG),DebugFull)
ifeq ($(CCTYPE),MSVC140)
LIBC = ucrtd.lib
@@ -728,11 +733,14 @@ LIBC = ucrtd.lib
else
LIBC = msvcrtd.lib
endif
-OPTIMIZE = -Od -MDd -Zi -D_DEBUG -DDEBUGGING
+OPTIMIZE = -Od -Zi
LINK_DBG = -debug
+DEFINES += -D_DEBUG -DDEBUGGING
+EXTRACFLAGS += -MDd
+
else
# -O1 yields smaller code, which turns out to be faster than -O2 on x86 and x64
-OPTIMIZE = -O1 -MD -Zi -DNDEBUG
+OPTIMIZE = -O1 -Zi
# we enable debug symbols in release builds also
LINK_DBG = -debug -opt:ref,icf
# you may want to enable this if you want COFF symbols in the executables
@@ -741,6 +749,7 @@ LINK_DBG = -debug -opt:ref,icf
# installed to get better stack traces from just the PDB symbols, so we
# avoid the bloat of COFF symbols by default.
#LINK_DBG = $(LINK_DBG) -debugtype:both
+EXTRACFLAGS += -MD
ifneq ($(CCTYPE),MSVC60)
# enable Whole Program Optimizations (WPO) and Link Time Code Generation (LTCG)
OPTIMIZE += -GL
@@ -835,7 +844,6 @@ endif
LIBFILES = $(LIBBASEFILES) $(LIBC)
-EXTRACFLAGS = -nologo -GF -W3
ifeq ($(__ICC),define)
EXTRACFLAGS += -Qstd=c99
endif
@@ -1209,7 +1217,7 @@ CFG_VARS = \
"archname=$(ARCHNAME)" \
"cc=$(CC)" \
"ld=$(LINK32)" \
- "ccflags=$(subst ",\",$(EXTRACFLAGS) $(OPTIMIZE) $(DEFINES) $(BUILDOPT))" \
+ "ccflags=$(subst ",\",$(EXTRACFLAGS) $(DEFINES) $(BUILDOPT))" \
"usecplusplus=$(USE_CPLUSPLUS)" \
"cf_email=$(EMAIL)" \
"d_mymalloc=$(PERL_MALLOC)" \
diff --git a/win32/Makefile b/win32/Makefile
index 29ae90d4f6..8906617127 100644
--- a/win32/Makefile
+++ b/win32/Makefile
@@ -494,6 +494,7 @@ INCLUDES = -I$(COREDIR) -I.\include -I. -I..
DEFINES = -DWIN32 -D_CONSOLE -DNO_STRICT
LOCDEFS = -DPERLDLL -DPERL_CORE
CXX_FLAG = -TP -EHsc
+EXTRACFLAGS = -nologo -GF -W3
!IF "$(CCTYPE)" == "MSVC140" || "$(CCTYPE)" == "MSVC141" || "$(CCTYPE)" == "MSVC142"
LIBC = ucrt.lib
@@ -502,22 +503,27 @@ LIBC = msvcrt.lib
!ENDIF
!IF "$(CFG)" == "Debug"
-OPTIMIZE = -Od -MD -Zi -DDEBUGGING
+OPTIMIZE = -Od -Zi
LINK_DBG = -debug
+DEFINES = $(DEFINES) -DDEBUGGING
+EXTRACFLAGS = $(EXTRACFLAGS) -MD
!ELSEIF "$(CFG)" == "DebugSymbols"
-OPTIMIZE = -Od -MD -Zi
+OPTIMIZE = -Od -Zi
LINK_DBG = -debug
+EXTRACFLAGS = $(EXTRACFLAGS) -MD
!ELSEIF "$(CFG)" == "DebugFull"
! IF "$(CCTYPE)" == "MSVC140" || "$(CCTYPE)" == "MSVC141" || "$(CCTYPE)" == "MSVC142"
LIBC = ucrtd.lib
! ELSE
LIBC = msvcrtd.lib
! ENDIF
-OPTIMIZE = -Od -MDd -Zi -D_DEBUG -DDEBUGGING
+OPTIMIZE = -Od -Zi
LINK_DBG = -debug
+DEFINES = $(DEFINES) -D_DEBUG -DDEBUGGING
+EXTRACFLAGS = $(EXTRACFLAGS) -MDd
!ELSE
# -O1 yields smaller code, which turns out to be faster than -O2 on x86 and x64
-OPTIMIZE = -O1 -MD -Zi -DNDEBUG
+OPTIMIZE = -O1 -Zi
# we enable debug symbols in release builds also
LINK_DBG = -debug -opt:ref,icf
# you may want to enable this if you want COFF symbols in the executables
@@ -526,6 +532,7 @@ LINK_DBG = -debug -opt:ref,icf
# installed to get better stack traces from just the PDB symbols, so we
# avoid the bloat of COFF symbols by default.
#LINK_DBG = $(LINK_DBG) -debugtype:both
+EXTRACFLAGS = $(EXTRACFLAGS) -MD
! IF "$(CCTYPE)" != "MSVC60"
# enable Whole Program Optimizations (WPO) and Link Time Code Generation (LTCG)
OPTIMIZE = $(OPTIMIZE) -GL
@@ -603,8 +610,6 @@ LIBBASEFILES = $(LIBBASEFILES) bufferoverflowU.lib
LIBFILES = $(LIBBASEFILES) $(LIBC)
-#EXTRACFLAGS = -nologo -GF -W4 -wd4127 -wd4706
-EXTRACFLAGS = -nologo -GF -W3
!IF "$(__ICC)" == "define"
EXTRACFLAGS = $(EXTRACFLAGS) -Qstd=c99
!ENDIF
@@ -916,7 +921,7 @@ CFG_VARS = \
"archname=$(ARCHNAME)" \
"cc=$(CC)" \
"ld=$(LINK32)" \
- "ccflags=$(EXTRACFLAGS) $(OPTIMIZE:"=\") $(DEFINES) $(BUILDOPT)" \
+ "ccflags=$(EXTRACFLAGS) $(DEFINES) $(BUILDOPT)" \
"usecplusplus=$(USE_CPLUSPLUS)" \
"cf_email=$(EMAIL)" \
"d_mymalloc=$(PERL_MALLOC)" \
diff --git a/win32/makefile.mk b/win32/makefile.mk
index 9d40c6cfc5..d4cfc5cb40 100644
--- a/win32/makefile.mk
+++ b/win32/makefile.mk
@@ -593,8 +593,9 @@ LIBFILES = $(LIBC) -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool \
-luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
.IF "$(CFG)" == "Debug"
-OPTIMIZE = -g -O2 -DDEBUGGING
+OPTIMIZE = -g -O2
LINK_DBG = -g
+DEFINES += -DDEBUGGING
.ELIF "$(CFG)" == "DebugSymbols"
OPTIMIZE = -g -O2
LINK_DBG = -g
@@ -674,6 +675,7 @@ INCLUDES = -I.\include -I. -I..
DEFINES = -DWIN32 -D_CONSOLE -DNO_STRICT
LOCDEFS = -DPERLDLL -DPERL_CORE
CXX_FLAG = -TP -EHsc
+EXTRACFLAGS = -nologo -GF -W3
.IF "$(CCTYPE)" == "MSVC140" || "$(CCTYPE)" == "MSVC141" || "$(CCTYPE)" == "MSVC142"
LIBC = ucrt.lib
@@ -682,22 +684,27 @@ LIBC = msvcrt.lib
.ENDIF
.IF "$(CFG)" == "Debug"
-OPTIMIZE = -Od -MD -Zi -DDEBUGGING
+OPTIMIZE = -Od -Zi
LINK_DBG = -debug
+DEFINES += -DDEBUGGING
+EXTRACFLAGS += -MD
.ELIF "$(CFG)" == "DebugSymbols"
-OPTIMIZE = -Od -MD -Zi
+OPTIMIZE = -Od -Zi
LINK_DBG = -debug
+EXTRACFLAGS += -MD
.ELIF "$(CFG)" == "DebugFull"
.IF "$(CCTYPE)" == "MSVC140" || "$(CCTYPE)" == "MSVC141" || "$(CCTYPE)" == "MSVC142"
LIBC = ucrtd.lib
.ELSE
LIBC = msvcrtd.lib
.ENDIF
-OPTIMIZE = -Od -MDd -Zi -D_DEBUG -DDEBUGGING
+OPTIMIZE = -Od -Zi
LINK_DBG = -debug
+DEFINES += -D_DEBUG -DDEBUGGING
+EXTRACFLAGS += -MDd
.ELSE
# -O1 yields smaller code, which turns out to be faster than -O2 on x86 and x64
-OPTIMIZE = -O1 -MD -Zi -DNDEBUG
+OPTIMIZE = -O1 -Zi
# we enable debug symbols in release builds also
LINK_DBG = -debug -opt:ref,icf
# you may want to enable this if you want COFF symbols in the executables
@@ -706,6 +713,7 @@ LINK_DBG = -debug -opt:ref,icf
# installed to get better stack traces from just the PDB symbols, so we
# avoid the bloat of COFF symbols by default.
#LINK_DBG = $(LINK_DBG) -debugtype:both
+EXTRACFLAGS += -MD
.IF "$(CCTYPE)" != "MSVC60"
# enable Whole Program Optimizations (WPO) and Link Time Code Generation (LTCG)
OPTIMIZE += -GL
@@ -784,7 +792,6 @@ LIBBASEFILES += bufferoverflowU.lib
LIBFILES = $(LIBBASEFILES) $(LIBC)
-EXTRACFLAGS = -nologo -GF -W3
.IF "$(__ICC)" == "define"
EXTRACFLAGS += -Qstd=c99
.ENDIF
@@ -1151,7 +1158,7 @@ CFG_VARS = \
archname=$(ARCHNAME) ~ \
cc=$(CC) ~ \
ld=$(LINK32) ~ \
- ccflags=$(EXTRACFLAGS) $(OPTIMIZE) $(DEFINES) $(BUILDOPT) ~ \
+ ccflags=$(EXTRACFLAGS) $(DEFINES) $(BUILDOPT) ~ \
usecplusplus=$(USE_CPLUSPLUS) ~ \
cf_email=$(EMAIL) ~ \
d_mymalloc=$(PERL_MALLOC) ~ \
--
2.21.0.windows.1
|
Optimization flags don't belong in $Config{ccflags}, while defines and CRT flags don't belong in $Config{optimize}. This change makes overriding optimization flags in Makefile.PL and Build.PL on win32 just as easy as on unix-likes. Additionally, don't define NDEBUG, perl.h already takes care of that. (gh Perl#17156)
Optimization flags don't belong in $Config{ccflags}, while defines and CRT flags don't belong in $Config{optimize}. This change makes overriding optimization flags in Makefile.PL and Build.PL on win32 just as easy as on unix-likes. Additionally, don't define NDEBUG, perl.h already takes care of that. (gh #17156)
Migrated from rt.perl.org#134445 (status was 'open')
Searchable as RT134445$
The text was updated successfully, but these errors were encountered: