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

Wang Nan wangnan0 at huawei.com
Tue Apr 2 12:43:48 CEST 2013


Hi,

I have splitted the patch into 3 ones.

PATCH 1 fix dependency about trace_defs.h
PATCH 2 make hake works in ghc 7.4.2
PATCH 3 is for ghc 7.6 and up, it is incompatible with PATCH 2.

I don't use #ifs as your suggestion.

--------- PATCH 1: fix dependency  -----------------

diff -r 12e657e0ed48 -r 7f16a9f0c7d1 .hgtags
--- a/.hgtags	Fri Mar 22 13:15:31 2013 +0100
+++ b/.hgtags	Tue Apr 02 18:37:48 2013 +0800
@@ -12,4 +12,3 @@
 91850d61e9fc89a27acc67576b816d64204987e7 release2012-11-03
 411cebe251b0da11cdd16a10a44f2b1db4143656 release2013-01-11
 571a75f9d7b42b673b2cf66eeb43762e8eb35bcb release2013-03-01
-f82a7cbc7224280b21df76032fa71ad52d903b4d release2013-03-22
diff -r 12e657e0ed48 -r 7f16a9f0c7d1 hake/ArchDefaults.hs
--- a/hake/ArchDefaults.hs	Fri Mar 22 13:15:31 2013 +0100
+++ b/hake/ArchDefaults.hs	Tue Apr 02 18:37:48 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/asmoffsets.h",
+                  PreDep InstallTree arch "/include/trace_definitions/trace_defs.h" ],
             optLdFlags = ldFlags arch,
             optLdCxxFlags = ldCxxFlags arch,
             optLibs = stdLibs arch,



------------ PATCH 2: make hake work for ghc 7.4.2   --------------

diff -r 7f16a9f0c7d1 -r 04dadf4cdede hake/Main.hs
--- a/hake/Main.hs	Tue Apr 02 18:37:48 2013 +0800
+++ b/hake/Main.hs	Tue Apr 02 18:41:47 2013 +0800
@@ -357,7 +357,7 @@
               -> 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" ]
@@ -374,8 +374,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")])


------------ PATCH 3: make hake work for ghc 7.6.2   --------------

diff -r 04dadf4cdede -r 9481bbb04676 hake/Main.hs
--- a/hake/Main.hs	Tue Apr 02 18:41:47 2013 +0800
+++ b/hake/Main.hs	Tue Apr 02 18:48:28 2013 +0800
@@ -19,7 +19,7 @@
 import System.Exit
 import GHC hiding (Target)
 import GHC.Paths ( libdir )
-import DynFlags ( defaultLogAction,
+import DynFlags ( defaultFatalMessager, defaultFlushOut,
                   xopt_set,
                   ExtensionFlag (Opt_DeriveDataTypeable) )
 import Data.Dynamic
@@ -362,7 +362,7 @@
                     ".",
                     (opt_bfsourcedir o) ./. "hake" ]
     in do
-      defaultErrorHandler defaultLogAction $ do
+      defaultErrorHandler defaultFatalMessager defaultFlushOut $ do
          runGhc (Just libdir) $ do
            dflags <- getSessionDynFlags
 	   let dflags1 = foldl xopt_set dflags [ Opt_DeriveDataTypeable ]
diff -r 04dadf4cdede -r 9481bbb04676 tools/mackerel/Fields.hs
--- a/tools/mackerel/Fields.hs	Tue Apr 02 18:41:47 2013 +0800
+++ b/tools/mackerel/Fields.hs	Tue Apr 02 18:48:28 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 04dadf4cdede -r 9481bbb04676 tools/mackerel/Main.hs
--- a/tools/mackerel/Main.hs	Tue Apr 02 18:41:47 2013 +0800
+++ b/tools/mackerel/Main.hs	Tue Apr 02 18:48:28 2013 +0800
@@ -26,6 +26,7 @@
 import qualified ShiftDriver
 import Checks
 import Dev
+import Control.Exception

 --
 -- Command line options and parsing code
diff -r 04dadf4cdede -r 9481bbb04676 tools/mackerel/ShiftDriver.hs
--- a/tools/mackerel/ShiftDriver.hs	Tue Apr 02 18:41:47 2013 +0800
+++ b/tools/mackerel/ShiftDriver.hs	Tue Apr 02 18:48:28 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))









- 2013/4/2 17:12, Kornilios Kourtis --
> Hi,
> 
> On Tue, Apr 02, 2013 at 09:33:50AM +0800, Wang Nan wrote:
>> Hi,
>>
>> I agree to avoid #ifs. However, at least the change of IIModule ->
>> IIDecl in Main.hs should be considered. Without this patch, ghc 7.4.2
>> (which you suggest in README) rejects to generate Makefile (it reports:
>> "module Hakefiles not interpreted").
>>
>> In fact, even with the IIModule -> IIDecl change, I'm unable to get
>> Makefile (it reports: stack overflow), but ghc 7.4 works with all parts
>> of the following patches applied. I don't know the exact reason.
> 
> I think that makes sense. We are using 7.4.1 which is why we have not
> seen the 7.4.2 problems reported here.  It would be great if we could
> support both 7.4.1 and 7.4.2.
> 
> Would you mind splitting up your patch into two patches?
>  #1 make hake work for ghc 7.4.2
>  #2 (ontop of #1) make hake work for ghc 7.6
> 
> Note that #1 can, also, contain any changes needed for #2 which are
> compatible with ghc 7.4.
> 
> I'd be happy to apply patch #1 (hopefully it will not break 7.4.1) in our
> tree, and put patch #2 in our wiki so that we can point people using
> 7.6.x there.
> 
> Regarding the stack overflow problem, a possible work-around is to avoid
> having build directories inside the source tree.
> 
> Thanks,
> Kornilios.
> 
>>
>>
>> -- 2013/4/1 23:50, Kornilios Kourtis --
>>> Hi,
>>>
>>> On Mon, Apr 01, 2013 at 11:21:54AM +0800, Wang Nan wrote:
>>>> 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.
>>>
>>> Thanks a lot for the patch. Admittedly, porting hake to the next ghc has
>>> not always been easy, so I'm sure we are going to make good use of it :-)
>>>
>>> However, I'm somewhat reluctant to add #ifs to the hake source code to
>>> avoid increasing code complexity. If this change would make your (or for
>>> that matter somebody else's) life easier, we'd be happy to consider it.
>>> Otherwise, if people that want to use ghc 7.6 can carry this patch on
>>> their own tree without too much effort, I think the best solution would
>>> be do just that. That being said, I don't really feel strongly about it.
>>>
>>> Thanks,
>>> Kornilios.
>>>
>>>>
>>>>
>>>>





More information about the Barrelfish-users mailing list