On Sun, Apr 08, 2007 at 07:49:24PM -0400, Gregory Wright wrote:
> 
> I have ghc-6.6 (darcs version from 20070405) running registerized on
> FreeBSD/amd64.

Excellent! Well done, and thanks for persevering!

It would be great if you could let us have a bindist and any necessary
patches.

> The fix is to patch libraries/base/Text/Regex/Posix.hs on the amd64  
> target:
> 
> --- libraries/base/Text/Regex/Posix.hs.sav      Thu Apr  5 12:05:22 2007
> +++ libraries/base/Text/Regex/Posix.hs  Thu Apr  5 12:05:45 2007
> @@ -106,7 +106,7 @@
> regexec (Regex regex_fptr) str = do
>    withCString str $ \cstr -> do
>      withForeignPtr regex_fptr $ \regex_ptr -> do
> -      nsub <- ((\hsc_ptr -> peekByteOff hsc_ptr 4)) regex_ptr
> +      nsub <- ((\hsc_ptr -> peekByteOff hsc_ptr 8)) regex_ptr
> {-# LINE 109 "Posix.hsc" #-}
>        let nsub_int = fromIntegral (nsub :: CSize)
>        allocaBytes ((1 + nsub_int) * (16)) $ \p_match -> do

Aha! That makes sense: When generating .hc files on the host machine,
hsc2hs makes a C program which generates a .hs module (with the host's
sizes embedded in it) which is finally compiled down to .hc as normal.

So I think to do this in a way that is porting-friendly, hsc2hs would
have to convert

    f = ... #peek regex_t, re_nsub ...

into something like

    -- Haskell:
    foreign import re_nsub_off :: Int
    f = ... (\hsc_ptr -> peekByteOff hsc_ptr re_nsub_off) ...

    /* C */
    #import "HsFFI.h"
    HsInt re_nsub_off(void) { return ... }

Unfortunately I don't think we can do anything as nice with #type.

> With this patch, we are pretty close.  However, there still seems to be
> something wrong with the splitter.  I can make a working registerized
> compiler if I set splitObjs=NO in build.mk, but it seems as if  
> whatever is
> wrong with ghc-split shouldn't be too hard to fix.
> 
> I've glanced at ghc-split.lprl, but on what files is it invoked? Can
> I run it from the command line on a file and see check what comes out?

If you compile a module with

    ghc -v -keep-tmp-files

then you should see the commandline it is using, and it should leave the
files for you to examine, and rerun the commands on, afterwards.


Thanks
Ian

_______________________________________________
Glasgow-haskell-users mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to