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

Start support of relocatable builds

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