diff options
author | David Terei <davidterei@gmail.com> | 2011-11-21 03:01:32 -0800 |
---|---|---|
committer | David Terei <davidterei@gmail.com> | 2011-11-21 03:01:32 -0800 |
commit | 11fcb10ad4d3499e60e278752001968134d7f4e4 (patch) | |
tree | 96427df63f64d03f22aa01f18d47d1b6e38b57db /compiler/main/SysTools.lhs | |
parent | f7d99de6d008014722a8b2ab07b521802dea0748 (diff) | |
download | haskell-11fcb10ad4d3499e60e278752001968134d7f4e4.tar.gz |
Fix #5636: Use clang as assembler on OSX when LLVM >= 3.0
LLVM doesn't support the OS X system assembler anymore so we must use
their assembler through clang. Also improved error messages when various
LLVM tools can't be run.
Diffstat (limited to 'compiler/main/SysTools.lhs')
-rw-r--r-- | compiler/main/SysTools.lhs | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/compiler/main/SysTools.lhs b/compiler/main/SysTools.lhs index 1ce34bc12b..00311597d8 100644 --- a/compiler/main/SysTools.lhs +++ b/compiler/main/SysTools.lhs @@ -21,6 +21,7 @@ module SysTools ( runWindres, runLlvmOpt, runLlvmLlc, + runClang, figureLlvmVersion, readElfSection, @@ -473,6 +474,22 @@ runLlvmLlc dflags args = do let (p,args0) = pgm_lc dflags runSomething dflags "LLVM Compiler" p (args0++args) +-- | Run the clang compiler (used as an assembler for the LLVM +-- backend on OS X as LLVM doesn't support the OS X system +-- assembler) +runClang :: DynFlags -> [Option] -> IO () +runClang dflags args = do + -- we simply assume its available on the PATH + let clang = "clang" + Exception.catch (do + runSomething dflags "Clang (Assembler)" clang args + ) + (\(err :: SomeException) -> do + putMsg dflags $ text $ "Error running clang! you need clang installed" + ++ " to use the LLVM backend" + throw err + ) + -- | Figure out which version of LLVM we are running this session figureLlvmVersion :: DynFlags -> IO (Maybe Int) figureLlvmVersion dflags = do @@ -504,9 +521,13 @@ figureLlvmVersion dflags = do return $ Just v ) (\err -> do - putMsg dflags $ text $ "Error (" ++ show err ++ ")" - putMsg dflags $ text "Warning: Couldn't figure out LLVM version!" - putMsg dflags $ text "Make sure you have installed LLVM" + debugTraceMsg dflags 2 + (text "Error (figuring out LLVM version):" <+> + text (show err)) + putMsg dflags $ vcat + [ text "Warning:", nest 9 $ + text "Couldn't figure out LLVM version!" $$ + text "Make sure you have installed LLVM"] return Nothing) return ver |