Skip to content

Commit 927b8fe

Browse files
committed
Cabal: Disable GHCi libraries on Windows with GHC >=9.4
As noted in GHC #21068, the lld linker used on Windows by GHC 9.4 and later does not support object merging. Consequently, --enable-library-for-ghci can no longer be supported on this platform.
1 parent d638e33 commit 927b8fe

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

Cabal/src/Distribution/Simple/Configure.hs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,22 @@ configure (pkg_descr0, pbi) cfg = do
635635
"--enable-split-objs; ignoring")
636636
return False
637637

638+
let compilerSupportsGhciLibs :: Bool
639+
compilerSupportsGhciLibs =
640+
case compilerId comp of
641+
CompilerId GHC version
642+
| version > mkVersion [9,3] && windows ->
643+
False
644+
CompilerId GHC _ ->
645+
True
646+
CompilerId GHCJS _ ->
647+
True
648+
_ -> False
649+
where
650+
windows = case compPlatform of
651+
Platform _ Windows -> True
652+
Platform _ _ -> False
653+
638654
let ghciLibByDefault =
639655
case compilerId comp of
640656
CompilerId GHC _ ->
@@ -651,6 +667,15 @@ configure (pkg_descr0, pbi) cfg = do
651667
not (GHCJS.isDynamic comp)
652668
_ -> False
653669

670+
withGHCiLib_ <-
671+
case fromFlagOrDefault ghciLibByDefault (configGHCiLib cfg) of
672+
True | not compilerSupportsGhciLibs -> do
673+
warn verbosity $
674+
"--enable-library-for-ghci is no longer supported on Windows with"
675+
++ "GHC 9.4 and later; ignoring..."
676+
return False
677+
v -> return v
678+
654679
let sharedLibsByDefault
655680
| fromFlag (configDynExe cfg) =
656681
-- build a shared library if dynamically-linked
@@ -747,8 +772,7 @@ configure (pkg_descr0, pbi) cfg = do
747772
withProfExeDetail = ProfDetailNone,
748773
withOptimization = fromFlag $ configOptimization cfg,
749774
withDebugInfo = fromFlag $ configDebugInfo cfg,
750-
withGHCiLib = fromFlagOrDefault ghciLibByDefault $
751-
configGHCiLib cfg,
775+
withGHCiLib = withGHCiLib_,
752776
splitSections = split_sections,
753777
splitObjs = split_objs,
754778
stripExes = strip_exe,

0 commit comments

Comments
 (0)