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

Add stage parameter to Gcc builder. Clean up.

parent 734994cf
......@@ -5,17 +5,18 @@
#===================
system-ghc = @WithGhc@
system-ghc-pkg = @GhcPkgCmd@
ghc-cabal = @hardtop@/inplace/bin/ghc-cabal
ghc-stage1 = @hardtop@/inplace/bin/ghc-stage1
ghc-stage2 = @hardtop@/inplace/bin/ghc-stage2
ghc-stage3 = @hardtop@/inplace/bin/ghc-stage3
system-ghc-pkg = @GhcPkgCmd@
ghc-pkg = @hardtop@/inplace/bin/ghc-pkg
system-gcc = @CC_STAGE0@
gcc = @WhatGccIsCalled@
ghc-cabal = @hardtop@/inplace/bin/ghc-cabal
ld = @LdCmd@
ar = @ArCmd@
alex = @AlexCmd@
......@@ -58,21 +59,21 @@ project-version = @ProjectVersion@
# Compilation and linking flags:
#===============================
conf-cc-args-stage-0 = @CONF_CC_OPTS_STAGE0@
conf-cc-args-stage-1 = @CONF_CC_OPTS_STAGE1@
conf-cc-args-stage-2 = @CONF_CC_OPTS_STAGE2@
conf-cc-args-stage0 = @CONF_CC_OPTS_STAGE0@
conf-cc-args-stage1 = @CONF_CC_OPTS_STAGE1@
conf-cc-args-stage2 = @CONF_CC_OPTS_STAGE2@
conf-cpp-args-stage-0 = @CONF_CPP_OPTS_STAGE0@
conf-cpp-args-stage-1 = @CONF_CPP_OPTS_STAGE1@
conf-cpp-args-stage-2 = @CONF_CPP_OPTS_STAGE2@
conf-cpp-args-stage0 = @CONF_CPP_OPTS_STAGE0@
conf-cpp-args-stage1 = @CONF_CPP_OPTS_STAGE1@
conf-cpp-args-stage2 = @CONF_CPP_OPTS_STAGE2@
conf-gcc-linker-args-stage-0 = @CONF_GCC_LINKER_OPTS_STAGE0@
conf-gcc-linker-args-stage-1 = @CONF_GCC_LINKER_OPTS_STAGE1@
conf-gcc-linker-args-stage-2 = @CONF_GCC_LINKER_OPTS_STAGE2@
conf-gcc-linker-args-stage0 = @CONF_GCC_LINKER_OPTS_STAGE0@
conf-gcc-linker-args-stage1 = @CONF_GCC_LINKER_OPTS_STAGE1@
conf-gcc-linker-args-stage2 = @CONF_GCC_LINKER_OPTS_STAGE2@
conf-ld-linker-args-stage-0 = @CONF_LD_LINKER_OPTS_STAGE0@
conf-ld-linker-args-stage-1 = @CONF_LD_LINKER_OPTS_STAGE1@
conf-ld-linker-args-stage-2 = @CONF_LD_LINKER_OPTS_STAGE2@
conf-ld-linker-args-stage0 = @CONF_LD_LINKER_OPTS_STAGE0@
conf-ld-linker-args-stage1 = @CONF_LD_LINKER_OPTS_STAGE1@
conf-ld-linker-args-stage2 = @CONF_LD_LINKER_OPTS_STAGE2@
src-hc-args = -H32m -O
......
......@@ -6,6 +6,7 @@ module Oracles.Base (
) where
import Base
import Util
import Development.Shake.Classes
newtype ConfigKey = ConfigKey String
......@@ -13,11 +14,11 @@ newtype ConfigKey = ConfigKey String
askConfigWithDefault :: String -> Action String -> Action String
askConfigWithDefault key defaultAction = do
maybeValue <- askOracle $ ConfigKey key
maybeValue <- askOracle $ ConfigKey key
case maybeValue of
Just value -> return value
Nothing -> defaultAction
askConfig :: String -> Action String
askConfig key = askConfigWithDefault key $
error $ "\nCannot find key '" ++ key ++ "' in configuration files."
redError $ "Cannot find key '" ++ key ++ "' in configuration files."
......@@ -21,11 +21,11 @@ import Oracles.Option
-- GhcPkg StageN, N > 0, is the one built on stage 0 (TODO: need only Stage1?)
data Builder = Ar
| Ld
| Gcc
| Alex
| Happy
| HsColour
| GhcCabal
| Gcc Stage
| Ghc Stage
| GhcPkg Stage
deriving Show
......@@ -35,7 +35,6 @@ instance ShowArg Builder where
let key = case builder of
Ar -> "ar"
Ld -> "ld"
Gcc -> "gcc"
Alex -> "alex"
Happy -> "happy"
HsColour -> "hscolour"
......@@ -44,6 +43,8 @@ instance ShowArg Builder where
Ghc Stage1 -> "ghc-stage1"
Ghc Stage2 -> "ghc-stage2"
Ghc Stage3 -> "ghc-stage3"
Gcc Stage0 -> "system-gcc"
Gcc _ -> "gcc"
GhcPkg Stage0 -> "system-ghc-pkg"
GhcPkg _ -> "ghc-pkg"
cfgPath <- askConfigWithDefault key $
......@@ -82,7 +83,7 @@ with builder = do
let key = case builder of
Ar -> "--with-ar="
Ld -> "--with-ld="
Gcc -> "--with-gcc="
Gcc _ -> "--with-gcc="
Ghc _ -> "--with-ghc="
Alex -> "--with-alex="
Happy -> "--with-happy="
......@@ -119,7 +120,7 @@ interestingInfo :: Builder -> [String] -> [String]
interestingInfo builder ss = case builder of
Ar -> prefixAndSuffix 2 1 ss
Ld -> prefixAndSuffix 4 0 ss
Gcc -> if head ss == "-MM"
Gcc _ -> if head ss == "-MM"
then prefixAndSuffix 1 1 ss
else ss
Ghc _ -> if head ss == "-M"
......
......@@ -56,7 +56,7 @@ instance ShowArgs MultiOption where
GmpIncludeDirs -> "gmp-include-dirs"
GmpLibDirs -> "gmp-lib-dirs"
where
showStage = ("-stage-" ++) . show
showStage = ("-stage" ++) . show
ghcWithInterpreter :: Condition
ghcWithInterpreter = do
......
......@@ -68,7 +68,7 @@ buildRule pkg @ (Package name path _) todo @ (stage, dist, _) =
when (not $ null hSrcs)
$ terseRun (Ghc stage) $ ghcArgs pkg todo way hSrcs obj
when (not $ null cSrcs)
$ terseRun Gcc $ gccArgs pkg todo cSrcs obj
$ terseRun (Gcc stage) $ gccArgs pkg todo cSrcs obj
argListRule :: Package -> TodoItem -> Rules ()
argListRule pkg todo @ (stage, _, settings) =
......@@ -80,7 +80,13 @@ argListRule pkg todo @ (stage, _, settings) =
("way '" ++ tag way ++ "'")
(Ghc stage)
(ghcArgs pkg todo way ["input.hs"] $ "output" <.> osuf way)
writeFileChanged out $ unlines ghcList
gccList <- forM ways' $ \way ->
argListWithComment
("way '" ++ tag way ++ "'")
(Gcc stage)
(gccArgs pkg todo ["input.c"] $ "output" <.> osuf way)
writeFileChanged out $ unlines ghcList ++ "\n" ++ unlines gccList
buildPackageCompile :: Package -> TodoItem -> Rules ()
buildPackageCompile = argListRule <> buildRule
......@@ -44,7 +44,7 @@ configureArgs stage settings =
, conf "--with-gmp-libraries" GmpLibDirs
-- TODO: why TargetPlatformFull and not host?
, when CrossCompiling $ conf "--host" $ arg TargetPlatformFull
, conf "--with-cc" $ arg Gcc ]
, conf "--with-cc" $ arg $ Gcc stage ]
-- Prepare a given 'packaga-data.mk' file for parsing by readConfigFile:
-- 1) Drop lines containing '$'
......@@ -86,15 +86,15 @@ cabalArgs pkg @ (Package _ path _) todo @ (stage, dist, settings) = args
-- * if it is empty, we need to emit one empty string argument
-- * otherwise, we must collapse it into one space-separated string
, arg (unwords <$> customDllArgs settings)
, with (Ghc stage) -- TODO: used limited to max stage1 GHC
, with (GhcPkg stage)
, with $ Ghc stage -- TODO: used to be limited to max stage1 GHC
, with $ GhcPkg stage
, customConfArgs settings
, when (stage == Stage0) bootPackageDb
, libraryArgs =<< ways settings
, when (specified HsColour) $ with HsColour
, configureArgs stage settings
, when (stage == Stage0) bootPkgConstraints
, with Gcc
, with $ Gcc stage
, when (stage /= Stage0) $ with Ld
, with Ar
, with Alex
......
......@@ -78,7 +78,7 @@ buildRule pkg @ (Package name path _) todo @ (stage, dist, settings) = do
deps <- fmap concat $ forM srcs $ \src -> do
let srcPath = path </> src
depFile = buildDir </> takeFileName src <.> "deps"
terseRun Gcc $ gccArgs srcPath pkg todo
terseRun (Gcc stage) $ gccArgs srcPath pkg todo
liftIO $ readFile depFile
writeFileChanged out deps
liftIO $ removeFiles buildDir ["*.c.deps"]
......@@ -88,7 +88,7 @@ argListRule pkg todo @ (stage, _, _) =
(argListPath argListDir pkg stage) %> \out -> do
need $ ["shake/src/Package/Dependencies.hs"] ++ sourceDependecies
ghcList <- argList (Ghc stage) $ ghcArgs pkg todo
gccList <- argList Gcc $ gccArgs "source.c" pkg todo
gccList <- argList (Gcc stage) $ gccArgs "source.c" pkg todo
writeFileChanged out $ ghcList ++ "\n" ++ gccList
buildPackageDependencies :: Package -> TodoItem -> Rules ()
......
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