summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleg Grenrus <oleg.grenrus@iki.fi>2018-03-25 20:13:18 -0400
committerBen Gamari <ben@smart-cactus.org>2018-03-25 20:58:10 -0400
commit41db237e1290b650e52eb07323eca71de941e184 (patch)
tree4529408d0eeac8dccbf8e79d146786f13b1da4df
parenta3986d7fa59d96a77ac0f25bcf1dcf96b8746994 (diff)
downloadhaskell-41db237e1290b650e52eb07323eca71de941e184.tar.gz
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
-rw-r--r--compiler/main/SysTools/Tasks.hs4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/main/SysTools/Tasks.hs b/compiler/main/SysTools/Tasks.hs
index 82560af006..66cc1ec1b2 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 ()