[commit: ghc] master: Preliminary nofib rule (#599) (d6c4e04)

git at git.haskell.org git at git.haskell.org
Tue Oct 23 20:17:08 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/d6c4e0423c3c41f01daf6a3e0403e8cf6ca82d95/ghc

>---------------------------------------------------------------

commit d6c4e0423c3c41f01daf6a3e0403e8cf6ca82d95
Author: Alp Mestanogullari <alpmestan at gmail.com>
Date:   Thu May 17 15:19:06 2018 +0200

    Preliminary nofib rule (#599)
    
    * first draft of a nofib rule
    
    * address some of Andrey's feedback
    
    * refactor nofib into a proper Builder, now runs but one of the programs fails
    
    * more subtle error handling, docs
    
    * get rid of RunNofib builder, invoke commands directly


>---------------------------------------------------------------

d6c4e0423c3c41f01daf6a3e0403e8cf6ca82d95
 hadrian.cabal                 |  1 +
 src/Main.hs                   |  2 ++
 src/Rules/Nofib.hs            | 58 +++++++++++++++++++++++++++++++++++++++++++
 src/Settings/Builders/Make.hs | 11 +++++++-
 4 files changed, 71 insertions(+), 1 deletion(-)

diff --git a/hadrian.cabal b/hadrian.cabal
index 96d5891..0bcbf1f 100644
--- a/hadrian.cabal
+++ b/hadrian.cabal
@@ -62,6 +62,7 @@ executable hadrian
                        , Rules.Gmp
                        , Rules.Libffi
                        , Rules.Library
+                       , Rules.Nofib
                        , Rules.Program
                        , Rules.Register
                        , Rules.Selftest
diff --git a/src/Main.hs b/src/Main.hs
index c90b052..083e683 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -10,6 +10,7 @@ import qualified Environment
 import qualified Rules
 import qualified Rules.Clean
 import qualified Rules.Documentation
+import qualified Rules.Nofib
 import qualified Rules.SourceDist
 import qualified Rules.Selftest
 import qualified Rules.Test
@@ -43,6 +44,7 @@ main = do
             Rules.buildRules
             Rules.Documentation.documentationRules
             Rules.Clean.cleanRules
+            Rules.Nofib.nofibRules
             Rules.oracleRules
             Rules.Selftest.selftestRules
             Rules.SourceDist.sourceDistRules
diff --git a/src/Rules/Nofib.hs b/src/Rules/Nofib.hs
new file mode 100644
index 0000000..e0ef5ea
--- /dev/null
+++ b/src/Rules/Nofib.hs
@@ -0,0 +1,58 @@
+module Rules.Nofib where
+
+import Base
+import Expression
+import GHC
+import Oracles.Setting
+import Target
+
+import System.Environment
+import System.Exit
+
+nofibRules :: Rules ()
+nofibRules = do
+  root <- buildRootRules
+
+  -- a phony "nofib" rule that just triggers
+  -- the rule below.
+  "nofib" ~> need [root -/- nofibLogFile]
+
+  -- a rule to produce <build root>/nofig-log
+  -- by running the nofib suite and capturing
+  -- the relevant output.
+  root -/- nofibLogFile %> \fp -> do
+    needNofibDeps
+
+    makePath <- builderPath (Make "nofib")
+    top <- topDirectory
+    ghcPath <- builderPath (Ghc CompileHs Stage2)
+    perlPath <- builderPath Perl
+
+    -- some makefiles in nofib rely on a $MAKE
+    -- env var being defined
+    liftIO (setEnv "MAKE" makePath)
+
+    -- this runs make commands in the nofib
+    -- subdirectory, passing the path to
+    -- the GHC to benchmark and perl to
+    -- nofib's makefiles.
+    let nofibArgs = ["WithNofibHc=" ++ (top -/- ghcPath), "PERL=" ++ perlPath]
+    unit $ cmd (Cwd "nofib") [makePath] ["clean"]
+    unit $ cmd (Cwd "nofib") [makePath] (nofibArgs ++ ["boot"])
+    (Exit e, Stdouterr log) <- cmd (Cwd "nofib") [makePath] nofibArgs
+    writeFile' fp log
+    if e == ExitSuccess
+      then putLoud $ "nofib log available at " ++ fp
+      else error $ "nofib failed, full log available at " ++ fp
+
+nofibLogFile :: FilePath
+nofibLogFile = "nofib-log"
+
+
+-- the dependencies that nofib seems to require.
+needNofibDeps :: Action ()
+needNofibDeps = do
+  unlitPath <- programPath (Context Stage1 unlit vanilla)
+  mtlPath <- pkgConfFile (Context Stage1 mtl vanilla)
+  need [ unlitPath, mtlPath ]
+  needBuilder (Ghc CompileHs Stage2)
diff --git a/src/Settings/Builders/Make.hs b/src/Settings/Builders/Make.hs
index cc350df..79d73cc 100644
--- a/src/Settings/Builders/Make.hs
+++ b/src/Settings/Builders/Make.hs
@@ -1,5 +1,6 @@
 module Settings.Builders.Make (makeBuilderArgs) where
 
+import Builder
 import Rules.Gmp
 import Rules.Libffi
 import Settings.Builders.Common
@@ -9,8 +10,16 @@ makeBuilderArgs = do
     threads    <- shakeThreads <$> expr getShakeOptions
     gmpPath    <- expr gmpBuildPath
     libffiPath <- expr libffiBuildPath
+    ghcPath    <- expr $
+      (-/-) <$> topDirectory <*> builderPath (Ghc CompileHs Stage2)
+    perlPath   <- expr $ builderPath Perl
     let t = show $ max 4 (threads - 2) -- Don't use all Shake's threads
     mconcat
         [ builder (Make gmpPath          ) ? pure ["MAKEFLAGS=-j" ++ t]
         , builder (Make libffiPath       ) ? pure ["MAKEFLAGS=-j" ++ t, "install"]
-        , builder (Make "testsuite/tests") ? pure ["THREADS=" ++ t, "fast"] ]
+        , builder (Make "testsuite/tests") ? pure ["THREADS=" ++ t, "fast"]
+        , builder (Make "nofib"          ) ? pure
+            [ "WithNofibHc=" ++ ghcPath
+            , "PERL=" ++ perlPath
+            ]
+        ]



More information about the ghc-commits mailing list