RE: GHC Alpha port?

2001-07-16 Thread Simon Marlow

 On 2001-07-13T16:55:57-0400, Ken Shan wrote:
  Current hurdle: ghc-inplace doesn't seem to be finding its .hi files
  for basic stuff.
  
  puffin:~$ cat Main.hs
  module Main where
  import IO
  main = putStrLn Hello, world!
  
  puffin:~$ u/ghc-port/alpha/ghc/compiler/ghc-inplace Main.hs
  Main.hs:1:
  failed to load interface for `Prelude':
  Could not find interface file for `Prelude'
  
  Main.hs:2:
  failed to load interface for `IO':
  Could not find interface file for `IO'
 
 This problem was because struct dirent differs between i386-linux and
 alpha-osf3.  I fixed it by running the intermediate C program
 generated by hsc2hs remotely on our alpha machine instead of locally
 on our linux machine.

well tracked down.

 Hello, world! works now!  Yay!

:-)  great work!

 So far, I've discovered 3 reasons why .hc files are not entirely
 portable across platforms.

There are quite a few bootstrapping and cross-compilation issues to be
resolved, and things got harder recently due to the use of hsc2hs to
generate some of the Haskell sources, which means the .hs files and
therefore the .hc files have platform-dependent content.  This is
somewhat unfortunate, but using careful cross-compilation techniques (as
you suggest) we can work around it.

I'm hoping that after this experience(!) we can do two things:

  - add some support for cross-compilation to the build system.
  - write down exactly what one needs to do to make this work, and
put the instructions in the build system documentation.

  1. ghc/includes/MachDeps.h, which is #included by some Haskell source
 files, in turn #includes ghc/includes/config.h, which differs from
 platform to platform.
 
 SOLUTION: Modify MachDeps.h to #include the config.h from
 alpha-osf3, even when compiling on i386-linux.

Yep: for cross compilation of the .hc files, the first thing to do is
run ./configure on the target platform and take the output back to the
host.  In general, the sources and build system should make the
distinction between the host platform's config and the target platform's
config, but it's probably a lot of work to get this right.

  2. The .hs file produced by hsc2hs differs from platform to platform,
 because the intermediate C program it generates necessarily
 behaves differently on each platform.
 
 SOLUTION: Add --keep-tmp-files flag to hsc2hs.  Run the
 intermediate C program over on alpha-osf3.

Yes.

  3. Liveness bitmaps are of different width (32 bits vs 64 bits)
 between platforms, and the compiler generates different HC code
 based on the width.
 
 SOLUTION: Make the compiler generate platform-independent HC code
 that uses newly defined preprocessor macros to switch between
 32-bit and 64-bit liveness bitmaps at C compilation time.

yes, we should definitely do this.  The .hc files are supposed to be
independent of word size, so hopefully this is the only wrinkle.

 These fixes (especially #1) make me uneasy about the bootstrapping
 process.  Here's my current limited understanding of the making of HC
 files:
 
  a. First we use the existing GHC to compile a new compiler (that
 produces unregisterised code)
 
  b. Second we use the new compiler to compile a new library (keeping
 the unregisterised HC files)
 -- This new library is compiled for use on alpha-osf3, not
i386-linux, in terms of issues (1) and (2) above.
 
  c. Third we use the new compiler from (a), in conjuction with the new
 library from (b), to compile a doubly new compiler (that produces
 unregisterised code) (keeping the unregisterised HC files)
 -- This doubly new compiler is compiled for use on alpha-osf3, not
i386-linux, in terms of issues (1) and (2) above.
 
  d. Finally we ship the HC files kept from steps (b) and (c) for use
 on the target platform
 
 Note that, in step (c), we run the i386-linux compiler from (a) with
 the alpha-osf3 library from (b).  The library produced in (b) is
 incorrect as i386-linux code, but that's okay because all we want from
 (b) are the HC files anyway.  Consequently, the doubly new compiler
 produced in (c) is also incorrect as i386-linux code.  That's again
 okay because all we really want from step (c) are the HC files anyway.
 Just to make sure, though, could you please confirm the following:?
 
 In step (c), the once-new compiler uses (b) only as data, not as
 code.  In other words, even though (b) is incorrect as i386-linux
 code (and so (c) is incorrect as i386-linux code), the HC files
 produced in (c) are still perfectly correct as alpha-osf3 code.

This should be the case, but we need to be careful about which settings
from the environment are used when compiling the compiler itself.  I can
see the following dependencies at the moment:

  - the compiler has a few #ifdefs for Windows.  As long as neither
the host nor the target in a 

GHC 5.01 Zarjaz: Test release for Windows

2001-07-16 Thread Reuben Thomas

There's a test InstallShield for Windows of GHC 5.01 now available at

http://www.haskell.org/ghc/dist/5.00.2/ghc-5-01.exe

There is no link to this from the web pages, as it's not intended for
general consumption.

This is a thrill-seekers' release (hence the moniker). Please do try it out
and report problems; I'm currently using it as my installed compiler, so I'm
interested in fixing any.

-- 
http://sc3d.org/rrt/
Reality is what refuses to disappear when you stop believing in it (Dick)


___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



do's and error messages

2001-07-16 Thread George Russell

If you have a type error message at the very start of a do statement, the result
can be rather confusing, because the typechecker doesn't know that do's are
almost always have type (IO (something)) and so tries to shoehorn the monad
to fit the type.  This has actually happened to me several times; the worst
case is when the result is (for example) a list, which allows the error to
propagate further.  Is there some way of doing something about this?

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



RE: do's and error messages

2001-07-16 Thread Simon Peyton-Jones

Here's an example:

f x = do { c ; putStrLn x; return () }

Test.hs:3:
Couldn't match `[]' against `IO'
Expected type: [t]
Inferred type: IO ()
In the application `putStrLn x'
in a `do' expression pattern binding: putStrLn x


I don't see an easy way to improve this.  I suppose we could
do some kind of voting thing, where we take a majority view about 
what the result type constructor of the monad is... but that would
take a bit of work.

Hmm.It's a good point, but I'm inclined to wait until there are more
yells before investing effort here.  

Simon

| -Original Message-
| From: George Russell [mailto:[EMAIL PROTECTED]] 
| Sent: 16 July 2001 15:56
| To: [EMAIL PROTECTED]
| Subject: do's and error messages
| 
| 
| If you have a type error message at the very start of a do 
| statement, the result can be rather confusing, because the 
| typechecker doesn't know that do's are almost always have 
| type (IO (something)) and so tries to shoehorn the monad to 
| fit the type.  This has actually happened to me several 
| times; the worst case is when the result is (for example) a 
| list, which allows the error to propagate further.  Is there 
| some way of doing something about this?
| 
| ___
| Glasgow-haskell-users mailing list 
| [EMAIL PROTECTED] 
| http://www.haskell.org/mailman/listinfo/glasgow-| haskell-users
| 

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



Re: do's and error messages

2001-07-16 Thread Ken Shan

On 2001-07-16T09:48:46-0700, Simon Peyton-Jones wrote:
 Here's an example:
   f x = do { c ; putStrLn x; return () }

Would

asIO :: IO a - IO a
asIO = id

help here?

-- 
Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig
See the sun in the midst of the rain. 
Scoop clear water from the heart of the fire.

 PGP signature