[Barrelfish-users] Make Hake works in ghc 7.4 and 7.6

Wang Nan wangnan0 at huawei.com
Mon Apr 1 05:21:54 CEST 2013


Sorry, the previous patch seems insufficient. cpp hates "\" endding lines.

Following updated patch has been tested under ghc 7.4.2 and ghc 7.6.2.



diff -r 12e657e0ed48 hake/ArchDefaults.hs
--- a/hake/ArchDefaults.hs	Fri Mar 22 13:15:31 2013 +0100
+++ b/hake/ArchDefaults.hs	Mon Apr 01 11:33:50 2013 +0800
@@ -112,7 +112,8 @@
             optDependencies =
                 [ PreDep InstallTree arch "/include/errors/errno.h",
                   PreDep InstallTree arch "/include/barrelfish_kpi/capbits.h",
-                  PreDep InstallTree arch "/include/asmoffsets.h" ],
+                  PreDep InstallTree arch "/include/trace_definitions/trace_defs.h",
+		  PreDep InstallTree arch "/include/asmoffsets.h" ],
             optLdFlags = ldFlags arch,
             optLdCxxFlags = ldCxxFlags arch,
             optLibs = stdLibs arch,
diff -r 12e657e0ed48 hake/Main.hs
--- a/hake/Main.hs	Fri Mar 22 13:15:31 2013 +0100
+++ b/hake/Main.hs	Mon Apr 01 11:33:50 2013 +0800
@@ -19,9 +19,14 @@
 import System.Exit
 import GHC hiding (Target)
 import GHC.Paths ( libdir )
-import DynFlags ( defaultLogAction,
+import DynFlags (
+#if __GLASGOW_HASKELL__ < 706
+                  defaultLogAction,
+#else
+                  defaultFatalMessager, defaultFlushOut,
+#endif
                   xopt_set,
-                  ExtensionFlag (Opt_DeriveDataTypeable) )
+                  ExtensionFlag (Opt_DeriveDataTypeable, Opt_Cpp) )
 import Data.Dynamic
 import Data.Maybe
 import Data.List
@@ -357,15 +362,19 @@
               -> IO [(String,HRule)]
 evalHakeFiles o allfiles hakefiles =
     let imports = [ "Hakefiles"]
-        all_imports = imports
+        all_imports = ("Prelude":"HakeTypes":imports)
         moddirs = [ (opt_installdir o) ./. "hake",
                     ".",
                     (opt_bfsourcedir o) ./. "hake" ]
-    in do
+    in do
+#if __GLASGOW_HASKELL__ < 706
       defaultErrorHandler defaultLogAction $ do
+#else
+      defaultErrorHandler defaultFatalMessager defaultFlushOut $ do
+#endif
          runGhc (Just libdir) $ do
            dflags <- getSessionDynFlags
-	   let dflags1 = foldl xopt_set dflags [ Opt_DeriveDataTypeable ]
+	   let dflags1 = foldl xopt_set dflags [ Opt_DeriveDataTypeable, Opt_Cpp ]
 	   _ <- setSessionDynFlags dflags1{
 		importPaths = moddirs,
                 hiDir = Just "./hake",
@@ -374,8 +383,7 @@
            targets <- mapM (\m -> guessTarget m Nothing) imports
            setTargets targets
            load LoadAllTargets
-           modlist <- mapM (\m -> findModule (mkModuleName m) Nothing) all_imports
-           setContext [IIModule m | m <- modlist]
+           setContext [(IIDecl . simpleImportDecl) (mkModuleName m) | m <- (all_imports)]
            val <- dynCompileExpr "Hakefiles.hf :: [(String, HRule)]"
            return (fromDyn val [("failed",Error "failed")])

diff -r 12e657e0ed48 hake/RuleDefs.hs
--- a/hake/RuleDefs.hs	Fri Mar 22 13:15:31 2013 +0100
+++ b/hake/RuleDefs.hs	Mon Apr 01 11:33:50 2013 +0800
@@ -779,7 +779,8 @@
             NoDep SrcTree "src" ".",
             Str "-odir ", NoDep BuildTree "tools" ".",
             Str "-hidir ", NoDep BuildTree "tools" ".",
-            Str "-rtsopts=all",
+            Str "-cpp",
+	    Str "-rtsopts=all",
             Str "--make ",
             In SrcTree "src" main,
             Str "-o ",
@@ -884,11 +885,11 @@
 appGetOptionsForArch arch args =
     (options arch) { extraIncludes =
                          [ NoDep SrcTree "src" a | a <- Args.addIncludes args],
-                     optIncludes = (optIncludes $ options arch) \\
+                     optIncludes = (optIncludes $ options arch) \\\
                          [ NoDep SrcTree "src" i | i <- Args.omitIncludes args ],
-                     optFlags = (optFlags $ options arch) \\
+                     optFlags = (optFlags $ options arch) \\\
                                 [ Str f | f <- Args.omitCFlags args ],
-                     optCxxFlags = (optCxxFlags $ options arch) \\
+                     optCxxFlags = (optCxxFlags $ options arch) \\\
                                    [ Str f | f <- Args.omitCxxFlags args ],
                      optSuffix = "_for_app_" ++ Args.target args,
                      extraFlags = Args.addCFlags args ++ Args.addCxxFlags args,
@@ -933,11 +934,11 @@
 libGetOptionsForArch arch args =
     (options arch) { extraIncludes =
                          [ NoDep SrcTree "src" a | a <- Args.addIncludes args],
-                     optIncludes = (optIncludes $ options arch) \\
+                     optIncludes = (optIncludes $ options arch) \\\
                          [ NoDep SrcTree "src" i | i <- Args.omitIncludes args ],
-                     optFlags = (optFlags $ options arch) \\
+                     optFlags = (optFlags $ options arch) \\\
                                 [ Str f | f <- Args.omitCFlags args ],
-                     optCxxFlags = (optCxxFlags $ options arch) \\
+                     optCxxFlags = (optCxxFlags $ options arch) \\\
                                    [ Str f | f <- Args.omitCxxFlags args ],
                      optSuffix = "_for_lib_" ++ Args.target args,
                      extraFlags = Args.addCFlags args ++ Args.addCxxFlags args,
diff -r 12e657e0ed48 hake/hake.sh
--- a/hake/hake.sh	Fri Mar 22 13:15:31 2013 +0100
+++ b/hake/hake.sh	Mon Apr 01 11:33:50 2013 +0800
@@ -125,6 +125,7 @@

 echo "Building hake..."
 ghc -O --make -XDeriveDataTypeable \
+    -cpp \
     -package ghc \
     -package ghc-paths \
     -o hake/hake \
diff -r 12e657e0ed48 lib/openssl-1.0.0d/Hakefile
--- a/lib/openssl-1.0.0d/Hakefile	Fri Mar 22 13:15:31 2013 +0100
+++ b/lib/openssl-1.0.0d/Hakefile	Mon Apr 01 11:33:50 2013 +0800
@@ -11,7 +11,7 @@
 --------------------------------------------------------------------------
 -- file list generated with this command:
 -- asq at schlaptop2:~/tmp/openssl/compile_linux/openssl-1.0.0d/crypto$ \
--- for i in [ `objdump -f libcrypto.a |sed -e '/o:/!d' -e 's/o:.*/c/' `; \
+-- for i in [ `objdump -f libcrypto.a |sed -e '/o:/!d' -e 's/o:.*/c/' `; \
 -- do find . -name $i; done |sed -e 's/^/"/'|sed -e 's/$/",/' >> \
 -- /home/asq/hg/barrelfish.dyn_adpt/usr/skb/testapps/openssl-1.0.0d/crypto/Hakefile

diff -r 12e657e0ed48 tools/flounder/Backend.lhs
--- a/tools/flounder/Backend.lhs	Fri Mar 22 13:15:31 2013 +0100
+++ b/tools/flounder/Backend.lhs	Mon Apr 01 11:33:50 2013 +0800
@@ -47,19 +47,19 @@

 %if false

->     "/*\n * Interface Definition: " ++ name ++ "\n\
->     \ * Generated from: " ++ filename ++ "\n\
->     \ * \n\
->     \ * Copyright (c) 2009, ETH Zurich.\n\
->     \ * All rights reserved.\n\
->     \ * \n\
->     \ * This file is distributed under the terms in the attached LICENSE\n\
->     \ * file. If you do not find this file, copies can be found by\n\
->     \ * writing to:\n\
->     \ * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich.\n\
->     \ *  Attn: Systems Group.\n\
->     \ * \n\
->     \ * THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT!\n\
+>     "/*\n * Interface Definition: " ++ name ++ "\n\\
+>     \ * Generated from: " ++ filename ++ "\n\\
+>     \ * \n\\
+>     \ * Copyright (c) 2009, ETH Zurich.\n\\
+>     \ * All rights reserved.\n\\
+>     \ * \n\\
+>     \ * This file is distributed under the terms in the attached LICENSE\n\\
+>     \ * file. If you do not find this file, copies can be found by\n\\
+>     \ * writing to:\n\\
+>     \ * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich.\n\\
+>     \ *  Attn: Systems Group.\n\\
+>     \ * \n\\
+>     \ * THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT!\n\\
 >     \ */\n\n"

 %endif
diff -r 12e657e0ed48 tools/mackerel/BitFieldDriver.hs
--- a/tools/mackerel/BitFieldDriver.hs	Fri Mar 22 13:15:31 2013 +0100
+++ b/tools/mackerel/BitFieldDriver.hs	Mon Apr 01 11:33:50 2013 +0800
@@ -91,18 +91,18 @@
 -------------------------------------------------------------------------

 r_preamble dev =
-    "/*\n * DEVICE DEFINITION: " ++ (Dev.desc dev) ++ "\n\
-    \ * \n\
-    \ * Copyright (c) 2007, ETH Zurich.\n\
-    \ * All rights reserved.\n\
-    \ * \n\
-    \ * This file is distributed under the terms in the attached LICENSE\n\
-    \ * file. If you do not find this file, copies can be found by\n\
-    \ * writing to:\n\
-    \ * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich.\n\
-    \ *  Attn: Systems Group.\n\
-    \ * \n\
-    \ * THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT!\n\
+    "/*\n * DEVICE DEFINITION: " ++ (Dev.desc dev) ++ "\n\\
+    \ * \n\\
+    \ * Copyright (c) 2007, ETH Zurich.\n\\
+    \ * All rights reserved.\n\\
+    \ * \n\\
+    \ * This file is distributed under the terms in the attached LICENSE\n\\
+    \ * file. If you do not find this file, copies can be found by\n\\
+    \ * writing to:\n\\
+    \ * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich.\n\\
+    \ *  Attn: Systems Group.\n\\
+    \ * \n\\
+    \ * THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT!\n\\
     \ */\n\n"

 -- Top-level create-a-header-file
diff -r 12e657e0ed48 tools/mackerel/Fields.hs
--- a/tools/mackerel/Fields.hs	Fri Mar 22 13:15:31 2013 +0100
+++ b/tools/mackerel/Fields.hs	Mon Apr 01 11:33:50 2013 +0800
@@ -121,11 +121,11 @@
 -- are polymorphic so that they don't need to know how large the total
 -- load unit is (32 bits? 8 bits?) etc.
 --
-extract_mask :: (Bits a) => Rec -> Integer -> a
+extract_mask :: (Num a, Bits a) => Rec -> Integer -> a
 extract_mask f sz =
     foldl setBit 0 (enumFromTo (fromInteger $ offset f)
                                (fromInteger $ (offset f) + (size f) - 1))
-insert_mask :: (Bits a) => Rec -> Integer -> a
+insert_mask :: (Num a, Bits a) => Rec -> Integer -> a
 insert_mask f sz =
     foldl complementBit (extract_mask f sz) (enumFromTo 0 (fromInteger sz - 1))

diff -r 12e657e0ed48 tools/mackerel/Main.hs
--- a/tools/mackerel/Main.hs	Fri Mar 22 13:15:31 2013 +0100
+++ b/tools/mackerel/Main.hs	Mon Apr 01 11:33:50 2013 +0800
@@ -26,6 +26,9 @@
 import qualified ShiftDriver
 import Checks
 import Dev
+#if __GLASGOW_HASKELL__ >= 706
+import Control.Exception
+#endif

 --
 -- Command line options and parsing code
diff -r 12e657e0ed48 tools/mackerel/ShiftDriver.hs
--- a/tools/mackerel/ShiftDriver.hs	Fri Mar 22 13:15:31 2013 +0100
+++ b/tools/mackerel/ShiftDriver.hs	Mon Apr 01 11:33:50 2013 +0800
@@ -306,12 +306,12 @@
 --
 -- Functions to generate masks to select or deselect a subfield of bits
 --
-select_mask :: (Bits a) => Integer -> Integer -> Integer -> a
+select_mask :: (Num a, Bits a) => Integer -> Integer -> Integer -> a
 select_mask word_size start width =
     foldl setBit 0 (enumFromTo (fromInteger $ start)
                                (fromInteger $ start + width - 1))

-deselect_mask :: (Bits a) => Integer -> Integer -> Integer -> a
+deselect_mask :: (Num a, Bits a) => Integer -> Integer -> Integer -> a
 deselect_mask word_size start width =
     foldl complementBit (select_mask word_size start width)
               (enumFromTo 0 (fromInteger word_size - 1))






More information about the Barrelfish-users mailing list