Commit 41db237e authored by Oleg Grenrus's avatar Oleg Grenrus Committed by Ben Gamari

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:
parent a3986d7f
......@@ -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 ()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment