Commit e2761b27 authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Simplify handling of programs with no Haskell main

parent e3be330a
......@@ -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
......
......@@ -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])
......@@ -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
......
......@@ -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 ]
......@@ -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" ]
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"] ]
module Settings.Packages.IservBin (iservBinPackageArgs) where
import GHC
import Predicate
iservBinPackageArgs :: Args
iservBinPackageArgs = package iservBin ? builder Ghc ? arg "-no-hs-main"
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"] ]
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"] ]
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