Skip to content

Commit c8180b0

Browse files
committed
[perl #121505] include -fwrapv by default for GCC 4.3 and later
1 parent f78f6d1 commit c8180b0

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

win32/makefile.mk

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ USE_LARGE_FILES *= define
140140
# MinGW or mingw-w64 with gcc-3.2 or later
141141
CCTYPE *= GCC
142142

143+
#
144+
# If you are using GCC, 4.3 or later by default we add the -fwrapv option.
145+
# See https://rt.perl.org/Ticket/Display.html?id=121505
146+
#
147+
#GCCWRAPV *= define
148+
143149
#
144150
# If you are using Intel C++ Compiler uncomment this
145151
#
@@ -408,6 +414,8 @@ INST_HTML = $(INST_TOP)$(INST_VER)\html
408414

409415
.USESHELL :
410416

417+
MINIBUILDOPT *=
418+
411419
.IF "$(CCTYPE)" == "GCC"
412420

413421
.IF "$(GCCCROSS)" == "define"
@@ -420,6 +428,13 @@ LIB32 = $(ARCHPREFIX)ar rc
420428
IMPLIB = $(ARCHPREFIX)dlltool
421429
RSC = $(ARCHPREFIX)windres
422430

431+
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))
432+
433+
.IF "$(GCCWRAPV)" == "define"
434+
BUILDOPT += -fwrapv
435+
MINIBUILDOPT += -fwrapv
436+
.ENDIF
437+
423438
i = .i
424439
o = .o
425440
a = .a
@@ -1139,10 +1154,10 @@ $(MINIDIR) :
11391154
if not exist "$(MINIDIR)" mkdir "$(MINIDIR)"
11401155

11411156
$(MINICORE_OBJ) : $(CORE_NOCFG_H)
1142-
$(CC) -c $(CFLAGS) -DPERL_EXTERNAL_GLOB -DPERL_IS_MINIPERL $(OBJOUT_FLAG)$@ ..\$(*B).c
1157+
$(CC) -c $(CFLAGS) $(MINIBUILDOPT) -DPERL_EXTERNAL_GLOB -DPERL_IS_MINIPERL $(OBJOUT_FLAG)$@ ..\$(*B).c
11431158

11441159
$(MINIWIN32_OBJ) : $(CORE_NOCFG_H)
1145-
$(CC) -c $(CFLAGS) -DPERL_IS_MINIPERL $(OBJOUT_FLAG)$@ $(*B).c
1160+
$(CC) -c $(CFLAGS) $(MINIBUILDOPT) -DPERL_IS_MINIPERL $(OBJOUT_FLAG)$@ $(*B).c
11461161

11471162
# -DPERL_IMPLICIT_SYS needs C++ for perllib.c
11481163
# rules wrapped in .IFs break Win9X build (we end up with unbalanced []s unless

0 commit comments

Comments
 (0)