From a3b0f2b2cff8babbb85cbbe1e7515905ffb444a8 Mon Sep 17 00:00:00 2001
From: "klebinger.andreas@gmx.at" <klebinger.andreas@gmx.at>
Date: Sat, 16 Jun 2018 12:37:41 -0400
Subject: [PATCH] Set -O2 via NoFibHcOpts instead of individual Makefiles.

We set -O2 in NoFibHcOpts which is then applied to all benchmarks run.

Adding -O2 in individual benchmarks is therefore redundant.
It also leads to issues when testing performance flags via
EXTRA_HC_OPTS.
Individual Makefiles attach -O2 last. This means all
flags set by -O2 could not be disabled with -fno-<flag> as they
were reenabled by the later -O2 switch.

Test Plan: Using

Reviewers: bgamari, jmct, O26 nofib

Differential Revision: https://phabricator.haskell.org/D4829
---
 real/eff/S/Makefile                  | 2 +-
 shootout/binary-trees/Makefile       | 2 +-
 shootout/fannkuch-redux/Makefile     | 3 ++-
 shootout/fasta/Makefile              | 2 +-
 shootout/k-nucleotide/Makefile       | 2 +-
 shootout/n-body/Makefile             | 2 +-
 shootout/pidigits/Makefile           | 1 -
 shootout/reverse-complement/Makefile | 2 +-
 shootout/spectral-norm/Makefile      | 2 +-
 smp/threads005/Main.hs               | 2 --
 smp/threads006/Main.hs               | 1 -
 11 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/real/eff/S/Makefile b/real/eff/S/Makefile
index dd62b77a..50c3e71c 100644
--- a/real/eff/S/Makefile
+++ b/real/eff/S/Makefile
@@ -1,7 +1,7 @@
 TOP = ../../..
 include $(TOP)/mk/boilerplate.mk
 
-SRC_HC_OPTS += -fglasgow-exts -package transformers -package mtl -O2
+SRC_HC_OPTS += -fglasgow-exts -package transformers -package mtl
 
 include $(TOP)/mk/target.mk
 
diff --git a/shootout/binary-trees/Makefile b/shootout/binary-trees/Makefile
index 8a27f6dc..6d944e8e 100644
--- a/shootout/binary-trees/Makefile
+++ b/shootout/binary-trees/Makefile
@@ -8,5 +8,5 @@ SLOW_OPTS = 20  # official shootout setting
 
 # The benchmark game also uses -fllvm, which we can't since it might
 # not be available on the developer's machine.
-HC_OPTS += -XBangPatterns -O2 -funbox-strict-fields
+HC_OPTS += -XBangPatterns -funbox-strict-fields
 SRC_RUNTEST_OPTS += +RTS -K128M -H -RTS
diff --git a/shootout/fannkuch-redux/Makefile b/shootout/fannkuch-redux/Makefile
index facb2620..729955fc 100644
--- a/shootout/fannkuch-redux/Makefile
+++ b/shootout/fannkuch-redux/Makefile
@@ -8,4 +8,5 @@ SLOW_OPTS = 12  # official shootout setting
 
 # The benchmark game also uses -fllvm, which we can't since it might
 # not be available on the developer's machine.
-HC_OPTS += -XBangPatterns -O2
+HC_OPTS += -XBangPatterns
+
diff --git a/shootout/fasta/Makefile b/shootout/fasta/Makefile
index 97a8b179..e61f95c8 100644
--- a/shootout/fasta/Makefile
+++ b/shootout/fasta/Makefile
@@ -13,7 +13,7 @@ SLOW_OPTS = 25000000  # official shootout setting
 
 # The benchmark game also uses -fllvm, which we can't since it might
 # not be available on the developer's machine.
-HC_OPTS += -O2 -XBangPatterns -XOverloadedStrings -package bytestring
+HC_OPTS += -XBangPatterns -XOverloadedStrings -package bytestring
 
 #------------------------------------------------------------------
 # Create output to validate against
diff --git a/shootout/k-nucleotide/Makefile b/shootout/k-nucleotide/Makefile
index a37cbadd..8e1e7144 100644
--- a/shootout/k-nucleotide/Makefile
+++ b/shootout/k-nucleotide/Makefile
@@ -9,7 +9,7 @@ SLOW_OPTS = 25000000  # official shootout setting
 
 # The benchmark game also uses -fllvm, which we can't since it might
 # not be available on the developer's machine.
-HC_OPTS += -O2 -XBangPatterns -package bytestring
+HC_OPTS += -XBangPatterns -package bytestring
 
 #------------------------------------------------------------------
 # Create input
diff --git a/shootout/n-body/Makefile b/shootout/n-body/Makefile
index 1ea0b09e..22908263 100644
--- a/shootout/n-body/Makefile
+++ b/shootout/n-body/Makefile
@@ -8,4 +8,4 @@ SLOW_OPTS = 50000000  # official shootout setting
 
 # The benchmark game also uses -fllvm, which we can't since it might
 # not be available on the developer's machine.
-HC_OPTS += -O2 -XBangPatterns -fexcess-precision
+HC_OPTS += -XBangPatterns -fexcess-precision
diff --git a/shootout/pidigits/Makefile b/shootout/pidigits/Makefile
index fa2edca0..fb3fc937 100644
--- a/shootout/pidigits/Makefile
+++ b/shootout/pidigits/Makefile
@@ -8,4 +8,3 @@ SLOW_OPTS = 10000  # official shootout setting
 
 # The benchmark game also uses -fllvm, which we can't since it might
 # not be available on the developer's machine.
-HC_OPTS += -O2
diff --git a/shootout/reverse-complement/Makefile b/shootout/reverse-complement/Makefile
index c165f2ff..0b51e163 100644
--- a/shootout/reverse-complement/Makefile
+++ b/shootout/reverse-complement/Makefile
@@ -13,7 +13,7 @@ SLOW_OPTS = 25000000  # official shootout setting
 
 # The benchmark game also uses -fllvm, which we can't since it might
 # not be available on the developer's machine.
-HC_OPTS += -O2 -XBangPatterns -funfolding-use-threshold=32 -XMagicHash \
+HC_OPTS += -XBangPatterns -funfolding-use-threshold=32 -XMagicHash \
 	-XUnboxedTuples
 
 #------------------------------------------------------------------
diff --git a/shootout/spectral-norm/Makefile b/shootout/spectral-norm/Makefile
index fd5dbfb7..a0728d93 100644
--- a/shootout/spectral-norm/Makefile
+++ b/shootout/spectral-norm/Makefile
@@ -8,4 +8,4 @@ SLOW_OPTS = 5500  # official shootout setting
 
 # The benchmark game also uses -fllvm, which we can't since it might
 # not be available on the developer's machine.
-HC_OPTS += -XBangPatterns -XMagicHash -O2 -fexcess-precision
+HC_OPTS += -XBangPatterns -XMagicHash -fexcess-precision
diff --git a/smp/threads005/Main.hs b/smp/threads005/Main.hs
index 970b3e17..24bb719a 100644
--- a/smp/threads005/Main.hs
+++ b/smp/threads005/Main.hs
@@ -1,5 +1,3 @@
-{-# OPTIONS_GHC -O2 #-}
-
 -- Program from GHC ticket #1589, to test scaling of the RTS with many threads.
 
 {-
diff --git a/smp/threads006/Main.hs b/smp/threads006/Main.hs
index 565213c4..c92e312c 100644
--- a/smp/threads006/Main.hs
+++ b/smp/threads006/Main.hs
@@ -1,4 +1,3 @@
-{-# OPTIONS_GHC -O2 #-}
 import System.IO
 import System.Environment
 import System.CPUTime
-- 
GitLab