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
2 changes: 1 addition & 1 deletion Cabal/src/Distribution/Simple/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,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
12 changes: 1 addition & 11 deletions Cabal/src/Distribution/Simple/Build/PathsModule.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ 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.zSupportsCpp = True
, Z.zAbsolute = absolute
, Z.zRelocatable = relocatable lbi
, Z.zIsWindows = isWindows
Expand All @@ -63,15 +62,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
8 changes: 1 addition & 7 deletions Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ data Z
= Z {zPackageName :: PackageName,
zVersionDigits :: String,
zSupportsCpp :: Bool,
zSupportsNoRebindableSyntax :: Bool,
zAbsolute :: Bool,
zRelocatable :: Bool,
zIsWindows :: Bool,
Expand All @@ -31,12 +30,7 @@ render z_root = execWriter $ do
return ()
else do
return ()
if (zSupportsNoRebindableSyntax z_root)
then do
tell "{-# LANGUAGE NoRebindableSyntax #-}\n"
return ()
else do
return ()
tell "{-# LANGUAGE NoRebindableSyntax #-}\n"
if (zNot z_root (zAbsolute z_root))
then do
tell "{-# LANGUAGE ForeignFunctionInterface #-}\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
7 changes: 1 addition & 6 deletions Cabal/src/Distribution/Simple/Configure.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2923,12 +2923,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
65 changes: 5 additions & 60 deletions Cabal/src/Distribution/Simple/GHC/Build/Link.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import Distribution.Compat.ResponseFile
import Distribution.InstalledPackageInfo (InstalledPackageInfo)
import qualified Distribution.InstalledPackageInfo as IPI
import qualified Distribution.InstalledPackageInfo as InstalledPackageInfo
import qualified Distribution.ModuleName as ModuleName
import Distribution.Package
import Distribution.PackageDescription as PD
import Distribution.PackageDescription.Utils (cabalBug)
Expand All @@ -32,7 +31,6 @@ import Distribution.Simple.GHC.ImplInfo
import qualified Distribution.Simple.GHC.Internal as Internal
import Distribution.Simple.LocalBuildInfo
import qualified Distribution.Simple.PackageIndex as PackageIndex
import Distribution.Simple.PreProcess.Types
import Distribution.Simple.Program
import qualified Distribution.Simple.Program.Ar as Ar
import Distribution.Simple.Program.GHC
Expand All @@ -51,8 +49,6 @@ import Distribution.Version
import System.Directory
( createDirectoryIfMissing
, doesDirectoryExist
, doesFileExist
, removeFile
, renameFile
)
import System.FilePath
Expand Down Expand Up @@ -230,7 +226,7 @@ linkOrLoadComponent
CLib lib -> do
let libWays = wantedLibWays isIndef
rpaths <- get_rpaths (Set.fromList libWays)
linkLibrary buildTargetDir cleanedExtraLibDirs pkg_descr verbosity runGhcProg lib lbi clbi extraSources rpaths libWays
linkLibrary buildTargetDir cleanedExtraLibDirs verbosity runGhcProg lib lbi clbi extraSources rpaths libWays
CFLib flib -> do
let flib_way = wantedFLibWay (withDynFLib flib)
rpaths <- get_rpaths (Set.singleton flib_way)
Expand All @@ -245,8 +241,6 @@ linkLibrary
-- ^ The library target build directory
-> [SymbolicPath Pkg (Dir Lib)]
-- ^ The list of extra lib dirs that exist (aka "cleaned")
-> PackageDescription
-- ^ The package description containing this library
-> Verbosity
-> (GhcOptions -> IO ())
-- ^ Run the configured Ghc program
Expand All @@ -260,18 +254,13 @@ linkLibrary
-> [BuildWay]
-- ^ Wanted build ways and corresponding build options
-> IO ()
linkLibrary buildTargetDir cleanedExtraLibDirs pkg_descr verbosity runGhcProg lib lbi clbi extraSources rpaths wantedWays = do
linkLibrary buildTargetDir cleanedExtraLibDirs verbosity runGhcProg lib lbi clbi extraSources rpaths wantedWays = do
let
common = configCommonFlags $ configFlags lbi
mbWorkDir = flagToMaybe $ setupWorkingDir common

compiler_id = compilerId comp
comp = compiler lbi
ghcVersion = compilerVersion comp
implInfo = getImplInfo comp
uid = componentUnitId clbi
libBi = libBuildInfo lib
Platform _hostArch hostOS = hostPlatform lbi
vanillaLibFilePath = buildTargetDir </> makeRelativePathEx (mkLibName uid)
profileLibFilePath = buildTargetDir </> makeRelativePathEx (mkProfLibName uid)
sharedLibFilePath =
Expand All @@ -288,19 +277,6 @@ linkLibrary buildTargetDir cleanedExtraLibDirs pkg_descr verbosity runGhcProg li
</> makeRelativePathEx (mkBytecodeLibName compiler_id uid)
ghciLibFilePath = buildTargetDir </> makeRelativePathEx (Internal.mkGHCiLibName uid)
ghciProfLibFilePath = buildTargetDir </> makeRelativePathEx (Internal.mkGHCiProfLibName uid)
libInstallPath =
libdir $
absoluteComponentInstallDirs
pkg_descr
lbi
uid
NoCopyDest
sharedLibInstallPath =
libInstallPath
</> mkSharedLibName (hostPlatform lbi) compiler_id uid
profSharedLibInstallPath =
libInstallPath
</> mkProfSharedLibName (hostPlatform lbi) compiler_id uid

getObjWayFiles :: BuildWay -> IO [SymbolicPath Pkg File]
getObjWayFiles w = getObjFiles (buildWayObjectExtension objExtension w) (buildWayObjectExtension objExtension w)
Expand All @@ -320,18 +296,6 @@ linkLibrary buildTargetDir cleanedExtraLibDirs pkg_descr verbosity runGhcProg li
hs_ext
True
, pure $ map (srcObjPath obj_ext) extraSources
, catMaybes
<$> sequenceA
[ findFileCwdWithExtension
mbWorkDir
[Suffix obj_ext]
[buildTargetDir]
xPath
| ghcVersion < mkVersion [7, 2] -- ghc-7.2+ does not make _stub.o files
, x <- allLibModules lib clbi
, let xPath :: RelativePath Artifacts File
xPath = makeRelativePathEx $ ModuleName.toFilePath x ++ "_stub"
]
]

-- Get the @.o@ path from a source path (e.g. @.hs@),
Expand Down Expand Up @@ -399,14 +363,7 @@ linkLibrary buildTargetDir cleanedExtraLibDirs pkg_descr verbosity runGhcProg li
, ghcOptDynLinkMode = toFlag GhcDynamicOnly
, ghcOptInputFiles = toNubListR $ map coerceSymbolicPath dynObjectFiles
, ghcOptOutputFile = toFlag sharedLibFilePath
, -- For dynamic libs, Mac OS/X needs to know the install location
-- at build time. This only applies to GHC < 7.8 - see the
-- discussion in #1660.
ghcOptDylibName =
if hostOS == OSX
&& ghcVersion < mkVersion [7, 8]
then toFlag sharedLibInstallPath
else mempty
, ghcOptDylibName = mempty
, ghcOptLinkLibs = extraLibs libBi
, ghcOptLinkLibPath = toNubListR cleanedExtraLibDirs
, ghcOptLinkFrameworks = toNubListR $ map getSymbolicPath $ PD.frameworks libBi
Expand All @@ -425,14 +382,7 @@ linkLibrary buildTargetDir cleanedExtraLibDirs pkg_descr verbosity runGhcProg li
, ghcOptDynLinkMode = toFlag GhcDynamicOnly
, ghcOptInputFiles = toNubListR pdynObjectFiles
, ghcOptOutputFile = toFlag profSharedLibFilePath
, -- For dynamic libs, Mac OS/X needs to know the install location
-- at build time. This only applies to GHC < 7.8 - see the
-- discussion in #1660.
ghcOptDylibName =
if hostOS == OSX
&& ghcVersion < mkVersion [7, 8]
then toFlag profSharedLibInstallPath
else mempty
, ghcOptDylibName = mempty
, ghcOptLinkLibs = extraLibs libBi
, ghcOptLinkLibPath = toNubListR cleanedExtraLibDirs
, ghcOptLinkFrameworks = toNubListR $ map getSymbolicPath $ PD.frameworks libBi
Expand Down Expand Up @@ -545,16 +495,11 @@ linkExecutable linkerOpts (way, buildOpts) targetDir targetName runGhcProg lbi =
-- assume there is a main function in another non-haskell object
ghcOptLinkNoHsMain = toFlag (ghcOptInputFiles baseOpts == mempty && ghcOptInputScripts baseOpts == mempty)
}
comp = compiler lbi

-- Work around old GHCs not relinking in this
-- situation, see #3294
let target =
targetDir </> makeRelativePathEx (exeTargetName (hostPlatform lbi) targetName)
when (compilerVersion comp < mkVersion [7, 7]) $ do
let targetPath = interpretSymbolicPathLBI lbi target
e <- doesFileExist targetPath
when e (removeFile targetPath)
runGhcProg linkOpts{ghcOptOutputFile = toFlag target}

-- | Link a foreign library component
Expand Down Expand Up @@ -661,7 +606,7 @@ getRPaths pbci = do
supportRPaths OSX = True
supportRPaths FreeBSD =
case compid of
CompilerId GHC ver | ver >= mkVersion [7, 10, 2] -> True
CompilerId GHC _ver -> True
_ -> False
supportRPaths OpenBSD = False
supportRPaths NetBSD = False
Expand Down
7 changes: 1 addition & 6 deletions Cabal/src/Distribution/Simple/GHCJS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ import System.Directory
, createDirectoryIfMissing
, doesFileExist
, getAppUserDataDirectory
, removeFile
, renameFile
)
import System.FilePath
Expand Down Expand Up @@ -1570,10 +1569,6 @@ gbuild verbosity numJobs pkg_descr lbi bm clbi = do
-- Work around old GHCs not relinking in this
-- situation, see #3294
let target = targetDir </> makeRelativePathEx targetName
when (compilerVersion comp < mkVersion [7, 7]) $ do
let targetPath = i target
e <- doesFileExist targetPath
when e (removeFile targetPath)
runGhcProg linkOpts{ghcOptOutputFile = toFlag target}
GBuildFLib flib -> do
let rtsInfo = extractRtsInfo lbi
Expand Down Expand Up @@ -1742,7 +1737,7 @@ getRPaths lbi clbi | supportRPaths hostOS = do
supportRPaths OSX = True
supportRPaths FreeBSD =
case compid of
CompilerId GHC ver | ver >= mkVersion [7, 10, 2] -> True
CompilerId GHC _ -> True
_ -> False
supportRPaths OpenBSD = False
supportRPaths NetBSD = False
Expand Down
21 changes: 2 additions & 19 deletions Cabal/src/Distribution/Simple/Program/Builtin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,7 @@ ghcProgram =
}
where
ghcPostConf _verbosity ghcProg = do
let setLanguageEnv prog =
prog
{ programOverrideEnv =
("LANGUAGE", Just "en")
: programOverrideEnv ghcProg
}

ignorePackageEnv prog = prog{programDefaultArgs = "-package-env=-" : programDefaultArgs prog}

-- Only the 7.8 branch seems to be affected. Fixed in 7.8.4.
affectedVersionRange =
intersectVersionRanges
(laterVersion $ mkVersion [7, 8, 0])
(earlierVersion $ mkVersion [7, 8, 4])
let ignorePackageEnv prog = prog{programDefaultArgs = "-package-env=-" : programDefaultArgs prog}

canIgnorePackageEnv = orLaterVersion $ mkVersion [8, 4, 4]

Expand All @@ -130,11 +117,7 @@ ghcProgram =
( \v ->
-- By default, ignore GHC_ENVIRONMENT variable of any package environment
-- files. See #10759
applyWhen (withinRange v canIgnorePackageEnv) ignorePackageEnv
-- Workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/8825
-- (spurious warning on non-english locales)
$
applyWhen (withinRange v affectedVersionRange) setLanguageEnv ghcProg
applyWhen (withinRange v canIgnorePackageEnv) ignorePackageEnv ghcProg
)
(programVersion ghcProg)

Expand Down
Loading
Loading