Commits (46)
:set -icabal-install -icabal-install/main
:load Main
--command "ghci -j4 +RTS -A128m"
......@@ -27,7 +27,7 @@ branches:
# TAGSUFFIX to help travis/upload.sh disambiguate the matrix entry.
matrix:
include:
- env: GHCVER=8.4.2 SCRIPT=meta BUILDER=none
- env: GHCVER=8.4.3 SCRIPT=meta BUILDER=none
os: linux
sudo: required
# These don't have -dyn/-prof whitelisted yet, so we have to
......@@ -55,20 +55,20 @@ matrix:
- env: GHCVER=8.2.2 SCRIPT=script USE_GOLD=YES
os: linux
sudo: required
- env: GHCVER=8.4.2 SCRIPT=script USE_GOLD=YES DEPLOY_DOCS=YES
- env: GHCVER=8.4.3 SCRIPT=script USE_GOLD=YES DEPLOY_DOCS=YES
os: linux
sudo: required
- env: GHCVER=8.4.2 SCRIPT=solver-debug-flags USE_GOLD=YES
- env: GHCVER=8.4.3 SCRIPT=solver-debug-flags USE_GOLD=YES
sudo: required
os: linux
- env: GHCVER=8.4.2 SCRIPT=script DEBUG_EXPENSIVE_ASSERTIONS=YES TAGSUFFIX="-fdebug-expensive-assertions" USE_GOLD=YES
- env: GHCVER=8.4.3 SCRIPT=script DEBUG_EXPENSIVE_ASSERTIONS=YES TAGSUFFIX="-fdebug-expensive-assertions" USE_GOLD=YES
os: linux
sudo: required
- env: GHCVER=8.0.2 SCRIPT=bootstrap USE_GOLD=YES
sudo: required
os: linux
- env: GHCVER=8.4.2 SCRIPT=bootstrap USE_GOLD=YES
- env: GHCVER=8.4.3 SCRIPT=bootstrap USE_GOLD=YES
sudo: required
os: linux
......
......@@ -75,12 +75,16 @@ extra-source-files:
tests/ParserTests/regressions/Octree-0.5.format
tests/ParserTests/regressions/bad-glob-syntax.cabal
tests/ParserTests/regressions/bad-glob-syntax.check
tests/ParserTests/regressions/cc-options-with-optimization.cabal
tests/ParserTests/regressions/cc-options-with-optimization.check
tests/ParserTests/regressions/common.cabal
tests/ParserTests/regressions/common.expr
tests/ParserTests/regressions/common.format
tests/ParserTests/regressions/common2.cabal
tests/ParserTests/regressions/common2.expr
tests/ParserTests/regressions/common2.format
tests/ParserTests/regressions/cxx-options-with-optimization.cabal
tests/ParserTests/regressions/cxx-options-with-optimization.check
tests/ParserTests/regressions/elif.cabal
tests/ParserTests/regressions/elif.expr
tests/ParserTests/regressions/elif.format
......@@ -95,6 +99,8 @@ extra-source-files:
tests/ParserTests/regressions/generics-sop.cabal
tests/ParserTests/regressions/generics-sop.expr
tests/ParserTests/regressions/generics-sop.format
tests/ParserTests/regressions/ghc-option-j.cabal
tests/ParserTests/regressions/ghc-option-j.check
tests/ParserTests/regressions/haddock-api-2.18.1-check.cabal
tests/ParserTests/regressions/haddock-api-2.18.1-check.check
tests/ParserTests/regressions/issue-5055.cabal
......@@ -270,7 +276,6 @@ library
Distribution.Simple.Hpc
Distribution.Simple.Install
Distribution.Simple.InstallDirs
Distribution.Simple.JHC
Distribution.Simple.LocalBuildInfo
Distribution.Simple.PackageIndex
Distribution.Simple.PreProcess
......
# 2.4.0.0 (current development version)
* Added `BlockArguments` to `KnownExtension` (#5101).
* Added `NumericUnderscores` to `KnownExtension` (#5130).
* Added `BlockArguments` to `KnownExtension`
([#5101](https://github.com/haskell/cabal/issues/5101)).
* Added `NumericUnderscores` to `KnownExtension`
([#5130]((https://github.com/haskell/cabal/issues/5130)).
* `buildDepends` is removed from `PackageDescription`. It had long been
uselessly hanging about as top-level build-depends already got put
into per-component condition trees anyway. Now it's finally been put
out of its misery (#4383).
out of its misery
([#4383](https://github.com/haskell/cabal/issues/4283)).
* Added `Eta` to `CompilerFlavor` and to known compilers.
* `cabal haddock` now generates per-component documentation (#5226).
* `cabal haddock` now generates per-component documentation
([#5226](https://github.com/haskell/cabal/issues/5226)).
* Allow `**` wildcards in `data-files`, `extra-source-files` and
`extra-doc-files`. These allow a limited form of recursive
matching, and require `cabal-version: 3.0`.
......@@ -19,7 +23,20 @@
have beem moved from `Distribution.Simple.Utils` to a new file,
`Distribution.Simple.Glob` and `FileGlob` has been made abstract.
(#5284, #3178, et al.)
([#5284](https://github.com/haskell/cabal/issues/5284), [#3178](https://github.com/haskell/cabal/issues/3178), et al.)
* Fixed `cxx-options` and `cxx-sources` buildinfo fields for
separate compilation of C++ source files to correctly build and link
non-library components ([#5309](https://github.com/haskell/cabal/issues/5309)).
* Reduced warnings generated by hsc2hs and c2hs when `cxx-options` field
is present in a component.
* `cabal check` now warns if `-j` is used in `ghc-options` in a Cabal
file. ([#5277](https://github.com/haskell/cabal/issues/5277))
* `install-includes` now works as expected with foreign libraries
([#5302](https://github.com/haskell/cabal/issues/5299)).
* Removed support for JHC.
* Options listed in `ghc-options`, `cc-options`, `ld-options`,
`cxx-options`, `cpp-options` are not deduplicated anymore
([#4449](https://github.com/haskell/cabal/issues/4449)).
----
......
......@@ -169,7 +169,7 @@ toConfiguredComponent pkg_descr this_cid dep_map component = do
value <- case Map.lookup cn =<< Map.lookup pn dep_map of
Nothing ->
dieProgress $
text "Dependency on unbuildable" <+>
text "Dependency on unbuildable (i.e. 'buildable: False')" <+>
text (showComponentName cn) <+>
text "from" <+> disp pn
Just v -> return v
......
......@@ -33,7 +33,6 @@ import qualified System.Posix
-- This is here for Haskell implementations that do not come with
-- System.IO.openTempFile. This includes nhc-1.20, hugs-2006.9.
-- TODO: Not sure about JHC
-- TODO: This file should probably be removed.
-- This is a copy/paste of the openBinaryTempFile definition, but
......
......@@ -16,7 +16,6 @@
--
-- > case compilerFlavor comp of
-- > GHC -> GHC.getInstalledPackages verbosity packageDb progdb
-- > JHC -> JHC.getInstalledPackages verbosity packageDb progdb
--
-- Obviously it would be better to use the proper 'Compiler' abstraction
-- because that would keep all the compiler-specific code together.
......@@ -33,6 +32,7 @@ module Distribution.Compiler (
defaultCompilerFlavor,
parseCompilerFlavorCompat,
classifyCompilerFlavor,
knownCompilerFlavors,
-- * Compiler id
CompilerId(..),
......@@ -59,7 +59,7 @@ import qualified Distribution.Compat.CharParsing as P
import qualified Text.PrettyPrint as Disp
data CompilerFlavor =
GHC | GHCJS | NHC | YHC | Hugs | HBC | Helium | JHC | UHC | Eta
GHC | GHCJS | NHC | YHC | Hugs | HBC | Helium | JHC | LHC | UHC | Eta
| HaskellSuite String -- string is the id of the actual compiler
| OtherCompiler String
deriving (Generic, Show, Read, Eq, Ord, Typeable, Data)
......@@ -70,7 +70,7 @@ instance NFData CompilerFlavor where rnf = genericRnf
knownCompilerFlavors :: [CompilerFlavor]
knownCompilerFlavors =
[GHC, GHCJS, NHC, YHC, Hugs, HBC, Helium, JHC, UHC, Eta]
[GHC, GHCJS, NHC, YHC, Hugs, HBC, Helium, JHC, LHC, UHC, Eta]
instance Pretty CompilerFlavor where
pretty (OtherCompiler name) = Disp.text name
......
......@@ -165,6 +165,7 @@ checkConfiguredPackage pkg =
++ checkSourceRepos pkg
++ checkGhcOptions pkg
++ checkCCOptions pkg
++ checkCxxOptions pkg
++ checkCPPOptions pkg
++ checkPaths pkg
++ checkCabalVersion pkg
......@@ -960,17 +961,23 @@ checkGhcOptions pkg =
disable e = Just (DisableExtension e)
checkCCOptions :: PackageDescription -> [PackageCheck]
checkCCOptions pkg =
checkCCOptions = checkCLikeOptions "C" "cc-options" ccOptions
checkCxxOptions :: PackageDescription -> [PackageCheck]
checkCxxOptions = checkCLikeOptions "C++" "cxx-options" cxxOptions
checkCLikeOptions :: String -> String -> (BuildInfo -> [String]) -> PackageDescription -> [PackageCheck]
checkCLikeOptions label prefix accessor pkg =
catMaybes [
checkAlternatives "cc-options" "include-dirs"
[ (flag, dir) | flag@('-':'I':dir) <- all_ccOptions ]
checkAlternatives prefix "include-dirs"
[ (flag, dir) | flag@('-':'I':dir) <- all_cLikeOptions ]
, checkAlternatives "cc-options" "extra-libraries"
[ (flag, lib) | flag@('-':'l':lib) <- all_ccOptions ]
, checkAlternatives prefix "extra-libraries"
[ (flag, lib) | flag@('-':'l':lib) <- all_cLikeOptions ]
, checkAlternatives "cc-options" "extra-lib-dirs"
[ (flag, dir) | flag@('-':'L':dir) <- all_ccOptions ]
, checkAlternatives prefix "extra-lib-dirs"
[ (flag, dir) | flag@('-':'L':dir) <- all_cLikeOptions ]
, checkAlternatives "ld-options" "extra-libraries"
[ (flag, lib) | flag@('-':'l':lib) <- all_ldOptions ]
......@@ -980,19 +987,18 @@ checkCCOptions pkg =
, checkCCFlags [ "-O", "-Os", "-O0", "-O1", "-O2", "-O3" ] $
PackageDistSuspicious $
"'cc-options: -O[n]' is generally not needed. When building with "
++ " optimisations Cabal automatically adds '-O2' for C code. "
++ "Setting it yourself interferes with the --disable-optimization "
++ "flag."
"'"++prefix++": -O[n]' is generally not needed. When building with "
++ " optimisations Cabal automatically adds '-O2' for "++label++" code. "
++ "Setting it yourself interferes with the --disable-optimization flag."
]
where all_ccOptions = [ opts | bi <- allBuildInfo pkg
, opts <- ccOptions bi ]
where all_cLikeOptions = [ opts | bi <- allBuildInfo pkg
, opts <- accessor bi ]
all_ldOptions = [ opts | bi <- allBuildInfo pkg
, opts <- ldOptions bi ]
checkCCFlags :: [String] -> PackageCheck -> Maybe PackageCheck
checkCCFlags flags = check (any (`elem` flags) all_ccOptions)
checkCCFlags flags = check (any (`elem` flags) all_cLikeOptions)
checkCPPOptions :: PackageDescription -> [PackageCheck]
checkCPPOptions pkg =
......@@ -1703,6 +1709,12 @@ checkDevelopmentOnlyFlagsBuildInfo bi =
++ "add new warnings. "
++ extraExplanation
, check (has_J) $
PackageDistInexcusable $
"'ghc-options: -j[N]' can make sense for specific user's setup,"
++ " but it is not appropriate for a distributed package."
++ extraExplanation
, checkFlags ["-fdefer-type-errors"] $
PackageDistInexcusable $
"'ghc-options: -fdefer-type-errors' is fine during development but "
......@@ -1740,6 +1752,13 @@ checkDevelopmentOnlyFlagsBuildInfo bi =
has_Werror = "-Werror" `elem` ghc_options
has_Wall = "-Wall" `elem` ghc_options
has_W = "-W" `elem` ghc_options
has_J = any
(\o -> case o of
"-j" -> True
('-' : 'j' : d : _) -> isDigit d
_ -> False
)
ghc_options
ghc_options = hcOptions GHC bi ++ hcProfOptions GHC bi
++ hcSharedOptions GHC bi
......
......@@ -432,17 +432,18 @@ optionsFieldGrammar
optionsFieldGrammar = combine
<$> monoidalFieldAla "ghc-options" (alaList' NoCommaFSep Token') (extract GHC)
<*> monoidalFieldAla "ghcjs-options" (alaList' NoCommaFSep Token') (extract GHCJS)
<*> monoidalFieldAla "jhc-options" (alaList' NoCommaFSep Token') (extract JHC)
-- NOTE: Hugs and NHC are not supported anymore, but these fields are kept
-- around for backwards compatibility.
-- NOTE: Hugs, NHC and JHC are not supported anymore, but these
-- fields are kept around so that we can still parse legacy .cabal
-- files that have them.
<* knownField "jhc-options"
<* knownField "hugs-options"
<* knownField "nhc98-options"
where
extract :: CompilerFlavor -> ALens' BuildInfo [String]
extract flavor = L.options . lookupLens flavor
combine ghc ghcjs jhs =
f GHC ghc ++ f GHCJS ghcjs ++ f JHC jhs
combine ghc ghcjs =
f GHC ghc ++ f GHCJS ghcjs
where
f _flavor [] = []
f flavor opts = [(flavor, opts)]
......
......@@ -46,7 +46,6 @@ import Distribution.Backpack
import Distribution.Backpack.DescribeUnitId
import qualified Distribution.Simple.GHC as GHC
import qualified Distribution.Simple.GHCJS as GHCJS
import qualified Distribution.Simple.JHC as JHC
import qualified Distribution.Simple.UHC as UHC
import qualified Distribution.Simple.HaskellSuite as HaskellSuite
import qualified Distribution.Simple.PackageIndex as Index
......@@ -579,7 +578,6 @@ buildLib verbosity numJobs pkg_descr lbi lib clbi =
case compilerFlavor (compiler lbi) of
GHC -> GHC.buildLib verbosity numJobs pkg_descr lbi lib clbi
GHCJS -> GHCJS.buildLib verbosity numJobs pkg_descr lbi lib clbi
JHC -> JHC.buildLib verbosity pkg_descr lbi lib clbi
UHC -> UHC.buildLib verbosity pkg_descr lbi lib clbi
HaskellSuite {} -> HaskellSuite.buildLib verbosity pkg_descr lbi lib clbi
_ -> die' verbosity "Building is not supported with this compiler."
......@@ -603,7 +601,6 @@ buildExe verbosity numJobs pkg_descr lbi exe clbi =
case compilerFlavor (compiler lbi) of
GHC -> GHC.buildExe verbosity numJobs pkg_descr lbi exe clbi
GHCJS -> GHCJS.buildExe verbosity numJobs pkg_descr lbi exe clbi
JHC -> JHC.buildExe verbosity pkg_descr lbi exe clbi
UHC -> UHC.buildExe verbosity pkg_descr lbi exe clbi
_ -> die' verbosity "Building is not supported with this compiler."
......
......@@ -62,8 +62,7 @@ generate pkg_descr lbi clbi =
| supports_language_pragma =
"{-# LANGUAGE ForeignFunctionInterface #-}\n"
| otherwise =
"{-# OPTIONS_GHC -fffi #-}\n"++
"{-# OPTIONS_JHC -fffi #-}\n"
"{-# OPTIONS_GHC -fffi #-}\n"
warning_pragmas =
"{-# OPTIONS_GHC -fno-warn-missing-import-lists #-}\n"
......
......@@ -453,6 +453,7 @@ data ComponentInfo = ComponentInfo {
cinfoAsmFiles:: [FilePath],
cinfoCmmFiles:: [FilePath],
cinfoCFiles :: [FilePath],
cinfoCxxFiles:: [FilePath],
cinfoJsFiles :: [FilePath]
}
......@@ -469,6 +470,7 @@ pkgComponentInfo pkg =
cinfoAsmFiles= asmSources bi,
cinfoCmmFiles= cmmSources bi,
cinfoCFiles = cSources bi,
cinfoCxxFiles= cxxSources bi,
cinfoJsFiles = jsSources bi
}
| c <- pkgComponents pkg
......
......@@ -105,7 +105,6 @@ import Distribution.Utils.LogProgress
import qualified Distribution.Simple.GHC as GHC
import qualified Distribution.Simple.GHCJS as GHCJS
import qualified Distribution.Simple.JHC as JHC
import qualified Distribution.Simple.UHC as UHC
import qualified Distribution.Simple.HaskellSuite as HaskellSuite
......@@ -1289,7 +1288,6 @@ getInstalledPackages verbosity comp packageDBs progdb = do
case compilerFlavor comp of
GHC -> GHC.getInstalledPackages verbosity comp packageDBs progdb
GHCJS -> GHCJS.getInstalledPackages verbosity packageDBs progdb
JHC -> JHC.getInstalledPackages verbosity packageDBs progdb
UHC -> UHC.getInstalledPackages verbosity comp packageDBs progdb
HaskellSuite {} ->
HaskellSuite.getInstalledPackages verbosity packageDBs progdb
......@@ -1601,7 +1599,6 @@ configCompilerEx (Just hcFlavor) hcPath hcPkg progdb verbosity = do
(comp, maybePlatform, programDb) <- case hcFlavor of
GHC -> GHC.configure verbosity hcPath hcPkg progdb
GHCJS -> GHCJS.configure verbosity hcPath hcPkg progdb
JHC -> JHC.configure verbosity hcPath hcPkg progdb
UHC -> UHC.configure verbosity hcPath hcPkg progdb
HaskellSuite {} -> HaskellSuite.configure verbosity hcPath hcPkg progdb
_ -> die' verbosity "Unknown compiler"
......
......@@ -37,7 +37,6 @@ import Distribution.Simple.Register (internalPackageDBPath)
import Distribution.Simple.BuildPaths
import Distribution.Simple.Utils
import Distribution.System
import Distribution.Utils.NubList
import Distribution.Version
import Distribution.Verbosity
......@@ -132,7 +131,7 @@ mkDoctestArgs verbosity tmp lbi clbi inFiles bi = do
, ghcOptFPic = toFlag True
, ghcOptHiSuffix = toFlag "dyn_hi"
, ghcOptObjSuffix = toFlag "dyn_o"
, ghcOptExtra = toNubListR (hcSharedOptions GHC bi)}
, ghcOptExtra = hcSharedOptions GHC bi}
opts <- if withVanillaLib lbi
then return vanillaOpts
else if withSharedLib lbi
......
......@@ -582,7 +582,7 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
(withProfLibDetail lbi),
ghcOptHiSuffix = toFlag "p_hi",
ghcOptObjSuffix = toFlag "p_o",
ghcOptExtra = toNubListR $ hcProfOptions GHC libBi,
ghcOptExtra = hcProfOptions GHC libBi,
ghcOptHPCDir = hpcdir Hpc.Prof
}
......@@ -591,23 +591,20 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
ghcOptFPic = toFlag True,
ghcOptHiSuffix = toFlag "dyn_hi",
ghcOptObjSuffix = toFlag "dyn_o",
ghcOptExtra = toNubListR $ hcSharedOptions GHC libBi,
ghcOptExtra = hcSharedOptions GHC libBi,
ghcOptHPCDir = hpcdir Hpc.Dyn
}
linkerOpts = mempty {
ghcOptLinkOptions = toNubListR $ PD.ldOptions libBi,
ghcOptLinkLibs = toNubListR $ extraLibs libBi,
ghcOptLinkOptions = PD.ldOptions libBi,
ghcOptLinkLibs = extraLibs libBi,
ghcOptLinkLibPath = toNubListR $ extraLibDirs libBi,
ghcOptLinkFrameworks = toNubListR $
PD.frameworks libBi,
ghcOptLinkFrameworkDirs = toNubListR $
PD.extraFrameworkDirs libBi,
ghcOptLinkFrameworks = toNubListR $ PD.frameworks libBi,
ghcOptLinkFrameworkDirs = toNubListR $ PD.extraFrameworkDirs libBi,
ghcOptInputFiles = toNubListR
[libTargetDir </> x | x <- cObjs]
}
replOpts = vanillaOpts {
ghcOptExtra = overNubListR
Internal.filterGhciFlags $
ghcOptExtra = Internal.filterGhciFlags $
ghcOptExtra vanillaOpts,
ghcOptNumJobs = mempty
}
......@@ -657,14 +654,14 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
info verbosity "Building C++ Sources..."
sequence_
[ do let baseCxxOpts = Internal.componentCxxGhcOptions verbosity implInfo
lbi libBi clbi libTargetDir filename
lbi libBi clbi libTargetDir filename
vanillaCxxOpts = if isGhcDynamic
then baseCxxOpts { ghcOptFPic = toFlag True }
else baseCxxOpts
profCxxOpts = vanillaCxxOpts `mappend` mempty {
ghcOptProfilingMode = toFlag True,
ghcOptObjSuffix = toFlag "p_o"
}
ghcOptProfilingMode = toFlag True,
ghcOptObjSuffix = toFlag "p_o"
}
sharedCxxOpts = vanillaCxxOpts `mappend` mempty {
ghcOptFPic = toFlag True,
ghcOptDynLinkMode = toFlag GhcDynamicOnly,
......@@ -794,8 +791,7 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
ghcOptDynLinkMode = toFlag GhcDynamicOnly,
ghcOptInputFiles = toNubListR dynamicObjectFiles,
ghcOptOutputFile = toFlag sharedLibFilePath,
ghcOptExtra = toNubListR $
hcSharedOptions GHC libBi,
ghcOptExtra = hcSharedOptions GHC libBi,
-- 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.
......@@ -822,7 +818,7 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
_ -> [],
ghcOptPackages = toNubListR $
Internal.mkGhcOptPackages clbi ,
ghcOptLinkLibs = toNubListR $ extraLibs libBi,
ghcOptLinkLibs = extraLibs libBi,
ghcOptLinkLibPath = toNubListR $ extraLibDirs libBi,
ghcOptLinkFrameworks = toNubListR $ PD.frameworks libBi,
ghcOptLinkFrameworkDirs =
......@@ -834,8 +830,7 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
ghcOptStaticLib = toFlag True,
ghcOptInputFiles = toNubListR staticObjectFiles,
ghcOptOutputFile = toFlag staticLibFilePath,
ghcOptExtra = toNubListR $
hcStaticOptions GHC libBi,
ghcOptExtra = hcStaticOptions GHC libBi,
ghcOptHideAllPackages = toFlag True,
ghcOptNoAutoLinkPackages = toFlag True,
ghcOptPackageDBs = withPackageDB lbi,
......@@ -855,7 +850,7 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
_ -> [],
ghcOptPackages = toNubListR $
Internal.mkGhcOptPackages clbi ,
ghcOptLinkLibs = toNubListR $ extraLibs libBi,
ghcOptLinkLibs = extraLibs libBi,
ghcOptLinkLibPath = toNubListR $ extraLibDirs libBi
}
......@@ -1083,12 +1078,27 @@ decodeMainIsArg arg
-- 'tail' drops the char satisfying 'pred'
where (r_suf, r_pre) = break pred' (reverse str)
-- | Return C sources, GHC input files and GHC input modules
-- | A collection of:
-- * C input files
-- * C++ input files
-- * GHC input files
-- * GHC input modules
--
-- Used to correctly build and link sources.
data BuildSources = BuildSources {
cSourcesFiles :: [FilePath],
cxxSourceFiles :: [FilePath],
inputSourceFiles :: [FilePath],
inputSourceModules :: [ModuleName]
}
-- | Locate and return the 'BuildSources' required to build and link.
gbuildSources :: Verbosity
-> Version -- ^ specVersion
-> FilePath
-> GBuildMode
-> IO ([FilePath], [FilePath], [ModuleName])
-> IO BuildSources
gbuildSources verbosity specVer tmpDir bm =
case bm of
GBuildExe exe -> exeSources exe
......@@ -1096,7 +1106,7 @@ gbuildSources verbosity specVer tmpDir bm =
GBuildFLib flib -> return $ flibSources flib
GReplFLib flib -> return $ flibSources flib
where
exeSources :: Executable -> IO ([FilePath], [FilePath], [ModuleName])
exeSources :: Executable -> IO BuildSources
exeSources exe@Executable{buildInfo = bnfo, modulePath = modPath} = do
main <- findFile (tmpDir : hsSourceDirs bnfo) modPath
let mainModName = fromMaybe ModuleName.main $ exeMainModuleName exe
......@@ -1121,19 +1131,48 @@ gbuildSources verbosity specVer tmpDir bm =
++ display mainModName
++ "' listed in 'other-modules' illegally!"
return (cSources bnfo, [main],
filter (/= mainModName) (exeModules exe))
else return (cSources bnfo, [main], exeModules exe)
else return (main : cSources bnfo, [], exeModules exe)
return BuildSources {
cSourcesFiles = cSources bnfo,
cxxSourceFiles = cxxSources bnfo,
inputSourceFiles = [main],
inputSourceModules = filter (/= mainModName) $ exeModules exe
}
flibSources :: ForeignLib -> ([FilePath], [FilePath], [ModuleName])
else return BuildSources {
cSourcesFiles = cSources bnfo,
cxxSourceFiles = cxxSources bnfo,
inputSourceFiles = [main],
inputSourceModules = exeModules exe
}
else let (csf, cxxsf)
| isCxx main = ( cSources bnfo, main : cxxSources bnfo)
-- if main is not a Haskell source
-- and main is not a C++ source
-- then we assume that it is a C source
| otherwise = (main : cSources bnfo, cxxSources bnfo)
in return BuildSources {
cSourcesFiles = csf,
cxxSourceFiles = cxxsf,
inputSourceFiles = [],
inputSourceModules = exeModules exe
}
flibSources :: ForeignLib -> BuildSources
flibSources flib@ForeignLib{foreignLibBuildInfo = bnfo} =
(cSources bnfo, [], foreignLibModules flib)
BuildSources {
cSourcesFiles = cSources bnfo,
cxxSourceFiles = cxxSources bnfo,
inputSourceFiles = [],
inputSourceModules = foreignLibModules flib
}
isHaskell :: FilePath -> Bool
isHaskell fp = elem (takeExtension fp) [".hs", ".lhs"]
isCxx :: FilePath -> Bool
isCxx fp = elem (takeExtension fp) [".cpp", ".cxx", ".c++"]
-- | Generic build function. See comment for 'GBuildMode'.
gbuild :: Verbosity -> Cabal.Flag (Maybe Int)
-> PackageDescription -> LocalBuildInfo
......@@ -1168,12 +1207,16 @@ gbuild verbosity numJobs pkg_descr lbi bm clbi = do
| otherwise = mempty
rpaths <- getRPaths lbi clbi
(cSrcs, inputFiles, inputModules) <- gbuildSources verbosity
(specVersion pkg_descr) tmpDir bm
buildSources <- gbuildSources verbosity (specVersion pkg_descr) tmpDir bm
let isGhcDynamic = isDynamic comp
let cSrcs = cSourcesFiles buildSources
cxxSrcs = cxxSourceFiles buildSources
inputFiles = inputSourceFiles buildSources
inputModules = inputSourceModules buildSources
isGhcDynamic = isDynamic comp
dynamicTooSupported = supportsDynamicToo comp
cObjs = map (`replaceExtension` objExtension) cSrcs
cxxObjs = map (`replaceExtension` objExtension) cxxSrcs
needDynamic = gbuildNeedDynamic lbi bm
needProfiling = withProfExe lbi
......@@ -1194,8 +1237,7 @@ gbuild verbosity numJobs pkg_descr lbi bm clbi = do
(withProfExeDetail lbi),
ghcOptHiSuffix = toFlag "p_hi",
ghcOptObjSuffix = toFlag "p_o",
ghcOptExtra = toNubListR
(hcProfOptions GHC bnfo),
ghcOptExtra = (hcProfOptions GHC bnfo),
ghcOptHPCDir = hpcdir Hpc.Prof
}
dynOpts = baseOpts `mappend` mempty {
......@@ -1204,8 +1246,7 @@ gbuild verbosity numJobs pkg_descr lbi bm clbi = do
ghcOptFPic = toFlag True,
ghcOptHiSuffix = toFlag "dyn_hi",
ghcOptObjSuffix = toFlag "dyn_o",
ghcOptExtra = toNubListR $
hcSharedOptions GHC bnfo,
ghcOptExtra = hcSharedOptions GHC bnfo,
ghcOptHPCDir = hpcdir Hpc.Dyn
}
dynTooOpts = staticOpts `mappend` mempty {
......@@ -1215,22 +1256,21 @@ gbuild verbosity numJobs pkg_descr lbi bm clbi = do
ghcOptHPCDir = hpcdir Hpc.Dyn
}
linkerOpts = mempty {
ghcOptLinkOptions = toNubListR $ PD.ldOptions bnfo,
ghcOptLinkLibs = toNubListR $ extraLibs bnfo,
ghcOptLinkOptions = PD.ldOptions bnfo,
ghcOptLinkLibs = extraLibs bnfo,
ghcOptLinkLibPath = toNubListR $ extraLibDirs bnfo,
ghcOptLinkFrameworks = toNubListR $
PD.frameworks bnfo,
ghcOptLinkFrameworkDirs = toNubListR $
PD.extraFrameworkDirs bnfo,
ghcOptInputFiles = toNubListR
[tmpDir </> x | x <- cObjs]
[tmpDir </> x | x <- cObjs ++ cxxObjs]
}
dynLinkerOpts = mempty {
ghcOptRPaths = rpaths
}
replOpts = baseOpts {
ghcOptExtra = overNubListR
Internal.filterGhciFlags
ghcOptExtra = Internal.filterGhciFlags
(ghcOptExtra baseOpts)
}
-- For a normal compile we do separate invocations of ghc for
......@@ -1283,6 +1323,38 @@ gbuild verbosity numJobs pkg_descr lbi bm clbi = do
runGhcProg compileOpts { ghcOptNoLink = toFlag True
, ghcOptNumJobs = numJobs }
-- build any C++ sources
unless (null cxxSrcs) $ do
info verbosity "Building C++ Sources..."
sequence_
[ do let baseCxxOpts = Internal.componentCxxGhcOptions verbosity implInfo
lbi bnfo clbi tmpDir filename
vanillaCxxOpts = if isGhcDynamic
-- Dynamic GHC requires C++ sources to be built
-- with -fPIC for REPL to work. See #2207.
then baseCxxOpts { ghcOptFPic = toFlag True }
else baseCxxOpts
profCxxOpts = vanillaCxxOpts `mappend` mempty {
ghcOptProfilingMode = toFlag True
}
sharedCxxOpts = vanillaCxxOpts `mappend` mempty {
ghcOptFPic = toFlag True,
ghcOptDynLinkMode = toFlag GhcDynamicOnly
}
opts | needProfiling = profCxxOpts
| needDynamic = sharedCxxOpts
| otherwise = vanillaCxxOpts
-- TODO: Placing all Haskell, C, & C++ objects in a single directory
-- Has the potential for file collisions. In general we would
-- consider this a user error. However, we should strive to
-- add a warning if this occurs.
odir = fromFlag (ghcOptObjDir opts)
createDirectoryIfMissingVerbose verbosity True odir
needsRecomp <- checkNeedsRecompilation filename opts
when needsRecomp $
runGhcProg opts
| filename <- cxxSrcs ]
-- build any C sources
unless (null cSrcs) $ do
info verbosity "Building C Sources..."
......@@ -1343,19 +1415,18 @@ gbuild verbosity numJobs pkg_descr lbi bm clbi = do
`mappend` mempty {
ghcOptLinkNoHsMain = toFlag True,
ghcOptShared = toFlag True,
ghcOptLinkLibs = toNubListR [
if needDynamic
then rtsDynamicLib rtsInfo
else rtsStaticLib rtsInfo
],
ghcOptLinkLibs = [ if needDynamic
then rtsDynamicLib rtsInfo
else rtsStaticLib rtsInfo
],
ghcOptLinkLibPath = toNubListR $ rtsLibPaths rtsInfo,
ghcOptFPic = toFlag True,
ghcOptLinkModDefFiles = toNubListR $ gbuildModDefFiles bm
}
-- See Note [RPATH]
`mappend` ifNeedsRPathWorkaround lbi mempty {
ghcOptLinkOptions = toNubListR ["-Wl,--no-as-needed"]
, ghcOptLinkLibs = toNubListR ["ffi"]
ghcOptLinkOptions = ["-Wl,--no-as-needed"]
, ghcOptLinkLibs = ["ffi"]
}
ForeignLibNativeStatic ->
-- this should be caught by buildFLib
......@@ -1583,7 +1654,7 @@ libAbiHash verbosity _pkg_descr lbi lib clbi = do
ghcOptFPic = toFlag True,
ghcOptHiSuffix = toFlag "dyn_hi",
ghcOptObjSuffix = toFlag "dyn_o",
ghcOptExtra = toNubListR $ hcSharedOptions GHC libBi
ghcOptExtra = hcSharedOptions GHC libBi
}
profArgs = vanillaArgs `mappend` mempty {
ghcOptProfilingMode = toFlag True,
......@@ -1591,7 +1662,7 @@ libAbiHash verbosity _pkg_descr lbi lib clbi = do
(withProfLibDetail lbi),
ghcOptHiSuffix = toFlag "p_hi",
ghcOptObjSuffix = toFlag "p_o",
ghcOptExtra = toNubListR $ hcProfOptions GHC libBi
ghcOptExtra = hcProfOptions GHC libBi
}
ghcArgs
| withVanillaLib lbi = vanillaArgs
......@@ -1757,6 +1828,7 @@ installLib verbosity lbi targetDir dynlibTargetDir _builtDir _pkg lib clbi = do
hasLib = not $ null (allLibModules lib clbi)
&& null (cSources (libBuildInfo lib))
&& null (cxxSources (libBuildInfo lib))
has_code = not (componentIsIndefinite clbi)
whenHasCode = when has_code
whenVanilla = when (hasLib && withVanillaLib lbi)
......
......@@ -57,6 +57,7 @@ data InstalledPackageInfo = InstalledPackageInfo {
depends :: [PackageIdentifier],
hugsOptions :: [String],
ccOptions :: [String],
cxxOptions :: [String],
ldOptions :: [String],
frameworkDirs :: [FilePath],
frameworks :: [String],
......@@ -105,6 +106,7 @@ toCurrent ipi@InstalledPackageInfo{} =
Current.depends = map (Current.mkLegacyUnitId . convertPackageId) (depends ipi),
Current.abiDepends = [],
Current.ccOptions = ccOptions ipi,
Current.cxxOptions = cxxOptions ipi,
Current.ldOptions = ldOptions ipi,
Current.frameworkDirs = frameworkDirs ipi,
Current.frameworks = frameworks ipi,
......
......@@ -87,7 +87,7 @@ ghcjsVersionImplInfo _ghcjsver ghcver = GhcImplInfo
, flagDebugInfo = False
, supportsDebugLevels = ghcv >= [8,0]
, supportsPkgEnvFiles = ghcv >= [8,0,2] --TODO: check this works in ghcjs
, flagWarnMissingHomeModules = False
, flagWarnMissingHomeModules = ghcv >= [8,2]
}
where
ghcv = versionNumbers ghcver
......@@ -284,8 +284,7 @@ componentCcGhcOptions verbosity _implInfo lbi bi clbi odir filename =
ghcOptHideAllPackages= toFlag True,
ghcOptPackageDBs = withPackageDB lbi,
ghcOptPackages = toNubListR $ mkGhcOptPackages clbi,
ghcOptCcOptions = toNubListR $
(case withOptimization lbi of
ghcOptCcOptions = (case withOptimization lbi of
NoOptimisation -> []
_ -> ["-O2"]) ++
(case withDebugInfo lbi of
......@@ -302,7 +301,7 @@ componentCxxGhcOptions :: Verbosity -> GhcImplInfo -> LocalBuildInfo
-> BuildInfo -> ComponentLocalBuildInfo
-> FilePath -> FilePath
-> GhcOptions
componentCxxGhcOptions verbosity _implInfo lbi bi cxxlbi odir filename =
componentCxxGhcOptions verbosity _implInfo lbi bi clbi odir filename =
mempty {
-- Respect -v0, but don't crank up verbosity on GHC if
-- Cabal verbosity is requested. For that, use --ghc-option=-v instead!
......@@ -310,7 +309,7 @@ componentCxxGhcOptions verbosity _implInfo lbi bi cxxlbi odir filename =
ghcOptMode = toFlag GhcModeCompile,
ghcOptInputFiles = toNubListR [filename],
ghcOptCppIncludePath = toNubListR $ [autogenComponentModulesDir lbi cxxlbi
ghcOptCppIncludePath = toNubListR $ [autogenComponentModulesDir lbi clbi
,autogenPackageModulesDir lbi
,odir]
-- includes relative to the package
......@@ -320,9 +319,8 @@ componentCxxGhcOptions verbosity _implInfo lbi bi cxxlbi odir filename =
++ [buildDir lbi </> dir | dir <- PD.includeDirs bi],
ghcOptHideAllPackages= toFlag True,
ghcOptPackageDBs = withPackageDB lbi,
ghcOptPackages = toNubListR $ mkGhcOptPackages cxxlbi,
ghcOptCxxOptions = toNubListR $
(case withOptimization lbi of
ghcOptPackages = toNubListR $ mkGhcOptPackages clbi,
ghcOptCxxOptions = (case withOptimization lbi of
NoOptimisation -> []
_ -> ["-O2"]) ++
(case withDebugInfo lbi of
......@@ -378,7 +376,7 @@ componentGhcOptions verbosity implInfo lbi bi clbi odir =
-- potential includes generated by `configure'
-- in the build directory
++ [buildDir lbi </> dir | dir <- PD.includeDirs bi],
ghcOptCppOptions = toNubListR $ cppOptions bi,
ghcOptCppOptions = cppOptions bi,
ghcOptCppIncludes = toNubListR $
[autogenComponentModulesDir lbi clbi </> cppHeaderName],
ghcOptFfiIncludes = toNubListR $ PD.includes bi,
......@@ -388,7 +386,7 @@ componentGhcOptions verbosity implInfo lbi bi clbi odir =
ghcOptOutputDir = toFlag odir,
ghcOptOptimisation = toGhcOptimisation (withOptimization lbi),
ghcOptDebugInfo = toFlag (withDebugInfo lbi),
ghcOptExtra = toNubListR $ hcOptions GHC bi,
ghcOptExtra = hcOptions GHC bi,
ghcOptExtraPath = toNubListR $ exe_paths,
ghcOptLanguage = toFlag (fromMaybe Haskell98 (defaultLanguage bi)),
-- Unsupported extensions have already been checked by configure
......