Skip to content

Commit 1c0e334

Browse files
committed
Merge pull request #3111 from ezyang/cabal-window-to-6-12
Change Cabal's GHC support window to GHC 6.12 or later
2 parents e786c34 + e1c39fc commit 1c0e334

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
@@ -72,7 +72,7 @@ configureToolchain :: GhcImplInfo
7272
-> M.Map String String
7373
-> ProgramConfiguration
7474
-> ProgramConfiguration
75-
configureToolchain implInfo ghcProg ghcInfo =
75+
configureToolchain _implInfo ghcProg ghcInfo =
7676
addKnownProgram gccProgram {
7777
programFindLocation = findProg gccProgramName extraGccPath,
7878
programPostConf = configureGcc
@@ -91,8 +91,6 @@ configureToolchain implInfo ghcProg ghcInfo =
9191
compilerDir = takeDirectory (programPath ghcProg)
9292
baseDir = takeDirectory compilerDir
9393
mingwBinDir = baseDir </> "mingw" </> "bin"
94-
libDir = baseDir </> "gcc-lib"
95-
includeDir = baseDir </> "include" </> "mingw"
9694
isWindows = case buildOS of Windows -> True; _ -> False
9795
binPrefix = ""
9896

@@ -117,9 +115,7 @@ configureToolchain implInfo ghcProg ghcInfo =
117115

118116
-- on Windows finding and configuring ghc's gcc & binutils is a bit special
119117
(windowsExtraGccDir, windowsExtraLdDir,
120-
windowsExtraArDir, windowsExtraStripDir)
121-
| separateGccMingw implInfo = (baseDir, libDir, libDir, libDir)
122-
| otherwise = -- GHC >= 6.12
118+
windowsExtraArDir, windowsExtraStripDir) =
123119
let b = mingwBinDir </> binPrefix
124120
in (b, b, b, b)
125121

@@ -157,28 +153,12 @@ configureToolchain implInfo ghcProg ghcInfo =
157153
| otherwise -> tokenizeQuotedWords flags
158154

159155
configureGcc :: Verbosity -> ConfiguredProgram -> IO ConfiguredProgram
160-
configureGcc v gccProg = do
161-
gccProg' <- configureGcc' v gccProg
162-
return gccProg' {
163-
programDefaultArgs = programDefaultArgs gccProg'
156+
configureGcc _v gccProg = do
157+
return gccProg {
158+
programDefaultArgs = programDefaultArgs gccProg
164159
++ ccFlags ++ gccLinkerFlags
165160
}
166161

167-
configureGcc' :: Verbosity -> ConfiguredProgram -> IO ConfiguredProgram
168-
configureGcc'
169-
| isWindows = \_ gccProg -> case programLocation gccProg of
170-
-- if it's found on system then it means we're using the result
171-
-- of programFindLocation above rather than a user-supplied path
172-
-- Pre GHC 6.12, that meant we should add these flags to tell
173-
-- ghc's gcc where it lives and thus where gcc can find its
174-
-- various files:
175-
FoundOnSystem {}
176-
| separateGccMingw implInfo ->
177-
return gccProg { programDefaultArgs = ["-B" ++ libDir,
178-
"-I" ++ includeDir] }
179-
_ -> return gccProg
180-
| otherwise = \_ gccProg -> return gccProg
181-
182162
configureLd :: Verbosity -> ConfiguredProgram -> IO ConfiguredProgram
183163
configureLd v ldProg = do
184164
ldProg' <- configureLd' v ldProg
@@ -218,8 +198,7 @@ getLanguages _ implInfo _
218198

219199
getGhcInfo :: Verbosity -> GhcImplInfo -> ConfiguredProgram
220200
-> IO [(String, String)]
221-
getGhcInfo verbosity implInfo ghcProg
222-
| flagInfoLanguages implInfo = do
201+
getGhcInfo verbosity _implInfo ghcProg = do
223202
xs <- getProgramOutput verbosity (suppressOverrideArgs ghcProg)
224203
["--info"]
225204
case reads xs of
@@ -228,13 +207,10 @@ getGhcInfo verbosity implInfo ghcProg
228207
return i
229208
_ ->
230209
die "Can't parse --info output of GHC"
231-
| otherwise =
232-
return []
233210

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

330239
componentCcGhcOptions :: Verbosity -> GhcImplInfo -> LocalBuildInfo
331240
-> BuildInfo -> ComponentLocalBuildInfo
332241
-> FilePath -> FilePath
333242
-> GhcOptions
334-
componentCcGhcOptions verbosity implInfo lbi bi clbi pref filename =
243+
componentCcGhcOptions verbosity _implInfo lbi bi clbi odir filename =
335244
mempty {
336245
ghcOptVerbosity = toFlag verbosity,
337246
ghcOptMode = toFlag GhcModeCompile,
@@ -353,10 +262,6 @@ componentCcGhcOptions verbosity implInfo lbi bi clbi pref filename =
353262
PD.ccOptions bi,
354263
ghcOptObjDir = toFlag odir
355264
}
356-
where
357-
odir | hasCcOdirBug implInfo = pref </> takeDirectory filename
358-
| otherwise = pref
359-
-- ghc 6.4.0 had a bug in -odir handling for C compilations.
360265

361266
componentGhcOptions :: Verbosity -> LocalBuildInfo
362267
-> BuildInfo -> ComponentLocalBuildInfo -> FilePath
@@ -431,11 +336,9 @@ ghcLookupProperty prop comp =
431336
-- Module_split directory for each module.
432337
getHaskellObjects :: GhcImplInfo -> Library -> LocalBuildInfo
433338
-> FilePath -> String -> Bool -> IO [FilePath]
434-
getHaskellObjects implInfo lib lbi pref wanted_obj_ext allow_split_objs
339+
getHaskellObjects _implInfo lib lbi pref wanted_obj_ext allow_split_objs
435340
| splitObjs lbi && allow_split_objs = do
436-
let splitSuffix = if noExtInSplitSuffix implInfo
437-
then "_split"
438-
else "_" ++ wanted_obj_ext ++ "_split"
341+
let splitSuffix = "_" ++ wanted_obj_ext ++ "_split"
439342
dirs = [ pref </> (ModuleName.toFilePath x ++ splitSuffix)
440343
| x <- libModules lib ]
441344
objss <- mapM getDirectoryContents dirs
@@ -448,10 +351,11 @@ getHaskellObjects implInfo lib lbi pref wanted_obj_ext allow_split_objs
448351
return [ pref </> ModuleName.toFilePath x <.> wanted_obj_ext
449352
| x <- libModules lib ]
450353

354+
-- TODO: rework me
451355
mkGhcOptPackages :: ComponentLocalBuildInfo
452-
-> [(UnitId, PackageId, ModuleRenaming)]
356+
-> [(UnitId, ModuleRenaming)]
453357
mkGhcOptPackages clbi =
454-
map (\(i,p) -> (i,p,lookupRenaming p (componentPackageRenaming clbi)))
358+
map (\(i,p) -> (i,lookupRenaming p (componentPackageRenaming clbi)))
455359
(componentPackageDeps clbi)
456360

457361
substTopDir :: FilePath -> InstalledPackageInfo -> InstalledPackageInfo

Cabal/Distribution/Simple/Program/GHC.hs

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

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

9290
-- | Start with a clean package set; the @ghc -hide-all-packages@ flag
9391
ghcOptHideAllPackages :: Flag Bool,
@@ -279,8 +277,7 @@ renderGhcOptions comp _platform@(Platform _arch os) opts
279277

280278
, maybe [] verbosityOpts (flagToMaybe (ghcOptVerbosity opts))
281279

282-
, [ "-fbuilding-cabal-package" | flagBool ghcOptCabal
283-
, flagBuildingCabalPkg implInfo ]
280+
, [ "-fbuilding-cabal-package" | flagBool ghcOptCabal ]
284281

285282
----------------
286283
-- Compilation
@@ -342,12 +339,10 @@ renderGhcOptions comp _platform@(Platform _arch os) opts
342339
, concat [ ["-hisuf", suf] | suf <- flag ghcOptHiSuffix ]
343340
, concat [ ["-dynosuf", suf] | suf <- flag ghcOptDynObjSuffix ]
344341
, concat [ ["-dynhisuf",suf] | suf <- flag ghcOptDynHiSuffix ]
345-
, concat [ ["-outputdir", dir] | dir <- flag ghcOptOutputDir
346-
, flagOutputDir implInfo ]
342+
, concat [ ["-outputdir", dir] | dir <- flag ghcOptOutputDir ]
347343
, concat [ ["-odir", dir] | dir <- flag ghcOptObjDir ]
348344
, concat [ ["-hidir", dir] | dir <- flag ghcOptHiDir ]
349-
, concat [ ["-stubdir", dir] | dir <- flag ghcOptStubDir
350-
, flagStubdir implInfo ]
345+
, concat [ ["-stubdir", dir] | dir <- flag ghcOptStubDir ]
351346

352347
-----------------------
353348
-- Source search path
@@ -362,8 +357,6 @@ renderGhcOptions comp _platform@(Platform _arch os) opts
362357
, [ "-optP" ++ opt | opt <- flags ghcOptCppOptions ]
363358
, concat [ [ "-optP-include", "-optP" ++ inc]
364359
| inc <- flags ghcOptCppIncludes ]
365-
, [ "-#include \"" ++ inc ++ "\""
366-
| inc <- flags ghcOptFfiIncludes, flagFfiIncludes implInfo ]
367360
, [ "-optc" ++ opt | opt <- flags ghcOptCcOptions ]
368361

369362
-----------------
@@ -400,13 +393,10 @@ renderGhcOptions comp _platform@(Platform _arch os) opts
400393

401394
, packageDbArgs implInfo (ghcOptPackageDBs opts)
402395

403-
, concat $ if flagPackageId implInfo
404-
then let space "" = ""
405-
space xs = ' ' : xs
406-
in [ ["-package-id", display ipkgid ++ space (display rns)]
407-
| (ipkgid,_,rns) <- flags ghcOptPackages ]
408-
else [ ["-package", display pkgid]
409-
| (_,pkgid,_) <- flags ghcOptPackages ]
396+
, concat $ let space "" = ""
397+
space xs = ' ' : xs
398+
in [ ["-package-id", display ipkgid ++ space (display rns)]
399+
| (ipkgid,rns) <- flags ghcOptPackages ]
410400

411401
----------------------------
412402
-- 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)