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

# Tomasz Konojacki <...@xen...>

Sun, 22 Sep 2019 08:23:10 -0700
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

# Tomasz Konojacki <...@xen...>

Sun, 22 Sep 2019 08:29:38 -0700
On Sun, 22 Sep 2019 08:23:10 -0700 "Tomasz Konojacki \(via RT\)" <[email protected]> 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.perl.org/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.
From 07dd43c03772f30d576adb42ea7bb9b05037368f Mon Sep 17 00:00:00 2001 From: Tomasz Konojacki <[email protected]> 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

# Tony Cook <...@dev...>

Tue, 01 Oct 2019 16:04:07 -0700
On Sun, 22 Sep 2019 08:29:38 -0700, [email protected] wrote: > On Sun, 22 Sep 2019 08:23:10 -0700 > "Tomasz Konojacki \(via RT\)" <[email protected]> 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.perl.org/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

# The RT System itself <>

Tue, 01 Oct 2019 16:04:07 -0700
Status changed from new to open.

# Tomasz Konojacki <...@xen...>

Thu, 03 Oct 2019 04:36:51 -0700
On Tue, 01 Oct 2019 16:04:08 -0700 "Tony Cook via RT" <[email protected]> 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.
From f61865ec7b1bdff621c982fc300e3349574d2be5 Mon Sep 17 00:00:00 2001 From: Tomasz Konojacki <[email protected]> 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