Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 6c91582f by Matthew Pickering at 2025-11-11T11:48:12-05: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 - - - - - 3 changed files: - compiler/GHC/Driver/Make.hs - testsuite/tests/ghc-e/should_fail/T9930fail.stderr - testsuite/tests/ghc-e/should_fail/all.T Changes: ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -1851,24 +1851,25 @@ 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_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') 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 - ===================================== testsuite/tests/ghc-e/should_fail/all.T ===================================== @@ -15,10 +15,8 @@ test('ghc-e-fail2', req_interp, makefile_test, ['ghc-e-fail2']) test('T9930fail', [extra_files(['T9930']), when(opsys('mingw32'), skip), - normalise_errmsg_fun(lambda s: normalise_version_("ghc")(s).replace('ghc-<VERSION>-<HASH>','ghc')), - # broken for JS until cross-compilers become stage2 compilers (#19174) - # or until we bootstrap with a 9.10 compiler - js_broken(19174)], + normalise_errmsg_fun(lambda s: normalise_version_("ghc")(s).replace('ghc-<VERSION>-<HASH>','ghc')) + ], makefile_test, ['T9930fail']) test('T18441fail0', req_interp, makefile_test, ['T18441fail0']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6c91582f915f80daff774db7738094bd... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6c91582f915f80daff774db7738094bd... You're receiving this email because of your account on gitlab.haskell.org.