[Git][ghc/ghc][wip/fix-link-node-errors] driver: Properly handle errors during LinkNode steps
Matthew Pickering pushed to branch wip/fix-link-node-errors at Glasgow Haskell Compiler / GHC Commits: e8c905e8 by Matthew Pickering at 2025-10-13T12:34:16+01:00 driver: Properly handle errors during LinkNode steps Previously we were not properly catching errors during the LinkNode step (see T9930fail test). This is fixed by wrapping the `LinkNode` action in `wrapAction`, the same handler which is used for module compilation. Fixes #26496 - - - - - 2 changed files: - compiler/GHC/Driver/Make.hs - testsuite/tests/ghc-e/should_fail/T9930fail.stderr Changes: ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -1847,24 +1847,20 @@ Also closely related are -} executeLinkNode :: HomeUnitGraph -> (Int, Int) -> UnitId -> [NodeKey] -> RunMakeM () -executeLinkNode hug kn uid deps = do +executeLinkNode hug kn@(k, _) uid deps = do withCurrentUnit uid $ do - MakeEnv{..} <- ask + make_env@MakeEnv{..} <- ask let dflags = hsc_dflags hsc_env - let hsc_env' = setHUG hug hsc_env msg' = (\messager -> \recomp -> messager hsc_env kn recomp (LinkNode deps uid)) <$> env_messager - linkresult <- liftIO $ withAbstractSem compile_sem $ do - link (ghcLink dflags) - (hsc_logger hsc_env') - (hsc_tmpfs hsc_env') - (hsc_FC hsc_env') - (hsc_hooks hsc_env') - dflags - (hsc_unit_env hsc_env') - True -- We already decided to link - msg' - (hsc_HPT hsc_env') + linkresult <- lift $ MaybeT $ withAbstractSem compile_sem $ withLoggerHsc k make_env $ \lcl_hsc_env -> do + let hsc_env' = setHUG hug lcl_hsc_env + wrapAction diag_wrapper hsc_env' $ do + link (ghcLink dflags) + hsc_env' + True -- We already decided to link + msg' + (hsc_HPT hsc_env') case linkresult of Failed -> fail "Link Failed" Succeeded -> return () ===================================== testsuite/tests/ghc-e/should_fail/T9930fail.stderr ===================================== @@ -1,11 +1,4 @@ -ghc: Uncaught exception ghc-9.13-inplace:GHC.Utils.Panic.GhcException: - -default output name would overwrite the input file; must specify -o explicitly +<no location info>: error: + default output name would overwrite the input file; must specify -o explicitly Usage: For basic information, try the `--help' option. -While handling default output name would overwrite the input file; must specify -o explicitly - | Usage: For basic information, try the `--help' option. - -HasCallStack backtrace: - bracket, called at compiler/GHC/Driver/MakeAction.hs:2955:3 in ghc-9.13-inplace:GHC.Driver.MakeAction - View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e8c905e8fc89e0779857426b02057fdf... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e8c905e8fc89e0779857426b02057fdf... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Matthew Pickering (@mpickering)