Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Cabal-syntax/Cabal-syntax.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ library
-Wincomplete-uni-patterns
-Wincomplete-record-updates
-Wno-unticked-promoted-constructors

if impl(ghc >= 8.0)
ghc-options: -Wcompat -Wnoncanonical-monad-instances
-Wcompat
-Wnoncanonical-monad-instances

if impl(ghc >= 8.0) && impl(ghc < 8.8)
ghc-options: -Wnoncanonical-monadfail-instances
Expand Down
4 changes: 2 additions & 2 deletions Cabal/src/Distribution/Simple/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ createInternalPackageDB
createInternalPackageDB verbosity lbi distPref = do
existsAlready <- doesPackageDBExist dbPath
when existsAlready $ deletePackageDB dbPath
createPackageDB verbosity (compiler lbi) (withPrograms lbi) False dbPath
createPackageDB verbosity (compiler lbi) (withPrograms lbi) dbPath
return (SpecificPackageDB dbRelPath)
where
dbRelPath = internalPackageDBPath lbi distPref
Expand Down Expand Up @@ -1188,7 +1188,7 @@ builtinAutogenFiles pkg lbi clbi =
pathsFile = AutogenModule (autogenPathsModuleName pkg) (Suffix "hs")
pathsContents = toUTF8LBS $ generatePathsModule pkg lbi clbi
packageInfoFile = AutogenModule (autogenPackageInfoModuleName pkg) (Suffix "hs")
packageInfoContents = toUTF8LBS $ generatePackageInfoModule pkg lbi
packageInfoContents = toUTF8LBS $ generatePackageInfoModule pkg
cppHeaderFile = AutogenFile $ toShortText cppHeaderName
cppHeaderContents = toUTF8LBS $ generateCabalMacrosHeader pkg lbi clbi

Expand Down
25 changes: 10 additions & 15 deletions Cabal/src/Distribution/Simple/Build/PackageInfoModule.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ import Distribution.Compat.Prelude
import Prelude ()

import Distribution.Package
import Distribution.PackageDescription
import Distribution.Simple.Compiler
import Distribution.Simple.LocalBuildInfo
import Distribution.Utils.ShortText
import Distribution.Version
( PackageName
, packageName
, packageVersion
, unPackageName
)
import Distribution.Types.PackageDescription (PackageDescription (..))
import Distribution.Types.Version (versionNumbers)
import Distribution.Utils.ShortText (fromShortText)

import qualified Distribution.Simple.Build.PackageInfoModule.Z as Z

Expand All @@ -33,24 +36,16 @@ import qualified Distribution.Simple.Build.PackageInfoModule.Z as Z

-- ------------------------------------------------------------

generatePackageInfoModule :: PackageDescription -> LocalBuildInfo -> String
generatePackageInfoModule pkg_descr lbi =
generatePackageInfoModule :: PackageDescription -> String
generatePackageInfoModule pkg_descr =
Z.render
Z.Z
{ Z.zPackageName = showPkgName $ packageName pkg_descr
, Z.zVersionDigits = show $ versionNumbers $ packageVersion pkg_descr
, Z.zSynopsis = fromShortText $ synopsis pkg_descr
, Z.zCopyright = fromShortText $ copyright pkg_descr
, Z.zHomepage = fromShortText $ homepage pkg_descr
, Z.zSupportsNoRebindableSyntax = supports_rebindable_syntax
}
where
supports_rebindable_syntax = ghc_newer_than (mkVersion [7, 0, 1])

ghc_newer_than minVersion =
case compilerCompatVersion GHC (compiler lbi) of
Nothing -> False
Just version -> version `withinRange` orLaterVersion minVersion

showPkgName :: PackageName -> String
showPkgName = map fixchar . unPackageName
Expand Down
10 changes: 2 additions & 8 deletions Cabal/src/Distribution/Simple/Build/PackageInfoModule/Z.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,20 @@

module Distribution.Simple.Build.PackageInfoModule.Z (render, Z (..)) where

import Distribution.ZinzaPrelude
import Distribution.ZinzaPrelude (Generic, execWriter, tell)

data Z = Z
{ zPackageName :: String
, zVersionDigits :: String
, zSynopsis :: String
, zCopyright :: String
, zHomepage :: String
, zSupportsNoRebindableSyntax :: Bool
}
deriving (Generic)

render :: Z -> String
render z_root = execWriter $ do
if (zSupportsNoRebindableSyntax z_root)
then do
tell "{-# LANGUAGE NoRebindableSyntax #-}\n"
return ()
else do
return ()
tell "{-# LANGUAGE NoRebindableSyntax #-}\n"
tell "{-# OPTIONS_GHC -w #-}\n"
tell "\n"
tell "{-|\n"
Expand Down
11 changes: 0 additions & 11 deletions Cabal/src/Distribution/Simple/Build/PathsModule.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ generatePathsModule pkg_descr lbi clbi =
Z.Z
{ Z.zPackageName = packageName pkg_descr
, Z.zVersionDigits = show $ versionNumbers $ packageVersion pkg_descr
, Z.zSupportsCpp = supports_cpp
, Z.zSupportsNoRebindableSyntax = supports_rebindable_syntax
, Z.zAbsolute = absolute
, Z.zRelocatable = relocatable lbi
, Z.zIsWindows = isWindows
Expand All @@ -63,15 +61,6 @@ generatePathsModule pkg_descr lbi clbi =
, Z.zSysconfdir = zSysconfdir
}
where
supports_cpp = supports_language_pragma
supports_rebindable_syntax = ghc_newer_than (mkVersion [7, 0, 1])
supports_language_pragma = ghc_newer_than (mkVersion [6, 6, 1])

ghc_newer_than minVersion =
case compilerCompatVersion GHC (compiler lbi) of
Nothing -> False
Just version -> version `withinRange` orLaterVersion minVersion

-- In several cases we cannot make relocatable installations
absolute =
hasLibs pkg_descr -- we can only make progs relocatable
Expand Down
37 changes: 4 additions & 33 deletions Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import Distribution.ZinzaPrelude
data Z
= Z {zPackageName :: PackageName,
zVersionDigits :: String,
zSupportsCpp :: Bool,
zSupportsNoRebindableSyntax :: Bool,
zAbsolute :: Bool,
zRelocatable :: Bool,
zIsWindows :: Bool,
Expand All @@ -25,18 +23,8 @@ data Z
deriving Generic
render :: Z -> String
render z_root = execWriter $ do
if (zSupportsCpp z_root)
then do
tell "{-# LANGUAGE CPP #-}\n"
return ()
else do
return ()
if (zSupportsNoRebindableSyntax z_root)
then do
tell "{-# LANGUAGE NoRebindableSyntax #-}\n"
return ()
else do
return ()
tell "{-# LANGUAGE CPP #-}\n"
tell "{-# LANGUAGE NoRebindableSyntax #-}\n"
if (zNot z_root (zAbsolute z_root))
then do
tell "{-# LANGUAGE ForeignFunctionInterface #-}\n"
Expand Down Expand Up @@ -91,25 +79,8 @@ render z_root = execWriter $ do
else do
return ()
tell "\n"
if (zSupportsCpp z_root)
then do
tell "#if defined(VERSION_base)\n"
tell "\n"
tell "#if MIN_VERSION_base(4,0,0)\n"
tell "catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a\n"
tell "#else\n"
tell "catchIO :: IO a -> (Exception.Exception -> IO a) -> IO a\n"
tell "#endif\n"
tell "\n"
tell "#else\n"
tell "catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a\n"
tell "#endif\n"
tell "catchIO = Exception.catch\n"
return ()
else do
tell "catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a\n"
tell "catchIO = Exception.catch\n"
return ()
tell "catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a\n"
tell "catchIO = Exception.catch\n"
tell "\n"
tell "-- |The package version.\n"
tell "version :: Version\n"
Expand Down
9 changes: 1 addition & 8 deletions Cabal/src/Distribution/Simple/Compiler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -492,15 +492,8 @@ reexportedAsSupported comp = case compilerFlavor comp of
-- "dynamic-library-dirs"?
libraryDynDirSupported :: Compiler -> Bool
libraryDynDirSupported comp = case compilerFlavor comp of
GHC ->
-- Not just v >= mkVersion [8,0,1,20161022], as there
-- are many GHC 8.1 nightlies which don't support this.
( (v >= mkVersion [8, 0, 1, 20161022] && v < mkVersion [8, 1])
|| v >= mkVersion [8, 1, 20161021]
)
GHC -> True
_ -> False
where
v = compilerVersion comp

-- | Does this compiler's "ar" command supports response file
-- arguments (i.e. @file-style arguments).
Expand Down
9 changes: 2 additions & 7 deletions Cabal/src/Distribution/Simple/Configure.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2095,7 +2095,7 @@ getInstalledPackages verbosity comp mbWorkDir packageDBs progdb = do
-- do not check empty packagedbs (ghc-pkg would error out)
packageDBs' <- filterM packageDBExists packageDBs
case compilerFlavor comp of
GHC -> GHC.getInstalledPackages verbosity comp mbWorkDir packageDBs' progdb
GHC -> GHC.getInstalledPackages verbosity mbWorkDir packageDBs' progdb
GHCJS -> GHCJS.getInstalledPackages verbosity mbWorkDir packageDBs' progdb
UHC -> UHC.getInstalledPackages verbosity comp mbWorkDir packageDBs' progdb
flv ->
Expand Down Expand Up @@ -2922,12 +2922,7 @@ checkForeignLibSupported :: Compiler -> Platform -> ForeignLib -> Maybe String
checkForeignLibSupported comp platform flib = go (compilerFlavor comp)
where
go :: CompilerFlavor -> Maybe String
go GHC
| compilerVersion comp < mkVersion [7, 8] =
unsupported
[ "Building foreign libraries is only supported with GHC >= 7.8"
]
| otherwise = goGhcPlatform platform
go GHC = goGhcPlatform platform
go _ =
unsupported
[ "Building foreign libraries is currently only supported with ghc"
Expand Down
12 changes: 3 additions & 9 deletions Cabal/src/Distribution/Simple/Errors.hs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ data CabalException
| AmbiguousBuildTarget [(String, [(String, String)])]
| CheckBuildTargets String
| VersionMismatchGHC FilePath Version FilePath Version
| CheckPackageDbStackPost76
| CheckPackageDbStackPre76
| CheckPackageDbStack
| GlobalPackageDbSpecifiedFirst
| CantInstallForeignLib
| NoSupportForPreProcessingTest TestType
Expand Down Expand Up @@ -230,8 +229,7 @@ exceptionCode e = case e of
AmbiguousBuildTarget{} -> 7865
CheckBuildTargets{} -> 4733
VersionMismatchGHC{} -> 4000
CheckPackageDbStackPost76{} -> 3000
CheckPackageDbStackPre76{} -> 5640
CheckPackageDbStack{} -> 3000
GlobalPackageDbSpecifiedFirst{} -> 2345
CantInstallForeignLib{} -> 8221
NoSupportForPreProcessingTest{} -> 3008
Expand Down Expand Up @@ -470,13 +468,9 @@ exceptionMessage e = case e of
++ ghcPkgProgPath
++ " is version "
++ prettyShow ghcPkgVersion
CheckPackageDbStackPost76 ->
CheckPackageDbStack ->
"If the global package db is specified, it must be "
++ "specified first and cannot be specified multiple times"
CheckPackageDbStackPre76 ->
"With current ghc versions the global package db is always used "
++ "and must be listed first. This ghc limitation is lifted in GHC 7.6,"
++ "see https://gitlab.haskell.org/ghc/ghc/-/issues/5977"
GlobalPackageDbSpecifiedFirst ->
"If the global package db is specified, it must be "
++ "specified first and cannot be specified multiple times"
Expand Down
56 changes: 12 additions & 44 deletions Cabal/src/Distribution/Simple/GHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ configureCompiler verbosity hcPath conf0 = do
++ prettyShow ghcVersion

let implInfo = ghcVersionImplInfo ghcVersion
languages <- Internal.getLanguages verbosity implInfo ghcProg
extensions0 <- Internal.getExtensions verbosity implInfo ghcProg
languages <- Internal.getLanguages implInfo
extensions0 <- Internal.getExtensions verbosity ghcProg

ghcInfo <- Internal.getGhcInfo verbosity implInfo ghcProg

Expand Down Expand Up @@ -489,14 +489,13 @@ getPackageDBContents verbosity mbWorkDir packagedb progdb = do
-- | Given a package DB stack, return all installed packages.
getInstalledPackages
:: Verbosity
-> Compiler
-> Maybe (SymbolicPath CWD (Dir from))
-> PackageDBStackX (SymbolicPath from (Dir PkgDB))
-> ProgramDb
-> IO InstalledPackageIndex
getInstalledPackages verbosity comp mbWorkDir packagedbs progdb = do
getInstalledPackages verbosity mbWorkDir packagedbs progdb = do
checkPackageDbEnvVar verbosity
checkPackageDbStack verbosity comp packagedbs
checkPackageDbStack verbosity packagedbs
pkgss <- getInstalledPackages' verbosity mbWorkDir packagedbs progdb
index <- toPackageIndex verbosity pkgss progdb
return $! hackRtsPackage index
Expand Down Expand Up @@ -576,30 +575,13 @@ checkPackageDbEnvVar :: Verbosity -> IO ()
checkPackageDbEnvVar verbosity =
Internal.checkPackageDbEnvVar verbosity "GHC" "GHC_PACKAGE_PATH"

checkPackageDbStack :: Eq fp => Verbosity -> Compiler -> PackageDBStackX fp -> IO ()
checkPackageDbStack verbosity comp =
if flagPackageConf implInfo
then checkPackageDbStackPre76 verbosity
else checkPackageDbStackPost76 verbosity
where
implInfo = ghcVersionImplInfo (compilerVersion comp)

checkPackageDbStackPost76 :: Eq fp => Verbosity -> PackageDBStackX fp -> IO ()
checkPackageDbStackPost76 _ (GlobalPackageDB : rest)
checkPackageDbStack :: Eq fp => Verbosity -> PackageDBStackX fp -> IO ()
checkPackageDbStack _ (GlobalPackageDB : rest)
| GlobalPackageDB `notElem` rest = return ()
checkPackageDbStackPost76 verbosity rest
checkPackageDbStack verbosity rest
| GlobalPackageDB `elem` rest =
dieWithException verbosity CheckPackageDbStackPost76
checkPackageDbStackPost76 _ _ = return ()

checkPackageDbStackPre76 :: Eq fp => Verbosity -> PackageDBStackX fp -> IO ()
checkPackageDbStackPre76 _ (GlobalPackageDB : rest)
| GlobalPackageDB `notElem` rest = return ()
checkPackageDbStackPre76 verbosity rest
| GlobalPackageDB `notElem` rest =
dieWithException verbosity CheckPackageDbStackPre76
checkPackageDbStackPre76 verbosity _ =
dieWithException verbosity GlobalPackageDbSpecifiedFirst
dieWithException verbosity CheckPackageDbStack
checkPackageDbStack _ _ = return ()

-- GHC < 6.10 put "$topdir/include/mingw" in rts's installDirs. This
-- breaks when you want to use a different gcc, so we need to filter
Expand Down Expand Up @@ -710,7 +692,7 @@ startInterpreter verbosity progdb comp platform packageDBs = do
{ ghcOptMode = toFlag GhcModeInteractive
, ghcOptPackageDBs = packageDBs
}
checkPackageDbStack verbosity comp packageDBs
checkPackageDbStack verbosity packageDBs
(ghcProg, _) <- requireProgram verbosity ghcProgram progdb
-- This doesn't pass source file arguments to GHC, so we don't have to worry
-- about using a response file here.
Expand Down Expand Up @@ -1134,23 +1116,9 @@ installLib verbosity lbi targetDir dynlibTargetDir bytecodeTargetDir _builtDir p
-- -----------------------------------------------------------------------------
-- Registering

hcPkgInfo :: ProgramDb -> HcPkg.HcPkgInfo
hcPkgInfo :: ProgramDb -> HcPkg.ConfiguredProgram
hcPkgInfo progdb =
HcPkg.HcPkgInfo
{ HcPkg.hcPkgProgram = ghcPkgProg
, HcPkg.noPkgDbStack = v < [6, 9]
, HcPkg.noVerboseFlag = v < [6, 11]
, HcPkg.flagPackageConf = v < [7, 5]
, HcPkg.supportsDirDbs = v >= [6, 8]
, HcPkg.requiresDirDbs = v >= [7, 10]
, HcPkg.nativeMultiInstance = v >= [7, 10]
, HcPkg.recacheMultiInstance = v >= [6, 12]
, HcPkg.suppressFilesCheck = v >= [6, 6]
}
where
v = versionNumbers ver
ghcPkgProg = fromMaybe (error "GHC.hcPkgInfo: no ghc program") $ lookupProgram ghcPkgProgram progdb
ver = fromMaybe (error "GHC.hcPkgInfo: no ghc version") $ programVersion ghcPkgProg
fromMaybe (error "GHC.hcPkgInfo: no ghc program") $ lookupProgram ghcPkgProgram progdb

registerPackage
:: Verbosity
Expand Down
Loading
Loading