GHC on MacOS X
Simon Marlow
simonmar@microsoft.com
Mon, 4 Mar 2002 12:13:21 -0000
> I've spent a day compiling ghc (5.03, checked out from CVS a=20
> few days ago) on MacOS X 10.1.
> The results: another unregistered build, a PowerPC implementation
> of createAdjustor (foreign export dynamic now works!).
Great stuff! You should coordinate with Sigbjorn Finne <sof@galois.com>
who is also working on a MacOS X port, I believe.
> I needed to modify a total of six files:
> File: Adjustor.c Status: Locally Modified
> File: ClosureFlags.c Status: Locally Modified
> File: Main.c Status: Locally Modified
> File: Storage.h Status: Locally Modified
> File: Posix.hs Status: Locally Modified
> File: Socket.hsc Status: Locally Modified
If you post the patches to cvs-ghc@haskell.org, we'll take a look.
> Socket.hsc refused to compile because on MacOS X, sigaddset()=20
> is a macro
> that chokes if its parameter is a void*. I added a wrapper=20
> function in a
> small C header file, but that's really ugly. What's the "proper" way?
The right way is to add a wrapper, as you've done. With proper use of
'inline' you can eliminate any performance reduction too (it's probably
not that big a deal, though).
> I also got a compiler panic on one of my own modules I tried=20
> to compile.
> I'll post that to ghc-bugs, as I somehow don't think it has to do with
> the PPC port.
There are/were some problems due to rottage in the unregisterised code
generation path, but I think Sigbjorn has mostly cleaned these up now.
Try updating your CVS tree to get the fixes.
> What I really need, of course, is a registered compiler...=20
> I'm even prepared to learn some Perl to do that, but for now I
> don't really have a clue what to
> do - I don't know enough about Intel/Sparc assembly language=20
> and runtime
> conventions to find out from the code without a few hints - can anyone
> give me a few pointers what the mangler is supposed to do _exactly_?
Ok, the mangler really just does two things. It removes the C function
prologues/epilogues to support tail-calls, and it brings info tables and
entry code next to each other. You'll get most of the way there by just
setting up a PPC machine-specific section at the start of
mangler/ghc-asm.lprl (there's already a powerpc version for rs6000, I'm
not sure how relevant this is, though).
The other things you need to look at are:=20
- rts/StgCRun.c, which is the tiny layer between C land and
registerised Haskell land, which just saves a few registers
and makes some space on the C stack. =20
- includes/TailCalls.c (probably the defaults for FB_ FE_ and
JMP_() will do).
- includes/MachRegs.h, which defines the register mapping.
There's one for PPC already, which again may or may not be
relevant.
Be sure to talk to Sigbjorn before diving in though, so as to avoid
duplicating any effort.
Cheers,
Simon