Skip to content

Commit 856898a

Browse files
committed
Remove support for versions of GHC prior to 6.12, fixes #3108.
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
1 parent 7aab356 commit 856898a

File tree

5 files changed

+31
-167
lines changed

5 files changed

+31
-167
lines changed

Cabal/Distribution/Simple/GHC.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ configure verbosity hcPath hcPkgPath conf0 = do
111111

112112
(ghcProg, ghcVersion, conf1) <-
113113
requireProgramVersion verbosity ghcProgram
114-
(orLaterVersion (Version [6,4] []))
114+
(orLaterVersion (Version [6,11] []))
115115
(userMaybeSpecifyPath "ghc" hcPath conf0)
116116
let implInfo = ghcVersionImplInfo ghcVersion
117117

Cabal/Distribution/Simple/GHC/ImplInfo.hs

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,7 @@ import Distribution.Version
3131
-}
3232

3333
data GhcImplInfo = GhcImplInfo
34-
{ hasCcOdirBug :: Bool -- ^ bug in -odir handling for C compilations.
35-
, flagInfoLanguages :: Bool -- ^ --info and --supported-languages flags
36-
, fakeRecordPuns :: Bool -- ^ use -XRecordPuns for NamedFieldPuns
37-
, flagStubdir :: Bool -- ^ -stubdir flag supported
38-
, flagOutputDir :: Bool -- ^ -outputdir flag supported
39-
, noExtInSplitSuffix :: Bool -- ^ split-obj suffix does not contain p_o ext
40-
, flagFfiIncludes :: Bool -- ^ -#include on command line for FFI includes
41-
, flagBuildingCabalPkg :: Bool -- ^ -fbuilding-cabal-package flag supported
42-
, flagPackageId :: Bool -- ^ -package-id / -package flags supported
43-
, separateGccMingw :: Bool -- ^ mingw and gcc are in separate directories
44-
, supportsHaskell2010 :: Bool -- ^ -XHaskell2010 and -XHaskell98 flags
34+
{ supportsHaskell2010 :: Bool -- ^ -XHaskell2010 and -XHaskell98 flags
4535
, reportsNoExt :: Bool -- ^ --supported-languages gives Ext and NoExt
4636
, alwaysNondecIndent :: Bool -- ^ NondecreasingIndentation is always on
4737
, flagGhciScript :: Bool -- ^ -ghci-script flag supported
@@ -65,17 +55,7 @@ getImplInfo comp =
6555

6656
ghcVersionImplInfo :: Version -> GhcImplInfo
6757
ghcVersionImplInfo (Version v _) = GhcImplInfo
68-
{ hasCcOdirBug = v < [6,4,1]
69-
, flagInfoLanguages = v >= [6,7]
70-
, fakeRecordPuns = v >= [6,8] && v < [6,10]
71-
, flagStubdir = v >= [6,8]
72-
, flagOutputDir = v >= [6,10]
73-
, noExtInSplitSuffix = v < [6,11]
74-
, flagFfiIncludes = v < [6,11]
75-
, flagBuildingCabalPkg = v >= [6,11]
76-
, flagPackageId = v > [6,11]
77-
, separateGccMingw = v < [6,12]
78-
, supportsHaskell2010 = v >= [7]
58+
{ supportsHaskell2010 = v >= [7]
7959
, reportsNoExt = v >= [7]
8060
, alwaysNondecIndent = v < [7,1]
8161
, flagGhciScript = v >= [7,2]
@@ -86,17 +66,7 @@ ghcVersionImplInfo (Version v _) = GhcImplInfo
8666

8767
ghcjsVersionImplInfo :: Version -> Version -> GhcImplInfo
8868
ghcjsVersionImplInfo _ghcjsVer _ghcVer = GhcImplInfo
89-
{ hasCcOdirBug = False
90-
, flagInfoLanguages = True
91-
, fakeRecordPuns = False
92-
, flagStubdir = True
93-
, flagOutputDir = True
94-
, noExtInSplitSuffix = False
95-
, flagFfiIncludes = False
96-
, flagBuildingCabalPkg = True
97-
, flagPackageId = True
98-
, separateGccMingw = False
99-
, supportsHaskell2010 = True
69+
{ supportsHaskell2010 = True
10070
, reportsNoExt = True
10171
, alwaysNondecIndent = False
10272
, flagGhciScript = True

Cabal/Distribution/Simple/GHC/Internal.hs

Lines changed: 17 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ configureToolchain :: GhcImplInfo
7171
-> M.Map String String
7272
-> ProgramConfiguration
7373
-> ProgramConfiguration
74-
configureToolchain implInfo ghcProg ghcInfo =
74+
configureToolchain _implInfo ghcProg ghcInfo =
7575
addKnownProgram gccProgram {
7676
programFindLocation = findProg gccProgram extraGccPath,
7777
programPostConf = configureGcc
@@ -90,8 +90,6 @@ configureToolchain implInfo ghcProg ghcInfo =
9090
compilerDir = takeDirectory (programPath ghcProg)
9191
baseDir = takeDirectory compilerDir
9292
mingwBinDir = baseDir </> "mingw" </> "bin"
93-
libDir = baseDir </> "gcc-lib"
94-
includeDir = baseDir </> "include" </> "mingw"
9593
isWindows = case buildOS of Windows -> True; _ -> False
9694
binPrefix = ""
9795

@@ -108,9 +106,7 @@ configureToolchain implInfo ghcProg ghcInfo =
108106

109107
-- on Windows finding and configuring ghc's gcc & binutils is a bit special
110108
(windowsExtraGccDir, windowsExtraLdDir,
111-
windowsExtraArDir, windowsExtraStripDir)
112-
| separateGccMingw implInfo = (baseDir, libDir, libDir, libDir)
113-
| otherwise = -- GHC >= 6.12
109+
windowsExtraArDir, windowsExtraStripDir) =
114110
let b = mingwBinDir </> binPrefix
115111
in (b, b, b, b)
116112

@@ -148,28 +144,12 @@ configureToolchain implInfo ghcProg ghcInfo =
148144
| otherwise -> tokenizeQuotedWords flags
149145

150146
configureGcc :: Verbosity -> ConfiguredProgram -> IO ConfiguredProgram
151-
configureGcc v gccProg = do
152-
gccProg' <- configureGcc' v gccProg
153-
return gccProg' {
154-
programDefaultArgs = programDefaultArgs gccProg'
147+
configureGcc _v gccProg = do
148+
return gccProg {
149+
programDefaultArgs = programDefaultArgs gccProg
155150
++ ccFlags ++ gccLinkerFlags
156151
}
157152

158-
configureGcc' :: Verbosity -> ConfiguredProgram -> IO ConfiguredProgram
159-
configureGcc'
160-
| isWindows = \_ gccProg -> case programLocation gccProg of
161-
-- if it's found on system then it means we're using the result
162-
-- of programFindLocation above rather than a user-supplied path
163-
-- Pre GHC 6.12, that meant we should add these flags to tell
164-
-- ghc's gcc where it lives and thus where gcc can find its
165-
-- various files:
166-
FoundOnSystem {}
167-
| separateGccMingw implInfo ->
168-
return gccProg { programDefaultArgs = ["-B" ++ libDir,
169-
"-I" ++ includeDir] }
170-
_ -> return gccProg
171-
| otherwise = \_ gccProg -> return gccProg
172-
173153
configureLd :: Verbosity -> ConfiguredProgram -> IO ConfiguredProgram
174154
configureLd v ldProg = do
175155
ldProg' <- configureLd' v ldProg
@@ -209,8 +189,7 @@ getLanguages _ implInfo _
209189

210190
getGhcInfo :: Verbosity -> GhcImplInfo -> ConfiguredProgram
211191
-> IO [(String, String)]
212-
getGhcInfo verbosity implInfo ghcProg
213-
| flagInfoLanguages implInfo = do
192+
getGhcInfo verbosity _implInfo ghcProg = do
214193
xs <- getProgramOutput verbosity (suppressOverrideArgs ghcProg)
215194
["--info"]
216195
case reads xs of
@@ -219,13 +198,10 @@ getGhcInfo verbosity implInfo ghcProg
219198
return i
220199
_ ->
221200
die "Can't parse --info output of GHC"
222-
| otherwise =
223-
return []
224201

225202
getExtensions :: Verbosity -> GhcImplInfo -> ConfiguredProgram
226203
-> IO [(Extension, String)]
227-
getExtensions verbosity implInfo ghcProg
228-
| flagInfoLanguages implInfo = do
204+
getExtensions verbosity implInfo ghcProg = do
229205
str <- getProgramOutput verbosity (suppressOverrideArgs ghcProg)
230206
["--supported-languages"]
231207
let extStrs = if reportsNoExt implInfo
@@ -241,88 +217,21 @@ getExtensions verbosity implInfo ghcProg
241217
]
242218
let extensions0 = [ (ext, "-X" ++ display ext)
243219
| Just ext <- map simpleParse extStrs ]
244-
extensions1 = if fakeRecordPuns implInfo
245-
then -- ghc-6.8 introduced RecordPuns however it
246-
-- should have been NamedFieldPuns. We now
247-
-- encourage packages to use NamedFieldPuns
248-
-- so for compatibility we fake support for
249-
-- it in ghc-6.8 by making it an alias for
250-
-- the old RecordPuns extension.
251-
(EnableExtension NamedFieldPuns, "-XRecordPuns") :
252-
(DisableExtension NamedFieldPuns, "-XNoRecordPuns") :
253-
extensions0
254-
else extensions0
255-
extensions2 = if alwaysNondecIndent implInfo
220+
extensions1 = if alwaysNondecIndent implInfo
256221
then -- ghc-7.2 split NondecreasingIndentation off
257222
-- into a proper extension. Before that it
258223
-- was always on.
259224
(EnableExtension NondecreasingIndentation, "") :
260225
(DisableExtension NondecreasingIndentation, "") :
261-
extensions1
262-
else extensions1
263-
return extensions2
264-
265-
| otherwise = return oldLanguageExtensions
266-
267-
-- | For GHC 6.6.x and earlier, the mapping from supported extensions to flags
268-
oldLanguageExtensions :: [(Extension, String)]
269-
oldLanguageExtensions =
270-
let doFlag (f, (enable, disable)) = [(EnableExtension f, enable),
271-
(DisableExtension f, disable)]
272-
fglasgowExts = ("-fglasgow-exts",
273-
"") -- This is wrong, but we don't want to turn
274-
-- all the extensions off when asked to just
275-
-- turn one off
276-
fFlag flag = ("-f" ++ flag, "-fno-" ++ flag)
277-
in concatMap doFlag
278-
[(OverlappingInstances , fFlag "allow-overlapping-instances")
279-
,(TypeSynonymInstances , fglasgowExts)
280-
,(TemplateHaskell , fFlag "th")
281-
,(ForeignFunctionInterface , fFlag "ffi")
282-
,(MonomorphismRestriction , fFlag "monomorphism-restriction")
283-
,(MonoPatBinds , fFlag "mono-pat-binds")
284-
,(UndecidableInstances , fFlag "allow-undecidable-instances")
285-
,(IncoherentInstances , fFlag "allow-incoherent-instances")
286-
,(Arrows , fFlag "arrows")
287-
,(Generics , fFlag "generics")
288-
,(ImplicitPrelude , fFlag "implicit-prelude")
289-
,(ImplicitParams , fFlag "implicit-params")
290-
,(CPP , ("-cpp", ""{- Wrong -}))
291-
,(BangPatterns , fFlag "bang-patterns")
292-
,(KindSignatures , fglasgowExts)
293-
,(RecursiveDo , fglasgowExts)
294-
,(ParallelListComp , fglasgowExts)
295-
,(MultiParamTypeClasses , fglasgowExts)
296-
,(FunctionalDependencies , fglasgowExts)
297-
,(Rank2Types , fglasgowExts)
298-
,(RankNTypes , fglasgowExts)
299-
,(PolymorphicComponents , fglasgowExts)
300-
,(ExistentialQuantification , fglasgowExts)
301-
,(ScopedTypeVariables , fFlag "scoped-type-variables")
302-
,(FlexibleContexts , fglasgowExts)
303-
,(FlexibleInstances , fglasgowExts)
304-
,(EmptyDataDecls , fglasgowExts)
305-
,(PatternGuards , fglasgowExts)
306-
,(GeneralizedNewtypeDeriving , fglasgowExts)
307-
,(MagicHash , fglasgowExts)
308-
,(UnicodeSyntax , fglasgowExts)
309-
,(PatternSignatures , fglasgowExts)
310-
,(UnliftedFFITypes , fglasgowExts)
311-
,(LiberalTypeSynonyms , fglasgowExts)
312-
,(TypeOperators , fglasgowExts)
313-
,(GADTs , fglasgowExts)
314-
,(RelaxedPolyRec , fglasgowExts)
315-
,(ExtendedDefaultRules , fFlag "extended-default-rules")
316-
,(UnboxedTuples , fglasgowExts)
317-
,(DeriveDataTypeable , fglasgowExts)
318-
,(ConstrainedClassMethods , fglasgowExts)
319-
]
226+
extensions0
227+
else extensions0
228+
return extensions1
320229

321230
componentCcGhcOptions :: Verbosity -> GhcImplInfo -> LocalBuildInfo
322231
-> BuildInfo -> ComponentLocalBuildInfo
323232
-> FilePath -> FilePath
324233
-> GhcOptions
325-
componentCcGhcOptions verbosity implInfo lbi bi clbi pref filename =
234+
componentCcGhcOptions verbosity _implInfo lbi bi clbi odir filename =
326235
mempty {
327236
ghcOptVerbosity = toFlag verbosity,
328237
ghcOptMode = toFlag GhcModeCompile,
@@ -344,10 +253,6 @@ componentCcGhcOptions verbosity implInfo lbi bi clbi pref filename =
344253
PD.ccOptions bi,
345254
ghcOptObjDir = toFlag odir
346255
}
347-
where
348-
odir | hasCcOdirBug implInfo = pref </> takeDirectory filename
349-
| otherwise = pref
350-
-- ghc 6.4.0 had a bug in -odir handling for C compilations.
351256

352257
componentGhcOptions :: Verbosity -> LocalBuildInfo
353258
-> BuildInfo -> ComponentLocalBuildInfo -> FilePath
@@ -422,11 +327,9 @@ ghcLookupProperty prop comp =
422327
-- Module_split directory for each module.
423328
getHaskellObjects :: GhcImplInfo -> Library -> LocalBuildInfo
424329
-> FilePath -> String -> Bool -> IO [FilePath]
425-
getHaskellObjects implInfo lib lbi pref wanted_obj_ext allow_split_objs
330+
getHaskellObjects _implInfo lib lbi pref wanted_obj_ext allow_split_objs
426331
| splitObjs lbi && allow_split_objs = do
427-
let splitSuffix = if noExtInSplitSuffix implInfo
428-
then "_split"
429-
else "_" ++ wanted_obj_ext ++ "_split"
332+
let splitSuffix = "_" ++ wanted_obj_ext ++ "_split"
430333
dirs = [ pref </> (ModuleName.toFilePath x ++ splitSuffix)
431334
| x <- libModules lib ]
432335
objss <- mapM getDirectoryContents dirs
@@ -439,10 +342,11 @@ getHaskellObjects implInfo lib lbi pref wanted_obj_ext allow_split_objs
439342
return [ pref </> ModuleName.toFilePath x <.> wanted_obj_ext
440343
| x <- libModules lib ]
441344

345+
-- TODO: rework me
442346
mkGhcOptPackages :: ComponentLocalBuildInfo
443-
-> [(UnitId, PackageId, ModuleRenaming)]
347+
-> [(UnitId, ModuleRenaming)]
444348
mkGhcOptPackages clbi =
445-
map (\(i,p) -> (i,p,lookupRenaming p (componentPackageRenaming clbi)))
349+
map (\(i,p) -> (i,lookupRenaming p (componentPackageRenaming clbi)))
446350
(componentPackageDeps clbi)
447351

448352
substTopDir :: FilePath -> InstalledPackageInfo -> InstalledPackageInfo

Cabal/Distribution/Simple/Program/GHC.hs

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,9 @@ data GhcOptions = GhcOptions {
7979
-- | GHC package databases to use, the @ghc -package-conf@ flag.
8080
ghcOptPackageDBs :: PackageDBStack,
8181

82-
-- | The GHC packages to use. For compatability with old and new ghc, this
83-
-- requires both the short and long form of the package id;
84-
-- the @ghc -package@ or @ghc -package-id@ flags.
82+
-- | The GHC packages to use, the @ghc -package-id@ flags.
8583
ghcOptPackages ::
86-
NubListR (UnitId, PackageId, ModuleRenaming),
84+
NubListR (UnitId, ModuleRenaming),
8785

8886
-- | Start with a clean package set; the @ghc -hide-all-packages@ flag
8987
ghcOptHideAllPackages :: Flag Bool,
@@ -269,8 +267,7 @@ renderGhcOptions comp opts
269267

270268
, maybe [] verbosityOpts (flagToMaybe (ghcOptVerbosity opts))
271269

272-
, [ "-fbuilding-cabal-package" | flagBool ghcOptCabal
273-
, flagBuildingCabalPkg implInfo ]
270+
, [ "-fbuilding-cabal-package" | flagBool ghcOptCabal ]
274271

275272
----------------
276273
-- Compilation
@@ -332,12 +329,10 @@ renderGhcOptions comp opts
332329
, concat [ ["-hisuf", suf] | suf <- flag ghcOptHiSuffix ]
333330
, concat [ ["-dynosuf", suf] | suf <- flag ghcOptDynObjSuffix ]
334331
, concat [ ["-dynhisuf",suf] | suf <- flag ghcOptDynHiSuffix ]
335-
, concat [ ["-outputdir", dir] | dir <- flag ghcOptOutputDir
336-
, flagOutputDir implInfo ]
332+
, concat [ ["-outputdir", dir] | dir <- flag ghcOptOutputDir ]
337333
, concat [ ["-odir", dir] | dir <- flag ghcOptObjDir ]
338334
, concat [ ["-hidir", dir] | dir <- flag ghcOptHiDir ]
339-
, concat [ ["-stubdir", dir] | dir <- flag ghcOptStubDir
340-
, flagStubdir implInfo ]
335+
, concat [ ["-stubdir", dir] | dir <- flag ghcOptStubDir ]
341336

342337
-----------------------
343338
-- Source search path
@@ -352,8 +347,6 @@ renderGhcOptions comp opts
352347
, [ "-optP" ++ opt | opt <- flags ghcOptCppOptions ]
353348
, concat [ [ "-optP-include", "-optP" ++ inc]
354349
| inc <- flags ghcOptCppIncludes ]
355-
, [ "-#include \"" ++ inc ++ "\""
356-
| inc <- flags ghcOptFfiIncludes, flagFfiIncludes implInfo ]
357350
, [ "-optc" ++ opt | opt <- flags ghcOptCcOptions ]
358351

359352
-----------------
@@ -383,13 +376,10 @@ renderGhcOptions comp opts
383376

384377
, packageDbArgs implInfo (ghcOptPackageDBs opts)
385378

386-
, concat $ if flagPackageId implInfo
387-
then let space "" = ""
388-
space xs = ' ' : xs
389-
in [ ["-package-id", display ipkgid ++ space (display rns)]
390-
| (ipkgid,_,rns) <- flags ghcOptPackages ]
391-
else [ ["-package", display pkgid]
392-
| (_,pkgid,_) <- flags ghcOptPackages ]
379+
, concat $ let space "" = ""
380+
space xs = ' ' : xs
381+
in [ ["-package-id", display ipkgid ++ space (display rns)]
382+
| (ipkgid,rns) <- flags ghcOptPackages ]
393383

394384
----------------------------
395385
-- Language and extensions

cabal-install/Distribution/Client/SetupWrapper.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ externalSetupMethod verbosity options pkg bt mkargs = do
614614
selectedDeps | useDependenciesExclusive options'
615615
= useDependencies options'
616616
| otherwise = useDependencies options' ++ cabalDep
617-
addRenaming (ipid, pid) = (ipid, pid, defaultRenaming)
617+
addRenaming (ipid, _) = (ipid, defaultRenaming)
618618
cppMacrosFile = setupDir </> "setup_macros.h"
619619
ghcOptions = mempty {
620620
ghcOptVerbosity = Flag verbosity

0 commit comments

Comments
 (0)