Commit eb787d6d authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Add --enable/disable-executable-stripping option

The default is enabled
parent 35b34c15
...@@ -88,7 +88,7 @@ import Distribution.Simple.Setup ...@@ -88,7 +88,7 @@ import Distribution.Simple.Setup
( ConfigFlags(..), CopyDest(..), fromFlag, fromFlagOrDefault, flagToMaybe ) ( ConfigFlags(..), CopyDest(..), fromFlag, fromFlagOrDefault, flagToMaybe )
import Distribution.Simple.InstallDirs import Distribution.Simple.InstallDirs
( InstallDirs(..), defaultInstallDirs, combineInstallDirs ) ( InstallDirs(..), defaultInstallDirs, combineInstallDirs )
import Distribution.Simple.LocalBuildInfo as LBI import Distribution.Simple.LocalBuildInfo
( LocalBuildInfo(..), absoluteInstallDirs ( LocalBuildInfo(..), absoluteInstallDirs
, prefixRelativeInstallDirs ) , prefixRelativeInstallDirs )
import Distribution.Simple.BuildPaths import Distribution.Simple.BuildPaths
...@@ -416,6 +416,7 @@ configure (pkg_descr0, pbi) cfg ...@@ -416,6 +416,7 @@ configure (pkg_descr0, pbi) cfg
withOptimization = fromFlag $ configOptimization cfg, withOptimization = fromFlag $ configOptimization cfg,
withGHCiLib = fromFlag $ configGHCiLib cfg, withGHCiLib = fromFlag $ configGHCiLib cfg,
splitObjs = split_objs, splitObjs = split_objs,
stripExes = fromFlag $ configStripExes cfg,
withPackageDB = packageDb, withPackageDB = packageDb,
progPrefix = fromFlag $ configProgPrefix cfg, progPrefix = fromFlag $ configProgPrefix cfg,
progSuffix = fromFlag $ configProgSuffix cfg progSuffix = fromFlag $ configProgSuffix cfg
......
...@@ -702,7 +702,7 @@ installExe verbosity lbi pref buildPref (progprefix, progsuffix) pkg_descr ...@@ -702,7 +702,7 @@ installExe verbosity lbi pref buildPref (progprefix, progsuffix) pkg_descr
stripExe verbosity lbi exeFileName (pref </> fixedExeFileName) stripExe verbosity lbi exeFileName (pref </> fixedExeFileName)
stripExe :: Verbosity -> LocalBuildInfo -> FilePath -> FilePath -> IO () stripExe :: Verbosity -> LocalBuildInfo -> FilePath -> FilePath -> IO ()
stripExe verbosity lbi name path = stripExe verbosity lbi name path = when (stripExes lbi) $
case lookupProgram stripProgram (withPrograms lbi) of case lookupProgram stripProgram (withPrograms lbi) of
Just strip -> rawSystemProgram verbosity strip [path] Just strip -> rawSystemProgram verbosity strip [path]
Nothing -> warn verbosity $ "Unable to strip executable '" ++ name Nothing -> warn verbosity $ "Unable to strip executable '" ++ name
......
...@@ -100,6 +100,7 @@ data LocalBuildInfo = LocalBuildInfo { ...@@ -100,6 +100,7 @@ data LocalBuildInfo = LocalBuildInfo {
withOptimization :: OptimisationLevel, -- ^Whether to build with optimization (if available). withOptimization :: OptimisationLevel, -- ^Whether to build with optimization (if available).
withGHCiLib :: Bool, -- ^Whether to build libs suitable for use with GHCi. withGHCiLib :: Bool, -- ^Whether to build libs suitable for use with GHCi.
splitObjs :: Bool, -- ^Use -split-objs with GHC, if available splitObjs :: Bool, -- ^Use -split-objs with GHC, if available
stripExes :: Bool, -- ^Whether to strip executables 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
......
...@@ -246,6 +246,7 @@ data ConfigFlags = ConfigFlags { ...@@ -246,6 +246,7 @@ data ConfigFlags = ConfigFlags {
configPackageDB :: Flag PackageDB, -- ^Which package DB to use configPackageDB :: Flag PackageDB, -- ^Which package DB to use
configGHCiLib :: Flag Bool, -- ^Enable compiling library for GHCi configGHCiLib :: Flag Bool, -- ^Enable compiling library for GHCi
configSplitObjs :: Flag Bool, -- ^Enable -split-objs with GHC configSplitObjs :: Flag Bool, -- ^Enable -split-objs with GHC
configStripExes :: Flag Bool, -- ^Enable executable stripping
configConfigurationsFlags :: [(String, Bool)] configConfigurationsFlags :: [(String, Bool)]
} }
deriving Show deriving Show
...@@ -264,7 +265,8 @@ defaultConfigFlags progConf = emptyConfigFlags { ...@@ -264,7 +265,8 @@ defaultConfigFlags progConf = emptyConfigFlags {
configVerbose = Flag normal, configVerbose = Flag normal,
configUserInstall = Flag False, --TODO: reverse this configUserInstall = Flag False, --TODO: reverse this
configGHCiLib = Flag True, configGHCiLib = Flag True,
configSplitObjs = Flag False -- takes longer, so turn off by default configSplitObjs = Flag False, -- takes longer, so turn off by default
configStripExes = Flag True
} }
configureCommand :: ProgramConfiguration -> CommandUI ConfigFlags configureCommand :: ProgramConfiguration -> CommandUI ConfigFlags
...@@ -417,6 +419,11 @@ configureOptions showOrParseArgs = ...@@ -417,6 +419,11 @@ configureOptions showOrParseArgs =
configSplitObjs (\v flags -> flags { configSplitObjs = v }) configSplitObjs (\v flags -> flags { configSplitObjs = v })
(boolOpt [] []) (boolOpt [] [])
,option "" ["executable-stripping"]
"strip executables upon installation to reduce binary sizes"
configStripExes (\v flags -> flags { configStripExes = v })
(boolOpt [] [])
,option "" ["configure-option"] ,option "" ["configure-option"]
"Extra option for configure" "Extra option for configure"
configConfigureArgs (\v flags -> flags { configConfigureArgs = v }) configConfigureArgs (\v flags -> flags { configConfigureArgs = v })
...@@ -494,6 +501,7 @@ instance Monoid ConfigFlags where ...@@ -494,6 +501,7 @@ instance Monoid ConfigFlags where
configPackageDB = mempty, configPackageDB = mempty,
configGHCiLib = mempty, configGHCiLib = mempty,
configSplitObjs = mempty, configSplitObjs = mempty,
configStripExes = mempty,
configExtraLibDirs = mempty, configExtraLibDirs = mempty,
configExtraIncludeDirs = mempty, configExtraIncludeDirs = mempty,
configConfigurationsFlags = mempty configConfigurationsFlags = mempty
...@@ -520,6 +528,7 @@ instance Monoid ConfigFlags where ...@@ -520,6 +528,7 @@ instance Monoid ConfigFlags where
configPackageDB = combine configPackageDB, configPackageDB = combine configPackageDB,
configGHCiLib = combine configGHCiLib, configGHCiLib = combine configGHCiLib,
configSplitObjs = combine configSplitObjs, configSplitObjs = combine configSplitObjs,
configStripExes = combine configSplitObjs,
configExtraLibDirs = combine configExtraLibDirs, configExtraLibDirs = combine configExtraLibDirs,
configExtraIncludeDirs = combine configExtraIncludeDirs, configExtraIncludeDirs = combine configExtraIncludeDirs,
configConfigurationsFlags = combine configConfigurationsFlags configConfigurationsFlags = combine configConfigurationsFlags
......
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