Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Enable shared lib by default if using a compiler that does dynamic by…

… default
  • Loading branch information...
commit 1f5144184a03fe4a3b11e2021d74eaffe8017353 1 parent e9a826a
@igfoo igfoo authored
View
20 Cabal/Distribution/Simple/Configure.hs
@@ -65,6 +65,8 @@ module Distribution.Simple.Configure (configure,
)
where
+import Distribution.Compiler
+ ( CompilerId(..) )
import Distribution.Simple.Compiler
( CompilerFlavor(..), Compiler(compilerId), compilerFlavor, compilerVersion
, showCompilerId, unsupportedLanguages, unsupportedExtensions
@@ -117,6 +119,10 @@ import Distribution.Version
( Version(..), anyVersion, orLaterVersion, withinRange, isAnyVersion )
import Distribution.Verbosity
( Verbosity, lessVerbose )
+import Distribution.Simple.Program.Db
+ ( lookupProgram )
+import Distribution.Simple.Program.Builtin
+ ( ghcProgram )
import qualified Distribution.Simple.GHC as GHC
import qualified Distribution.Simple.JHC as JHC
@@ -526,6 +532,18 @@ configure (pkg_descr0, pbi) cfg
++ intercalate " depends on "
(map (\(_,k,_) -> "'" ++ k ++ "'") (vs ++ [head vs]))
+ withSharedLibDefault <-
+ case compilerId comp of
+ CompilerId GHC _ ->
+ case lookupProgram ghcProgram programsConfig''' of
+ Just ghcProg ->
+ do xs <- GHC.getGhcInfo verbosity ghcProg
+ return $ case lookup "Dynamic by default" xs of
+ Just "YES" -> True
+ _ -> False
+ Nothing -> return False
+ _ -> return False
+
let lbi = LocalBuildInfo {
configFlags = cfg,
extraConfigArgs = [], -- Currently configure does not
@@ -548,7 +566,7 @@ configure (pkg_descr0, pbi) cfg
withPrograms = programsConfig''',
withVanillaLib = fromFlag $ configVanillaLib cfg,
withProfLib = fromFlag $ configProfLib cfg,
- withSharedLib = fromFlag $ configSharedLib cfg,
+ withSharedLib = fromFlagOrDefault withSharedLibDefault $ configSharedLib cfg,
withDynExe = fromFlag $ configDynExe cfg,
withProfExe = fromFlag $ configProfExe cfg,
withOptimization = fromFlag $ configOptimization cfg,
View
26 Cabal/Distribution/Simple/GHC.hs
@@ -61,6 +61,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}
module Distribution.Simple.GHC (
+ getGhcInfo,
configure, getInstalledPackages,
buildLib, buildExe,
installLib, installExe,
@@ -137,6 +138,21 @@ import System.IO (hClose, hPutStrLn)
import System.Environment (getEnv)
import Distribution.Compat.Exception (catchExit, catchIO)
+getGhcInfo :: Verbosity -> ConfiguredProgram -> IO [(String, String)]
+getGhcInfo verbosity ghcProg =
+ case programVersion ghcProg of
+ Just ghcVersion
+ | ghcVersion >= Version [6,7] [] ->
+ do xs <- getProgramOutput verbosity ghcProg ["--info"]
+ case reads xs of
+ [(i, ss)]
+ | all isSpace ss ->
+ return i
+ _ ->
+ die "Can't parse --info output of GHC"
+ _ ->
+ return []
+
-- -----------------------------------------------------------------------------
-- Configuring
@@ -172,15 +188,7 @@ configure verbosity hcPath hcPkgPath conf0 = do
languages <- getLanguages verbosity ghcProg
extensions <- getExtensions verbosity ghcProg
- ghcInfo <- if ghcVersion >= Version [6,7] []
- then do xs <- getProgramOutput verbosity ghcProg ["--info"]
- case reads xs of
- [(i, ss)]
- | all isSpace ss ->
- return i
- _ ->
- die "Can't parse --info output of GHC"
- else return []
+ ghcInfo <- getGhcInfo verbosity ghcProg
let comp = Compiler {
compilerId = CompilerId GHC ghcVersion,
View
2  Cabal/Distribution/Simple/Setup.hs
@@ -304,7 +304,7 @@ defaultConfigFlags progConf = emptyConfigFlags {
configHcFlavor = maybe NoFlag Flag defaultCompilerFlavor,
configVanillaLib = Flag True,
configProfLib = Flag False,
- configSharedLib = Flag False,
+ configSharedLib = NoFlag,
configDynExe = Flag False,
configProfExe = Flag False,
configOptimization = Flag NormalOptimisation,
Please sign in to comment.
Something went wrong with that request. Please try again.