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] win32: separate $Config{ccflags} and $Config{optimize} #17156

Closed
p5pRT opened this issue Sep 22, 2019 · 7 comments
Closed

[PATCH] win32: separate $Config{ccflags} and $Config{optimize} #17156

p5pRT opened this issue Sep 22, 2019 · 7 comments

Comments

@p5pRT
Copy link

p5pRT commented Sep 22, 2019

Migrated from rt.perl.org#134445 (status was 'open')

Searchable as RT134445$

@p5pRT
Copy link
Author

p5pRT commented Sep 22, 2019

From @xenu

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.

The patch will be attached to a reply.

perl # circumvent perlbug's spamfilter

@p5pRT
Copy link
Author

p5pRT commented Sep 22, 2019

From @xenu

On Sun, 22 Sep 2019 08​:23​:10 -0700
"Tomasz Konojacki \(via RT\)" <perlbug-followup@​perl.org> wrote​:

# New Ticket Created by Tomasz Konojacki
# Please include the string​: [perl #134445]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=134445 >

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.

The patch will be attached to a reply.

perl # circumvent perlbug's spamfilter

The patch is attached.

@p5pRT
Copy link
Author

p5pRT commented Sep 22, 2019

From @xenu

0001-win32-separate-Config-ccflags-and-Config-optimize.patch
From 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

@p5pRT
Copy link
Author

p5pRT commented Oct 1, 2019

From @tonycoz

On Sun, 22 Sep 2019 08​:29​:38 -0700, me@​xenu.pl wrote​:

On Sun, 22 Sep 2019 08​:23​:10 -0700
"Tomasz Konojacki \(via RT\)" <perlbug-followup@​perl.org> wrote​:

# New Ticket Created by Tomasz Konojacki
# Please include the string​: [perl #134445]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=134445 >

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.

The patch will be attached to a reply.

perl # circumvent perlbug's spamfilter

The patch is attached.

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 -MDd -Zi

-OPTIMIZE = -Od -MD -Zi -DDEBUGGING
+OPTIMIZE = -Od -MD -Zi

Tony

@p5pRT
Copy link
Author

p5pRT commented Oct 1, 2019

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

@p5pRT
Copy link
Author

p5pRT commented Oct 3, 2019

From @xenu

On Tue, 01 Oct 2019 16​:04​:08 -0700
"Tony Cook via RT" <perlbug-followup@​perl.org> 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 -MDd -Zi

-OPTIMIZE = -Od -MD -Zi -DDEBUGGING
+OPTIMIZE = -Od -MD -Zi

Tony

Yes, you're right, I didn't think through the MSVC part of that patch.

V2 is attached.

@p5pRT
Copy link
Author

p5pRT commented Oct 3, 2019

From @xenu

0001-win32-separate-Config-ccflags-and-Config-optimize.patch
From 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

xenu added a commit to xenu/perl5 that referenced this issue Oct 26, 2019
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)
tonycoz pushed a commit that referenced this issue Oct 27, 2019
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)
@tonycoz tonycoz closed this as completed Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants