From 4915e566cb661aa934e133c7c9b21c0d1964490a Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Sun, 1 May 2011 16:19:06 +0100 Subject: [PATCH] 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. --- compiler/main/CodeOutput.lhs | 3 +-- compiler/main/DynFlags.hs | 25 +++++++++++++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) 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 -- 1.7.10.4