Skip to content

Commit 1cd54e4

Browse files
committed
Remove old mkVersion
1 parent c5c2072 commit 1cd54e4

13 files changed

Lines changed: 38 additions & 156 deletions

File tree

Cabal/src/Distribution/Simple/Build.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@ builtinAutogenFiles pkg lbi clbi =
11901190
pathsFile = AutogenModule (autogenPathsModuleName pkg) (Suffix "hs")
11911191
pathsContents = toUTF8LBS $ generatePathsModule pkg lbi clbi
11921192
packageInfoFile = AutogenModule (autogenPackageInfoModuleName pkg) (Suffix "hs")
1193-
packageInfoContents = toUTF8LBS $ generatePackageInfoModule pkg lbi
1193+
packageInfoContents = toUTF8LBS $ generatePackageInfoModule pkg
11941194
cppHeaderFile = AutogenFile $ toShortText cppHeaderName
11951195
cppHeaderContents = toUTF8LBS $ generateCabalMacrosHeader pkg lbi clbi
11961196

Cabal/src/Distribution/Simple/Build/PackageInfoModule.hs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ import Distribution.Compat.Prelude
1919
import Prelude ()
2020

2121
import Distribution.Package
22-
import Distribution.PackageDescription
23-
import Distribution.Simple.Compiler
24-
import Distribution.Simple.LocalBuildInfo
25-
import Distribution.Utils.ShortText
26-
import Distribution.Version
22+
( PackageName
23+
, packageName
24+
, packageVersion
25+
, unPackageName
26+
)
27+
import Distribution.Types.PackageDescription (PackageDescription (..))
28+
import Distribution.Types.Version (versionNumbers)
29+
import Distribution.Utils.ShortText (fromShortText)
2730

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

@@ -33,24 +36,17 @@ import qualified Distribution.Simple.Build.PackageInfoModule.Z as Z
3336

3437
-- ------------------------------------------------------------
3538

36-
generatePackageInfoModule :: PackageDescription -> LocalBuildInfo -> String
37-
generatePackageInfoModule pkg_descr lbi =
39+
generatePackageInfoModule :: PackageDescription -> String
40+
generatePackageInfoModule pkg_descr =
3841
Z.render
3942
Z.Z
4043
{ Z.zPackageName = showPkgName $ packageName pkg_descr
4144
, Z.zVersionDigits = show $ versionNumbers $ packageVersion pkg_descr
4245
, Z.zSynopsis = fromShortText $ synopsis pkg_descr
4346
, Z.zCopyright = fromShortText $ copyright pkg_descr
4447
, Z.zHomepage = fromShortText $ homepage pkg_descr
45-
, Z.zSupportsNoRebindableSyntax = supports_rebindable_syntax
48+
, Z.zSupportsNoRebindableSyntax = True
4649
}
47-
where
48-
supports_rebindable_syntax = ghc_newer_than (mkVersion [7, 0, 1])
49-
50-
ghc_newer_than minVersion =
51-
case compilerCompatVersion GHC (compiler lbi) of
52-
Nothing -> False
53-
Just version -> version `withinRange` orLaterVersion minVersion
5450

5551
showPkgName :: PackageName -> String
5652
showPkgName = map fixchar . unPackageName

Cabal/src/Distribution/Simple/Build/PathsModule.hs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ generatePathsModule pkg_descr lbi clbi =
4444
Z.Z
4545
{ Z.zPackageName = packageName pkg_descr
4646
, Z.zVersionDigits = show $ versionNumbers $ packageVersion pkg_descr
47-
, Z.zSupportsCpp = supports_cpp
48-
, Z.zSupportsNoRebindableSyntax = supports_rebindable_syntax
47+
, Z.zSupportsCpp = True
48+
, Z.zSupportsNoRebindableSyntax = True
4949
, Z.zAbsolute = absolute
5050
, Z.zRelocatable = relocatable lbi
5151
, Z.zIsWindows = isWindows
@@ -63,15 +63,6 @@ generatePathsModule pkg_descr lbi clbi =
6363
, Z.zSysconfdir = zSysconfdir
6464
}
6565
where
66-
supports_cpp = supports_language_pragma
67-
supports_rebindable_syntax = ghc_newer_than (mkVersion [7, 0, 1])
68-
supports_language_pragma = ghc_newer_than (mkVersion [6, 6, 1])
69-
70-
ghc_newer_than minVersion =
71-
case compilerCompatVersion GHC (compiler lbi) of
72-
Nothing -> False
73-
Just version -> version `withinRange` orLaterVersion minVersion
74-
7566
-- In several cases we cannot make relocatable installations
7667
absolute =
7768
hasLibs pkg_descr -- we can only make progs relocatable

Cabal/src/Distribution/Simple/Compiler.hs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -492,15 +492,8 @@ reexportedAsSupported comp = case compilerFlavor comp of
492492
-- "dynamic-library-dirs"?
493493
libraryDynDirSupported :: Compiler -> Bool
494494
libraryDynDirSupported comp = case compilerFlavor comp of
495-
GHC ->
496-
-- Not just v >= mkVersion [8,0,1,20161022], as there
497-
-- are many GHC 8.1 nightlies which don't support this.
498-
( (v >= mkVersion [8, 0, 1, 20161022] && v < mkVersion [8, 1])
499-
|| v >= mkVersion [8, 1, 20161021]
500-
)
495+
GHC -> True
501496
_ -> False
502-
where
503-
v = compilerVersion comp
504497

505498
-- | Does this compiler's "ar" command supports response file
506499
-- arguments (i.e. @file-style arguments).

Cabal/src/Distribution/Simple/Configure.hs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2923,12 +2923,7 @@ checkForeignLibSupported :: Compiler -> Platform -> ForeignLib -> Maybe String
29232923
checkForeignLibSupported comp platform flib = go (compilerFlavor comp)
29242924
where
29252925
go :: CompilerFlavor -> Maybe String
2926-
go GHC
2927-
| compilerVersion comp < mkVersion [7, 8] =
2928-
unsupported
2929-
[ "Building foreign libraries is only supported with GHC >= 7.8"
2930-
]
2931-
| otherwise = goGhcPlatform platform
2926+
go GHC = goGhcPlatform platform
29322927
go _ =
29332928
unsupported
29342929
[ "Building foreign libraries is currently only supported with ghc"

Cabal/src/Distribution/Simple/GHC/Build/Link.hs

Lines changed: 6 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ import Distribution.Version
5151
import System.Directory
5252
( createDirectoryIfMissing
5353
, doesDirectoryExist
54-
, doesFileExist
55-
, removeFile
5654
, renameFile
5755
)
5856
import System.FilePath
@@ -260,18 +258,17 @@ linkLibrary
260258
-> [BuildWay]
261259
-- ^ Wanted build ways and corresponding build options
262260
-> IO ()
263-
linkLibrary buildTargetDir cleanedExtraLibDirs pkg_descr verbosity runGhcProg lib lbi clbi extraSources rpaths wantedWays = do
261+
linkLibrary buildTargetDir cleanedExtraLibDirs _pkg_descr verbosity runGhcProg lib lbi clbi extraSources rpaths wantedWays = do
264262
let
265263
common = configCommonFlags $ configFlags lbi
266264
mbWorkDir = flagToMaybe $ setupWorkingDir common
267265

268266
compiler_id = compilerId comp
269267
comp = compiler lbi
270-
ghcVersion = compilerVersion comp
271268
implInfo = getImplInfo comp
272269
uid = componentUnitId clbi
273270
libBi = libBuildInfo lib
274-
Platform _hostArch hostOS = hostPlatform lbi
271+
Platform _hostArch _hostOS = hostPlatform lbi
275272
vanillaLibFilePath = buildTargetDir </> makeRelativePathEx (mkLibName uid)
276273
profileLibFilePath = buildTargetDir </> makeRelativePathEx (mkProfLibName uid)
277274
sharedLibFilePath =
@@ -288,19 +285,6 @@ linkLibrary buildTargetDir cleanedExtraLibDirs pkg_descr verbosity runGhcProg li
288285
</> makeRelativePathEx (mkBytecodeLibName compiler_id uid)
289286
ghciLibFilePath = buildTargetDir </> makeRelativePathEx (Internal.mkGHCiLibName uid)
290287
ghciProfLibFilePath = buildTargetDir </> makeRelativePathEx (Internal.mkGHCiProfLibName uid)
291-
libInstallPath =
292-
libdir $
293-
absoluteComponentInstallDirs
294-
pkg_descr
295-
lbi
296-
uid
297-
NoCopyDest
298-
sharedLibInstallPath =
299-
libInstallPath
300-
</> mkSharedLibName (hostPlatform lbi) compiler_id uid
301-
profSharedLibInstallPath =
302-
libInstallPath
303-
</> mkProfSharedLibName (hostPlatform lbi) compiler_id uid
304288

305289
getObjWayFiles :: BuildWay -> IO [SymbolicPath Pkg File]
306290
getObjWayFiles w = getObjFiles (buildWayObjectExtension objExtension w) (buildWayObjectExtension objExtension w)
@@ -322,16 +306,7 @@ linkLibrary buildTargetDir cleanedExtraLibDirs pkg_descr verbosity runGhcProg li
322306
, pure $ map (srcObjPath obj_ext) extraSources
323307
, catMaybes
324308
<$> sequenceA
325-
[ findFileCwdWithExtension
326-
mbWorkDir
327-
[Suffix obj_ext]
328-
[buildTargetDir]
329-
xPath
330-
| ghcVersion < mkVersion [7, 2] -- ghc-7.2+ does not make _stub.o files
331-
, x <- allLibModules lib clbi
332-
, let xPath :: RelativePath Artifacts File
333-
xPath = makeRelativePathEx $ ModuleName.toFilePath x ++ "_stub"
334-
]
309+
[]
335310
]
336311

337312
-- Get the @.o@ path from a source path (e.g. @.hs@),
@@ -399,14 +374,7 @@ linkLibrary buildTargetDir cleanedExtraLibDirs pkg_descr verbosity runGhcProg li
399374
, ghcOptDynLinkMode = toFlag GhcDynamicOnly
400375
, ghcOptInputFiles = toNubListR $ map coerceSymbolicPath dynObjectFiles
401376
, ghcOptOutputFile = toFlag sharedLibFilePath
402-
, -- For dynamic libs, Mac OS/X needs to know the install location
403-
-- at build time. This only applies to GHC < 7.8 - see the
404-
-- discussion in #1660.
405-
ghcOptDylibName =
406-
if hostOS == OSX
407-
&& ghcVersion < mkVersion [7, 8]
408-
then toFlag sharedLibInstallPath
409-
else mempty
377+
, ghcOptDylibName = mempty
410378
, ghcOptLinkLibs = extraLibs libBi
411379
, ghcOptLinkLibPath = toNubListR cleanedExtraLibDirs
412380
, ghcOptLinkFrameworks = toNubListR $ map getSymbolicPath $ PD.frameworks libBi
@@ -425,14 +393,7 @@ linkLibrary buildTargetDir cleanedExtraLibDirs pkg_descr verbosity runGhcProg li
425393
, ghcOptDynLinkMode = toFlag GhcDynamicOnly
426394
, ghcOptInputFiles = toNubListR pdynObjectFiles
427395
, ghcOptOutputFile = toFlag profSharedLibFilePath
428-
, -- For dynamic libs, Mac OS/X needs to know the install location
429-
-- at build time. This only applies to GHC < 7.8 - see the
430-
-- discussion in #1660.
431-
ghcOptDylibName =
432-
if hostOS == OSX
433-
&& ghcVersion < mkVersion [7, 8]
434-
then toFlag profSharedLibInstallPath
435-
else mempty
396+
, ghcOptDylibName = mempty
436397
, ghcOptLinkLibs = extraLibs libBi
437398
, ghcOptLinkLibPath = toNubListR cleanedExtraLibDirs
438399
, ghcOptLinkFrameworks = toNubListR $ map getSymbolicPath $ PD.frameworks libBi
@@ -545,16 +506,11 @@ linkExecutable linkerOpts (way, buildOpts) targetDir targetName runGhcProg lbi =
545506
-- assume there is a main function in another non-haskell object
546507
ghcOptLinkNoHsMain = toFlag (ghcOptInputFiles baseOpts == mempty && ghcOptInputScripts baseOpts == mempty)
547508
}
548-
comp = compiler lbi
549509

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

560516
-- | Link a foreign library component
@@ -661,7 +617,7 @@ getRPaths pbci = do
661617
supportRPaths OSX = True
662618
supportRPaths FreeBSD =
663619
case compid of
664-
CompilerId GHC ver | ver >= mkVersion [7, 10, 2] -> True
620+
CompilerId GHC _ver -> True
665621
_ -> False
666622
supportRPaths OpenBSD = False
667623
supportRPaths NetBSD = False

Cabal/src/Distribution/Simple/GHCJS.hs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ import System.Directory
9797
, createDirectoryIfMissing
9898
, doesFileExist
9999
, getAppUserDataDirectory
100-
, removeFile
101100
, renameFile
102101
)
103102
import System.FilePath
@@ -1570,10 +1569,6 @@ gbuild verbosity numJobs pkg_descr lbi bm clbi = do
15701569
-- Work around old GHCs not relinking in this
15711570
-- situation, see #3294
15721571
let target = targetDir </> makeRelativePathEx targetName
1573-
when (compilerVersion comp < mkVersion [7, 7]) $ do
1574-
let targetPath = i target
1575-
e <- doesFileExist targetPath
1576-
when e (removeFile targetPath)
15771572
runGhcProg linkOpts{ghcOptOutputFile = toFlag target}
15781573
GBuildFLib flib -> do
15791574
let rtsInfo = extractRtsInfo lbi
@@ -1742,7 +1737,7 @@ getRPaths lbi clbi | supportRPaths hostOS = do
17421737
supportRPaths OSX = True
17431738
supportRPaths FreeBSD =
17441739
case compid of
1745-
CompilerId GHC ver | ver >= mkVersion [7, 10, 2] -> True
1740+
CompilerId GHC _ -> True
17461741
_ -> False
17471742
supportRPaths OpenBSD = False
17481743
supportRPaths NetBSD = False

Cabal/src/Distribution/Simple/Program/Builtin.hs

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,7 @@ ghcProgram =
105105
}
106106
where
107107
ghcPostConf _verbosity ghcProg = do
108-
let setLanguageEnv prog =
109-
prog
110-
{ programOverrideEnv =
111-
("LANGUAGE", Just "en")
112-
: programOverrideEnv ghcProg
113-
}
114-
115-
ignorePackageEnv prog = prog{programDefaultArgs = "-package-env=-" : programDefaultArgs prog}
116-
117-
-- Only the 7.8 branch seems to be affected. Fixed in 7.8.4.
118-
affectedVersionRange =
119-
intersectVersionRanges
120-
(laterVersion $ mkVersion [7, 8, 0])
121-
(earlierVersion $ mkVersion [7, 8, 4])
108+
let ignorePackageEnv prog = prog{programDefaultArgs = "-package-env=-" : programDefaultArgs prog}
122109

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

@@ -130,11 +117,7 @@ ghcProgram =
130117
( \v ->
131118
-- By default, ignore GHC_ENVIRONMENT variable of any package environment
132119
-- files. See #10759
133-
applyWhen (withinRange v canIgnorePackageEnv) ignorePackageEnv
134-
-- Workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/8825
135-
-- (spurious warning on non-english locales)
136-
$
137-
applyWhen (withinRange v affectedVersionRange) setLanguageEnv ghcProg
120+
applyWhen (withinRange v canIgnorePackageEnv) ignorePackageEnv ghcProg
138121
)
139122
(programVersion ghcProg)
140123

cabal-install/src/Distribution/Client/CmdRepl.hs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ targetedRepl
522522
-- into the multi-out directory.
523523
replOpts'' <- case targetCtx of
524524
ProjectContext -> return $ replOpts'{replOptionsFlagOutput = Flag dir}
525-
_ -> usingGhciScript compiler projectRoot replOpts'
525+
_ -> usingGhciScript projectRoot replOpts'
526526

527527
let buildCtx' = buildCtx & lElaboratedShared . lPkgConfigReplOptions .~ replOpts''
528528
printPlan verbosity baseCtx'' buildCtx'
@@ -591,7 +591,7 @@ targetedRepl
591591
-- single target repl
592592
replOpts'' <- case targetCtx of
593593
ProjectContext -> return replOpts'
594-
_ -> usingGhciScript compiler projectRoot replOpts'
594+
_ -> usingGhciScript projectRoot replOpts'
595595

596596
let buildCtx' = buildCtx & lElaboratedShared . lPkgConfigReplOptions .~ replOpts''
597597
printPlan verbosity baseCtx'' buildCtx'
@@ -762,19 +762,12 @@ generateReplFlags includeTransitive elaboratedPlan OriginalComponentInfo{..} = f
762762
--
763763
-- The @-ghci-script@ flag is path to the ghci script responsible for changing to the
764764
-- correct directory. Only works on GHC >= 7.6, though. 🙁
765-
usingGhciScript :: Compiler -> FilePath -> ReplOptions -> IO ReplOptions
766-
usingGhciScript compiler projectRoot replOpts
767-
| compilerCompatVersion GHC compiler >= Just minGhciScriptVersion = do
768-
let ghciScriptPath = projectRoot </> "setcwd.ghci"
769-
cwd <- getCurrentDirectory
770-
writeFile ghciScriptPath (":cd " ++ cwd)
771-
return $ replOpts & lReplOptionsFlags %~ (("-ghci-script" ++ ghciScriptPath) :)
772-
| otherwise = return replOpts
773-
774-
-- | First version of GHC where GHCi supported the flag we need.
775-
-- https://downloads.haskell.org/~ghc/7.6.1/docs/html/users_guide/release-7-6-1.html
776-
minGhciScriptVersion :: Version
777-
minGhciScriptVersion = mkVersion [7, 6]
765+
usingGhciScript :: FilePath -> ReplOptions -> IO ReplOptions
766+
usingGhciScript projectRoot replOpts = do
767+
let ghciScriptPath = projectRoot </> "setcwd.ghci"
768+
cwd <- getCurrentDirectory
769+
writeFile ghciScriptPath (":cd " ++ cwd)
770+
return $ replOpts & lReplOptionsFlags %~ (("-ghci-script" ++ ghciScriptPath) :)
778771

779772
-- | This defines what a 'TargetSelector' means for the @repl@ command.
780773
-- It selects the 'AvailableTarget's that the 'TargetSelector' refers to,

cabal-install/src/Distribution/Client/Init/NonInteractive/Heuristics.hs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,7 @@ guessCabalSpecVersion = do
7474
-- | Guess the language specification based on the GHC version
7575
guessLanguage :: Interactive m => Compiler -> m Language
7676
guessLanguage Compiler{compilerId = CompilerId GHC ver} =
77-
return $
78-
if ver < mkVersion [7, 0, 1]
79-
then Haskell98
80-
else Haskell2010
77+
return Haskell2010
8178
guessLanguage _ = return defaultLanguage
8279

8380
-- | Guess the package name based on the given root directory.

0 commit comments

Comments
 (0)