[commit: ghc] master: llvmGen: Pass -optlo flags last to opt (41db237)

git at git.haskell.org git at git.haskell.org
Mon Mar 26 00:59:36 UTC 2018


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

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

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

commit 41db237e1290b650e52eb07323eca71de941e184
Author: Oleg Grenrus <oleg.grenrus at iki.fi>
Date:   Sun Mar 25 20:13:18 2018 -0400

    llvmGen: Pass -optlo flags last to opt
    
    LLVM, like GHC, processes flags in the order that they appear.
    Consequently, we need to ensure the user-provided flags appear last so
    they can override flags produced by GHC. See #14821.
    
    Test Plan: `ghc -O2 -optlo-O2 -v3 $FILE` and ensure that `opt` and `llc`
    are invoked with `-O2`.
    
    Subscribers: rwbarton, thomie, carter
    
    GHC Trac Issues: #14821
    
    Differential Revision: https://phabricator.haskell.org/D4421


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

41db237e1290b650e52eb07323eca71de941e184
 compiler/main/SysTools/Tasks.hs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/compiler/main/SysTools/Tasks.hs b/compiler/main/SysTools/Tasks.hs
index 82560af..66cc1ec 100644
--- a/compiler/main/SysTools/Tasks.hs
+++ b/compiler/main/SysTools/Tasks.hs
@@ -147,7 +147,9 @@ runLlvmOpt :: DynFlags -> [Option] -> IO ()
 runLlvmOpt dflags args = do
   let (p,args0) = pgm_lo dflags
       args1 = map Option (getOpts dflags opt_lo)
-  runSomething dflags "LLVM Optimiser" p (args0 ++ args1 ++ args)
+      -- We take care to pass -optlo flags (e.g. args0) last to ensure that the
+      -- user can override flags passed by GHC. See #14821.
+  runSomething dflags "LLVM Optimiser" p (args1 ++ args ++ args0)
 
 -- | Run the LLVM Compiler
 runLlvmLlc :: DynFlags -> [Option] -> IO ()



More information about the ghc-commits mailing list