Commit 06a713e1 authored by Christiaan Baaij's avatar Christiaan Baaij

Start support of relocatable builds

parent 3aeb4970
......@@ -601,6 +601,16 @@ configure (pkg_descr0, pbi) cfg
GHC.ghcDynamic comp
_ -> False
reloc <-
if not (fromFlag $ configRelocatable cfg)
then return False
else case flavor of
GHC | version >= Version [7,8] [] -> return True
_ -> do warn verbosity
("this compiler does not support " ++
"--enable-relocatable; ignoring")
return False
let lbi = LocalBuildInfo {
configFlags = cfg,
extraConfigArgs = [], -- Currently configure does not
......@@ -631,7 +641,8 @@ configure (pkg_descr0, pbi) cfg
stripLibs = fromFlag $ configStripLibs cfg,
withPackageDB = packageDbs,
progPrefix = fromFlag $ configProgPrefix cfg,
progSuffix = fromFlag $ configProgSuffix cfg
progSuffix = fromFlag $ configProgSuffix cfg,
relocatable = reloc
}
let dirs = absoluteInstallDirs pkg_descr lbi NoCopyDest
......
......@@ -102,7 +102,7 @@ import Distribution.Verbosity
import Distribution.Text
( display, simpleParse )
import Distribution.Utils.NubList
( overNubListR, toNubListR )
( NubListR, overNubListR, toNubListR )
import Language.Haskell.Extension (Language(..), Extension(..)
,KnownExtension(..))
......@@ -906,11 +906,18 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
ghcOptPackageKey = toFlag (pkgKey lbi),
ghcOptNoAutoLinkPackages = toFlag True,
ghcOptPackageDBs = withPackageDB lbi,
ghcOptPackages = toNubListR $ mkGhcOptPackages clbi ,
ghcOptPackages = toNubListR $ mkGhcOptPackages clbi,
ghcOptLinkOptions = if (hostOS == OSX
&& relocatable lbi)
then toRPaths lbi clbi
else mempty,
ghcOptLinkLibs = toNubListR $ extraLibs libBi,
ghcOptLinkLibPath = toNubListR $ extraLibDirs libBi
ghcOptLinkLibPath = toNubListR $ extraLibDirs libBi,
ghcOptNoRPath = toFlag (relocatable lbi)
}
info verbosity (show (ghcOptPackages ghcSharedLinkArgs))
whenVanillaLib False $ do
Ar.createArLibArchive verbosity lbi vanillaLibFilePath staticObjectFiles
......@@ -925,6 +932,11 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
whenSharedLib False $
runGhcProg ghcSharedLinkArgs
toRPaths :: LocalBuildInfo
-> ComponentLocalBuildInfo
-> NubListR String
toRPaths = undefined
-- | Start a REPL without loading any source files.
startInterpreter :: Verbosity -> ProgramConfiguration -> Compiler
-> PackageDBStack -> IO ()
......@@ -1022,7 +1034,8 @@ buildOrReplExe forRepl verbosity numJobs _pkg_descr lbi
ghcOptLinkLibPath = toNubListR $ extraLibDirs exeBi,
ghcOptLinkFrameworks = toNubListR $ PD.frameworks exeBi,
ghcOptInputFiles = toNubListR
[exeDir </> x | x <- cObjs]
[exeDir </> x | x <- cObjs],
ghcOptNoRPath = toFlag (relocatable lbi)
}
replOpts = baseOpts {
ghcOptExtra = overNubListR filterGhciFlags
......
......@@ -139,7 +139,8 @@ data LocalBuildInfo = LocalBuildInfo {
stripExes :: Bool, -- ^Whether to strip executables during install
stripLibs :: Bool, -- ^Whether to strip libraries during install
progPrefix :: PathTemplate, -- ^Prefix to be prepended to installed executables
progSuffix :: PathTemplate -- ^Suffix to be appended to installed executables
progSuffix :: PathTemplate, -- ^Suffix to be appended to installed executables
relocatable :: Bool -- ^Whether to build a relocatable package
} deriving (Generic, Read, Show)
instance Binary LocalBuildInfo
......
......@@ -189,6 +189,7 @@ data GhcOptions = GhcOptions {
ghcOptShared :: Flag Bool,
ghcOptFPic :: Flag Bool,
ghcOptDylibName :: Flag String,
ghcOptNoRPath :: Flag Bool, -- ^ Don't embed any runtime paths.
---------------
-- Misc flags
......@@ -336,6 +337,7 @@ renderGhcOptions comp opts
, ["-L" ++ dir | dir <- flags ghcOptLinkLibPath ]
, concat [ ["-framework", fmwk] | fmwk <- flags ghcOptLinkFrameworks ]
, [ "-no-hs-main" | flagBool ghcOptLinkNoHsMain ]
, [ "-dynload deploy" | flagBool ghcOptNoRPath ]
-------------
-- Packages
......@@ -488,6 +490,7 @@ instance Monoid GhcOptions where
ghcOptShared = mempty,
ghcOptFPic = mempty,
ghcOptDylibName = mempty,
ghcOptNoRPath = mempty,
ghcOptVerbosity = mempty,
ghcOptCabal = mempty
}
......@@ -539,6 +542,7 @@ instance Monoid GhcOptions where
ghcOptShared = combine ghcOptShared,
ghcOptFPic = combine ghcOptFPic,
ghcOptDylibName = combine ghcOptDylibName,
ghcOptNoRPath = combine ghcOptNoRPath,
ghcOptVerbosity = combine ghcOptVerbosity,
ghcOptCabal = combine ghcOptCabal
}
......
......@@ -304,8 +304,9 @@ data ConfigFlags = ConfigFlags {
configExactConfiguration :: Flag Bool,
-- ^All direct dependencies and flags are provided on the command line by
-- the user via the '--dependency' and '--flags' options.
configFlagError :: Flag String
configFlagError :: Flag String,
-- ^Halt and show an error message indicating an error in flag assignment
configRelocatable :: Flag Bool -- ^ Enable relocatable package built
}
deriving (Generic, Read, Show)
......@@ -346,7 +347,8 @@ defaultConfigFlags progConf = emptyConfigFlags {
configCoverage = Flag False,
configLibCoverage = NoFlag,
configExactConfiguration = Flag False,
configFlagError = NoFlag
configFlagError = NoFlag,
configRelocatable = Flag False
}
configureCommand :: ProgramConfiguration -> CommandUI ConfigFlags
......@@ -549,6 +551,11 @@ configureOptions showOrParseArgs =
"dependency checking and compilation for benchmarks listed in the package description file."
configBenchmarks (\v flags -> flags { configBenchmarks = v })
(boolOpt [] [])
,option "" ["relocatable"]
"building a package that is relocatable. (GHC only)"
configRelocatable (\v flags -> flags { configRelocatable = v})
(boolOpt [] [])
]
where
readFlagList :: String -> FlagAssignment
......@@ -702,7 +709,8 @@ instance Monoid ConfigFlags where
configLibCoverage = mempty,
configExactConfiguration = mempty,
configBenchmarks = mempty,
configFlagError = mempty
configFlagError = mempty,
configRelocatable = mempty
}
mappend a b = ConfigFlags {
configPrograms = configPrograms b,
......@@ -742,7 +750,8 @@ instance Monoid ConfigFlags where
configLibCoverage = combine configLibCoverage,
configExactConfiguration = combine configExactConfiguration,
configBenchmarks = combine configBenchmarks,
configFlagError = combine configFlagError
configFlagError = combine configFlagError,
configRelocatable = combine configRelocatable
}
where combine field = field a `mappend` field b
......
......@@ -293,7 +293,8 @@ instance Monoid SavedConfig where
configCoverage = combine configCoverage,
configLibCoverage = combine configLibCoverage,
configExactConfiguration = combine configExactConfiguration,
configFlagError = combine configFlagError
configFlagError = combine configFlagError,
configRelocatable = combine configRelocatable
}
where
combine = combine' savedConfigureFlags
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment