[commit: ghc] master: Only add -O to C compilations if there was -O on the command line (d060837)

git at git.haskell.org git at git.haskell.org
Thu Aug 22 12:35:40 CEST 2013


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/d06083739a310c36e9e6dc82107c8c4b03210e56/ghc

>---------------------------------------------------------------

commit d06083739a310c36e9e6dc82107c8c4b03210e56
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Thu Aug 22 10:53:53 2013 +0100

    Only add -O to C compilations if there was -O on the command line
    
    In 1e2b3780ebc40d28cd0f029b90df102df09e6827 I changed the option
    ordering for C compilations.  A side effect was that -optc options
    came before the automatic -O we were adding, which made it so that the
    -debug RTS was getting optimised when it shouldn't have been.
    
    Perhaps we shouldn't have automatic -O options added to C
    compilations.  But that might cause problems for build systems that
    are relying on the current behaviour, so I've made a minor change
    instead: now C optimisation level == Haskell optimisation level.


>---------------------------------------------------------------

d06083739a310c36e9e6dc82107c8c4b03210e56
 compiler/main/DriverPipeline.hs |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index c5bcdc7..c005a46 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -1116,8 +1116,9 @@ runPhase (RealPhase cc_phase) input_fn dflags
             split_opt | hcc && split_objs = [ "-DUSE_SPLIT_MARKERS" ]
                       | otherwise         = [ ]
 
-        let cc_opt | optLevel dflags >= 2 = "-O2"
-                   | otherwise            = "-O"
+        let cc_opt | optLevel dflags >= 2 = [ "-O2" ]
+                   | optLevel dflags >= 1 = [ "-O" ]
+                   | otherwise            = []
 
         -- Decide next phase
         let next_phase = As
@@ -1187,7 +1188,8 @@ runPhase (RealPhase cc_phase) input_fn dflags
                              then gcc_extra_viac_flags ++ more_hcc_opts
                              else [])
                        ++ verbFlags
-                       ++ [ "-S", cc_opt ]
+                       ++ [ "-S" ]
+                       ++ cc_opt
                        ++ [ "-D__GLASGOW_HASKELL__="++cProjectVersionInt ]
                        ++ framework_paths
                        ++ split_opt





More information about the ghc-commits mailing list