This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
gcc 4.9 by default does some optimizations that break perl (#121505)
authorH.Merijn Brand - Tux <h.m.brand@xs4all.nl>
Wed, 9 Apr 2014 08:57:21 +0000 (10:57 +0200)
committerH.Merijn Brand - Tux <h.m.brand@xs4all.nl>
Wed, 9 Apr 2014 08:57:21 +0000 (10:57 +0200)
Patch by Tony Cook

U/perl/gccvers.U

index 5e93d3a..d3acc8f 100644 (file)
@@ -39,6 +39,7 @@
 ?LINT:extern ccname
 ?LINT:change ccname
 ?LINT:change locincpth
+?LINT:change ccflags
 ?LINT:set gccansipedantic
 ?X: Check if they have gcc in any guise.
 : Check if we are using GNU gcc and what its version is
@@ -131,3 +132,19 @@ case "$gccversion" in
     $rm -f try try.*
 esac
 
+# gcc 4.9 by default does some optimizations that break perl.
+# see ticket 121505.
+#
+# The -fwrapv disables those optimizations (and probably others,) so
+# for gcc 4.9 (and later, since the optimizations probably won't go
+# away), add -fwrapv unless the user requests -fno-wrapv, which
+# disables -fwrapv, or if the user requests -fsanitize=undefined,
+# which turns the overflows -fwrapv ignores into runtime errors.
+case "$gccversion" in
+4.9.*|4.1[0-9].*|[5-9].*)
+    case "$ccflags" in
+    *-fno-wrapv*|*-fsanitize=undefined*|*-fwrapv*) ;;
+    *) ccflags="$ccflags -fwrapv" ;;
+    esac
+esac
+