Skip to content

Commit 10653c1

Browse files
committed
fix: address Copilot review comments on PR #118
- Clarify dependency explanation in GHC.Hs.Instances.Parsed comment - Add DEPRECATED pragma to empty GHC.Hs.Instances.Transitions module - Clarify toRegNo helper comment in Dwarf/Constants.hs as a fallback - Log a message when initializePlugins is skipped (no interpreter) - Fix wrong function name in panic: runHscPhase -> runHscBackendPhase
1 parent 7e3e08e commit 10653c1

5 files changed

Lines changed: 22 additions & 7 deletions

File tree

compiler/GHC/CmmToAsm/Dwarf/Constants.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ import GHC.CmmToAsm.X86.Regs
1818

1919
import Data.Word
2020

21-
-- | Extract register number from a real register
22-
-- This is a local helper to avoid depending on any specific NCG's Regs module
21+
-- | Extract register number from a real register.
22+
-- This is a local, generic fallback used when a platform-specific NCG Regs
23+
-- module is not available (e.g. when that NCG is compiled out). It is not
24+
-- intended to replace backend-specific definitions elsewhere.
2325
toRegNo :: Reg -> RegNo
2426
toRegNo (RegReal (RealRegSingle n)) = n
2527
toRegNo _ = panic "toRegNo: unsupported register"

compiler/GHC/Driver/Main.hs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,16 @@ import qualified GHC.Unit.Home.Graph as HUG
328328
import GHC.Unit.Home.PackageTable
329329

330330
#if !defined(HAVE_INTERPRETER)
331-
-- Stub when interpreter not available
331+
-- Stub when interpreter not available: plugin initialization requires the
332+
-- interpreter to load compiled plugin code, so we skip it in minimal builds.
333+
-- If plugins are specified in the flags but the interpreter is unavailable,
334+
-- they will simply be ignored.
332335
initializePlugins :: HscEnv -> IO HscEnv
333-
initializePlugins = return
336+
initializePlugins hsc_env = do
337+
let logger = hsc_logger hsc_env
338+
logMsg logger MCInfo noSrcSpan $
339+
text "initializePlugins: interpreter not available; skipping plugin initialization"
340+
return hsc_env
334341
#endif
335342

336343
#if !defined(HAVE_JS_BACKEND)

compiler/GHC/Driver/Pipeline/Execute.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ runHscBackendPhase pipe_env hsc_env mod_name src_flavour location result = do
636636
bc <- generateFreshByteCode hsc_env mod_name (mkCgInteractiveGuts cgguts) mod_location
637637
return ([], final_iface, emptyHomeModInfoLinkable { homeMod_bytecode = Just bc } , panic "interpreter")
638638
#else
639-
panic "GHC.Driver.Pipeline.Execute.runHscPhase: bytecode generation not supported (HAVE_INTERPRETER not defined)"
639+
panic "GHC.Driver.Pipeline.Execute.runHscBackendPhase: bytecode generation not supported (HAVE_INTERPRETER not defined)"
640640
#endif
641641

642642

compiler/GHC/Hs/Instances/Parsed.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
-- NO transitive dependencies on HsExpr, HsBindLR, HsLocalBinds, HsUntypedSplice,
1111
-- or HsType (which contains HsSpliceTy -> HsUntypedSplice -> HsExpr).
1212
--
13-
-- Most GhcPs instances are in Renamed.hs because of the hard-coded [LSig GhcRn]
14-
-- in NHsValBindsLR which creates: HsExpr -> HsLocalBinds -> NHsValBindsLR -> [LSig GhcRn]
13+
-- Most GhcPs instances are in Renamed.hs because NHsValBindsLR (used by
14+
-- HsLocalBinds inside HsExpr) has a field of type [LSig GhcRn]. Any Data
15+
-- instance for NHsValBindsLR GhcPs would therefore mention GhcRn, so those
16+
-- instances must live in Renamed.hs to avoid cyclic module dependencies.
1517
--
1618
-- Additionally, HsType GhcPs contains HsSpliceTy which uses HsUntypedSplice GhcPs,
1719
-- and HsUntypedSplice contains HsExpr, so HsType and all types containing it must

compiler/GHC/Hs/Instances/Transitions.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@
1616
-- parameter which determines which phase-specific types they need.
1717
--
1818
-- This module is kept for backwards compatibility and re-exports nothing.
19+
-- It should not be imported in new code; it exists only so that existing
20+
-- imports do not break. Consider removing it once all downstream consumers
21+
-- have been updated.
1922
--
2023
-- See #9557 and #18254 for why we use -O0.
2124
{-# OPTIONS_GHC -O0 #-}
25+
{-# DEPRECATED "This module is empty; import the phase-specific GHC.Hs.Instances.* modules instead." #-}
2226

2327
module GHC.Hs.Instances.Transitions where
2428

0 commit comments

Comments
 (0)