[commit: ghc] wip/nfs-locking: Simplify handling of programs with no Haskell main (e2761b2)
git at git.haskell.org
git at git.haskell.org
Fri Oct 27 01:14:39 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/nfs-locking
Link : http://ghc.haskell.org/trac/ghc/changeset/e2761b27d9c01828650a48e854ce1f3980dc29b4/ghc
>---------------------------------------------------------------
commit e2761b27d9c01828650a48e854ce1f3980dc29b4
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date: Sun Nov 27 15:36:50 2016 +0000
Simplify handling of programs with no Haskell main
>---------------------------------------------------------------
e2761b27d9c01828650a48e854ce1f3980dc29b4
hadrian.cabal | 4 ----
src/GHC.hs | 7 ++++++-
src/Settings/Builders/Ghc.hs | 4 +++-
src/Settings/Default.hs | 10 +---------
src/Settings/Packages/Ghc.hs | 7 ++-----
src/Settings/Packages/Hp2ps.hs | 9 ---------
src/Settings/Packages/IservBin.hs | 7 -------
src/Settings/Packages/Touchy.hs | 9 ---------
src/Settings/Packages/Unlit.hs | 9 ---------
9 files changed, 12 insertions(+), 54 deletions(-)
diff --git a/hadrian.cabal b/hadrian.cabal
index 0663643..30ed256 100644
--- a/hadrian.cabal
+++ b/hadrian.cabal
@@ -94,13 +94,9 @@ executable hadrian
, Settings.Packages.GhcCabal
, Settings.Packages.GhcPrim
, Settings.Packages.Haddock
- , Settings.Packages.Hp2ps
, Settings.Packages.IntegerGmp
- , Settings.Packages.IservBin
, Settings.Packages.Rts
, Settings.Packages.RunGhc
- , Settings.Packages.Touchy
- , Settings.Packages.Unlit
, Settings.Path
, Stage
, Target
diff --git a/src/GHC.hs b/src/GHC.hs
index 9111d64..4521679 100644
--- a/src/GHC.hs
+++ b/src/GHC.hs
@@ -9,7 +9,8 @@ module GHC (
parallel, pretty, primitive, process, rts, runGhc, stm, templateHaskell,
terminfo, time, touchy, transformers, unlit, unix, win32, xhtml,
- defaultKnownPackages, builderProvenance, programName, nonCabalContext
+ defaultKnownPackages, builderProvenance, programName, nonCabalContext,
+ nonHsMainPackage
) where
import Builder
@@ -130,3 +131,7 @@ programName Context {..}
nonCabalContext :: Context -> Bool
nonCabalContext Context {..} = (package `elem` [hp2ps, rts, touchy, unlit])
|| package == ghcCabal && stage == Stage0
+
+-- | Some program packages should not be linked with Haskell main function.
+nonHsMainPackage :: Package -> Bool
+nonHsMainPackage = (`elem` [ghc, hp2ps, iservBin, touchy, unlit])
diff --git a/src/Settings/Builders/Ghc.hs b/src/Settings/Builders/Ghc.hs
index 0c4c569..f5b13e1 100644
--- a/src/Settings/Builders/Ghc.hs
+++ b/src/Settings/Builders/Ghc.hs
@@ -22,6 +22,7 @@ ghcBuilderArgs = (builder (Ghc CompileHs) ||^ builder (Ghc LinkHs)) ? do
ghcLinkArgs :: Args
ghcLinkArgs = builder (Ghc LinkHs) ? do
stage <- getStage
+ pkg <- getPackage
libs <- getPkgDataList DepExtraLibs
libDirs <- getPkgDataList DepLibDirs
gmpLibs <- if stage > Stage0
@@ -31,6 +32,7 @@ ghcLinkArgs = builder (Ghc LinkHs) ? do
return $ concatMap (words . strip) buildInfo
else return []
mconcat [ arg "-no-auto-link-packages"
+ , nonHsMainPackage pkg ? arg "-no-hs-main"
, append [ "-optl-l" ++ lib | lib <- libs ++ gmpLibs ]
, append [ "-optl-L" ++ unifyPath dir | dir <- libDirs ] ]
@@ -75,7 +77,7 @@ commonGhcArgs = do
, arg "-odir" , arg path
, arg "-hidir" , arg path
, arg "-stubdir" , arg path
- , arg "-rtsopts" ] -- TODO: ifeq "$(HC_VERSION_GE_6_13)" "YES"
+ , (not . nonHsMainPackage) <$> getPackage ? arg "-rtsopts" ]
-- TODO: Do '-ticky' in all debug ways?
wayGhcArgs :: Args
diff --git a/src/Settings/Default.hs b/src/Settings/Default.hs
index c863a9e..6f56c5d 100644
--- a/src/Settings/Default.hs
+++ b/src/Settings/Default.hs
@@ -34,13 +34,9 @@ import Settings.Packages.Ghc
import Settings.Packages.GhcCabal
import Settings.Packages.GhcPrim
import Settings.Packages.Haddock
-import Settings.Packages.Hp2ps
import Settings.Packages.IntegerGmp
-import Settings.Packages.IservBin
import Settings.Packages.Rts
import Settings.Packages.RunGhc
-import Settings.Packages.Touchy
-import Settings.Packages.Unlit
import UserSettings
-- | All default command line arguments.
@@ -203,10 +199,6 @@ defaultPackageArgs = mconcat
, ghcCabalPackageArgs
, ghcPrimPackageArgs
, haddockPackageArgs
- , hp2psPackageArgs
, integerGmpPackageArgs
- , iservBinPackageArgs
, rtsPackageArgs
- , runGhcPackageArgs
- , touchyPackageArgs
- , unlitPackageArgs ]
+ , runGhcPackageArgs ]
diff --git a/src/Settings/Packages/Ghc.hs b/src/Settings/Packages/Ghc.hs
index b069c23..a95bda6 100644
--- a/src/Settings/Packages/Ghc.hs
+++ b/src/Settings/Packages/Ghc.hs
@@ -8,10 +8,7 @@ import Settings.Path
ghcPackageArgs :: Args
ghcPackageArgs = package ghc ? do
stage <- getStage
- mconcat [ builder Ghc ? mconcat
- [ arg $ "-I" ++ buildPath (vanillaContext stage compiler)
- , arg "-no-hs-main" ]
+ mconcat [ builder Ghc ? arg ("-I" ++ buildPath (vanillaContext stage compiler))
, builder GhcCabal ?
- ghcWithInterpreter ? notStage0 ? arg "--flags=ghci"
- ]
+ ghcWithInterpreter ? notStage0 ? arg "--flags=ghci" ]
diff --git a/src/Settings/Packages/Hp2ps.hs b/src/Settings/Packages/Hp2ps.hs
deleted file mode 100644
index a5c62c2..0000000
--- a/src/Settings/Packages/Hp2ps.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-module Settings.Packages.Hp2ps (hp2psPackageArgs) where
-
-import GHC
-import Predicate
-
-hp2psPackageArgs :: Args
-hp2psPackageArgs = package hp2ps ?
- builder Ghc ? mconcat [ arg "-no-hs-main"
- , remove ["-hide-all-packages"] ]
diff --git a/src/Settings/Packages/IservBin.hs b/src/Settings/Packages/IservBin.hs
deleted file mode 100644
index 40b2101..0000000
--- a/src/Settings/Packages/IservBin.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module Settings.Packages.IservBin (iservBinPackageArgs) where
-
-import GHC
-import Predicate
-
-iservBinPackageArgs :: Args
-iservBinPackageArgs = package iservBin ? builder Ghc ? arg "-no-hs-main"
diff --git a/src/Settings/Packages/Touchy.hs b/src/Settings/Packages/Touchy.hs
deleted file mode 100644
index 7c2e04c..0000000
--- a/src/Settings/Packages/Touchy.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-module Settings.Packages.Touchy (touchyPackageArgs) where
-
-import GHC
-import Predicate
-
-touchyPackageArgs :: Args
-touchyPackageArgs = package touchy ?
- builder Ghc ? mconcat [ arg "-no-hs-main"
- , remove ["-hide-all-packages"] ]
diff --git a/src/Settings/Packages/Unlit.hs b/src/Settings/Packages/Unlit.hs
deleted file mode 100644
index a959699..0000000
--- a/src/Settings/Packages/Unlit.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-module Settings.Packages.Unlit (unlitPackageArgs) where
-
-import GHC
-import Predicate
-
-unlitPackageArgs :: Args
-unlitPackageArgs = package unlit ?
- builder Ghc ? mconcat [ arg "-no-hs-main"
- , remove ["-hide-all-packages"] ]
More information about the ghc-commits
mailing list