@@ -76,7 +76,7 @@ import Distribution.Simple.Program
76
76
import Distribution.Simple.Setup as Setup
77
77
import Distribution.Simple.BuildTarget
78
78
import Distribution.Simple.LocalBuildInfo
79
- import Distribution.Simple.Program.Db (appendProgramSearchPath , modifyProgramSearchPath )
79
+ import Distribution.Simple.Program.Db (appendProgramSearchPath , modifyProgramSearchPath , lookupProgramByName )
80
80
import Distribution.Simple.Utils
81
81
import Distribution.System
82
82
import Distribution.Types.PackageVersionConstraint
@@ -102,7 +102,8 @@ import qualified Distribution.Simple.HaskellSuite as HaskellSuite
102
102
import Control.Exception
103
103
( try )
104
104
import Distribution.Utils.Structured ( structuredDecodeOrFailIO , structuredEncode )
105
- import Distribution.Compat.Directory ( listDirectory )
105
+ import Distribution.Compat.Directory
106
+ ( listDirectory , doesPathExist )
106
107
import Data.ByteString.Lazy ( ByteString )
107
108
import qualified Data.ByteString as BS
108
109
import qualified Data.ByteString.Lazy.Char8 as BLC8
@@ -115,8 +116,6 @@ import System.Directory
115
116
, getTemporaryDirectory , removeFile )
116
117
import System.FilePath
117
118
( (</>) , isAbsolute , takeDirectory )
118
- import Distribution.Compat.Directory
119
- ( doesPathExist )
120
119
import qualified System.Info
121
120
( compilerName , compilerVersion )
122
121
import System.IO
@@ -639,21 +638,16 @@ configure (pkg_descr0, pbi) cfg = do
639
638
" --enable-split-objs; ignoring" )
640
639
return False
641
640
642
- let compilerSupportsGhciLibs :: Bool
643
- compilerSupportsGhciLibs =
644
- case compilerId comp of
645
- CompilerId GHC version
646
- | version > mkVersion [9 ,3 ] && windows ->
647
- False
648
- CompilerId GHC _ ->
649
- True
650
- CompilerId GHCJS _ ->
651
- True
652
- _ -> False
653
- where
654
- windows = case compPlatform of
655
- Platform _ Windows -> True
656
- Platform _ _ -> False
641
+ -- Basically yes/no/unknown.
642
+ let linkerSupportsRelocations :: Maybe Bool
643
+ linkerSupportsRelocations =
644
+ case lookupProgramByName " ld" programDb'' of
645
+ Nothing -> Nothing
646
+ Just ld ->
647
+ case Map. lookup " Supports relocatable output" $ programProperties ld of
648
+ Just " YES" -> Just True
649
+ Just " NO" -> Just False
650
+ _other -> Nothing
657
651
658
652
let ghciLibByDefault =
659
653
case compilerId comp of
@@ -673,10 +667,12 @@ configure (pkg_descr0, pbi) cfg = do
673
667
674
668
withGHCiLib_ <-
675
669
case fromFlagOrDefault ghciLibByDefault (configGHCiLib cfg) of
676
- True | not compilerSupportsGhciLibs -> do
670
+ -- NOTE: If linkerSupportsRelocations is Nothing this may still fail if the
671
+ -- linker does not support -r.
672
+ True | not (fromMaybe True linkerSupportsRelocations) -> do
677
673
warn verbosity $
678
- " --enable-library-for-ghci is no longer supported on Windows with "
679
- ++ " GHC 9.4 and later ; ignoring..."
674
+ " --enable-library-for-ghci is not supported with the current "
675
+ ++ " linker ; ignoring..."
680
676
return False
681
677
v -> return v
682
678
@@ -951,11 +947,11 @@ dependencySatisfiable
951
947
then internalDepSatisfiable
952
948
else
953
949
-- Backward compatibility for the old sublibrary syntax
954
- ( sublibs == mainLibSet
950
+ sublibs == mainLibSet
955
951
&& Map. member
956
952
(pn, CLibName $ LSubLibName $
957
953
packageNameToUnqualComponentName depName)
958
- requiredDepsMap)
954
+ requiredDepsMap
959
955
960
956
|| all visible sublibs
961
957
@@ -982,7 +978,7 @@ dependencySatisfiable
982
978
internalDepSatisfiable =
983
979
Set. isSubsetOf (NES. toSet sublibs) packageLibraries
984
980
internalDepSatisfiableExternally =
985
- all (\ ln -> not $ null $ PackageIndex. lookupInternalDependency installedPackageSet pn vr ln ) sublibs
981
+ all (not . null . PackageIndex. lookupInternalDependency installedPackageSet pn vr) sublibs
986
982
987
983
-- Check whether a library exists and is visible.
988
984
-- We don't disambiguate between dependency on non-existent or private
@@ -1451,8 +1447,7 @@ getInstalledPackagesMonitorFiles verbosity comp packageDBs progdb platform =
1451
1447
-- flag into a single package db stack.
1452
1448
--
1453
1449
interpretPackageDbFlags :: Bool -> [Maybe PackageDB ] -> PackageDBStack
1454
- interpretPackageDbFlags userInstall specificDBs =
1455
- extra initialStack specificDBs
1450
+ interpretPackageDbFlags userInstall = extra initialStack
1456
1451
where
1457
1452
initialStack | userInstall = [GlobalPackageDB , UserPackageDB ]
1458
1453
| otherwise = [GlobalPackageDB ]
@@ -1698,8 +1693,8 @@ ccLdOptionsBuildInfo cflags ldflags ldflags_static =
1698
1693
let (includeDirs', cflags') = partition (" -I" `isPrefixOf` ) cflags
1699
1694
(extraLibs', ldflags') = partition (" -l" `isPrefixOf` ) ldflags
1700
1695
(extraLibDirs', ldflags'') = partition (" -L" `isPrefixOf` ) ldflags'
1701
- ( extraLibsStatic') = filter (" -l" `isPrefixOf` ) ldflags_static
1702
- ( extraLibDirsStatic') = filter (" -L" `isPrefixOf` ) ldflags_static
1696
+ extraLibsStatic' = filter (" -l" `isPrefixOf` ) ldflags_static
1697
+ extraLibDirsStatic' = filter (" -L" `isPrefixOf` ) ldflags_static
1703
1698
in mempty {
1704
1699
includeDirs = map (drop 2 ) includeDirs',
1705
1700
extraLibs = map (drop 2 ) extraLibs',
0 commit comments