diff options
author | Daniel Gröber <dxld@darkboxed.org> | 2019-05-25 13:57:45 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-05-30 16:44:08 -0400 |
commit | 99e7276982fe41dca0098e37a9cbf71091c3e275 (patch) | |
tree | 92f37e76956e161696926ea65c32505f2f56244d /compiler/main/GhcMake.hs | |
parent | 18d3f01d9abe2994b2b3d07b67ee9616c3553e16 (diff) | |
download | haskell-99e7276982fe41dca0098e37a9cbf71091c3e275.tar.gz |
Catch preprocessor errors in downsweep
This changes the way preprocessor failures are presented to the
user. Previously the user would simply get an unlocated message on stderr
such as:
`gcc' failed in phase `C pre-processor'. (Exit code: 1)
Now at the problematic source file is mentioned:
A.hs:1:1: error:
`gcc' failed in phase `C pre-processor'. (Exit code: 1)
This also makes live easier for GHC API clients as the preprocessor error
is now thrown as a SourceError exception.
Diffstat (limited to 'compiler/main/GhcMake.hs')
-rw-r--r-- | compiler/main/GhcMake.hs | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/compiler/main/GhcMake.hs b/compiler/main/GhcMake.hs index 341356f775..f3a1cfaaca 100644 --- a/compiler/main/GhcMake.hs +++ b/compiler/main/GhcMake.hs @@ -2489,19 +2489,6 @@ getObjTimestamp location is_boot = if is_boot == IsBoot then return Nothing else modificationTimeIfExists (ml_obj_file location) - -preprocessFile :: HscEnv - -> FilePath - -> Maybe Phase -- ^ Starting phase - -> Maybe (StringBuffer,UTCTime) - -> IO (DynFlags, FilePath, StringBuffer) -preprocessFile hsc_env src_fn mb_phase maybe_buf - = do - (dflags', hspp_fn) - <- preprocess hsc_env src_fn (fst <$> maybe_buf) mb_phase - buf <- hGetStringBuffer hspp_fn - return (dflags', hspp_fn, buf) - data PreprocessedImports = PreprocessedImports { pi_local_dflags :: DynFlags @@ -2523,8 +2510,8 @@ getPreprocessedImports -> ExceptT ErrorMessages IO PreprocessedImports getPreprocessedImports hsc_env src_fn mb_phase maybe_buf = do (pi_local_dflags, pi_hspp_fn) - <- liftIO $ preprocess hsc_env src_fn (fst <$> maybe_buf) mb_phase - pi_hscpp_buf <- liftIO $ hGetStringBuffer pi_hspp_fn + <- ExceptT $ preprocess hsc_env src_fn (fst <$> maybe_buf) mb_phase + pi_hspp_buf <- liftIO $ hGetStringBuffer pi_hspp_fn (pi_srcimps, pi_theimps, L pi_mod_name_loc pi_mod_name) <- ExceptT $ getImports pi_local_dflags pi_hspp_buf pi_hspp_fn src_fn return PreprocessedImports {..} |