From: Ian Lynagh Date: Sun, 1 May 2011 15:19:06 +0000 (+0100) Subject: Ignore requests to use backends that aren't available; fixes #5145 X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=4915e566cb661aa934e133c7c9b21c0d1964490a Ignore requests to use backends that aren't available; fixes #5145 Now if you try to use "-fasm" with an unreg compiler, for example, you just get a warning saying it's being ignored. --- diff --git a/compiler/main/CodeOutput.lhs b/compiler/main/CodeOutput.lhs index 7cfc2e9..f5e3394 100644 --- a/compiler/main/CodeOutput.lhs +++ b/compiler/main/CodeOutput.lhs @@ -156,8 +156,7 @@ outputAsm dflags filenm flat_absC nativeCodeGen dflags f ncg_uniqs flat_absC | otherwise - = pprPanic "This compiler was built without a native code generator" - (text "Use -fvia-C instead") + = panic "This compiler was built without a native code generator" \end{code} diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index c7e0465..7e15aa4 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -2039,11 +2039,28 @@ setTarget l = upd set -- not from bytecode to object-code. The idea is that -fasm/-fllvm -- can be safely used in an OPTIONS_GHC pragma. setObjTarget :: HscTarget -> DynP () -setObjTarget l = upd set +setObjTarget l = updM set where - set dfs - | isObjectTarget (hscTarget dfs) = dfs { hscTarget = l } - | otherwise = dfs + set dflags + | isObjectTarget (hscTarget dflags) + = case l of + HscC + | cGhcUnregisterised /= "YES" -> + do addWarn ("Compiler not unregisterised, so ignoring " ++ + showHscTargetFlag l) + return dflags + HscAsm + | cGhcWithNativeCodeGen /= "YES" -> + do addWarn ("Compiler has no native codegen, so ignoring " ++ + showHscTargetFlag l) + return dflags + HscLlvm + | cGhcUnregisterised == "YES" -> + do addWarn ("Compiler unregisterised, so ignoring " ++ + showHscTargetFlag l) + return dflags + _ -> return $ dflags { hscTarget = l } + | otherwise = return dflags setOptLevel :: Int -> DynFlags -> DynP DynFlags setOptLevel n dflags