Re: porting nhc98 to plan9
Fernan Bolando <[email protected]> Thu, 10 Sep 2009 16:38:23 +0800
| Newsgroups | gmane.comp.lang.haskell.nhc.user |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Sep 10, 2009 at 3:57 PM, Malcolm Wallace <[email protected]> wrote: > Hi Fernan, > >> Aside from below code. I am also having problems compiling hc files with >> #define CT_v249 ((void*)startLabel+464) > > By way of explanation, the idea of these symbols is that the bytecode > sometimes needs to refer to an indexed position elsewhere in the bytecode= . > =A0If the indexed position needs to be visible externally (to this module= ), it > is declared like > >> =A0 =A0unsigned F0_Prelude_46primLeave[] =3D { > > but in the cases where it need only be visible internal to the module (e.= g. > a constant table (CT) associated with a function), we use an address > calculation instead: > >> =A0 =A0#define CT_v249 =A0 =A0 ((void*)startLabel+464) > > In both cases, it is important that the bytecode be continuous, that is, = in > a sequence like > > =A0 =A0, bytes2word('u','p','l','e') > =A0 =A0}; > =A0 =A0unsigned PC_Prelude_4618[] =3D { > =A0 =A0 =A0bytes2word('P','r','e','l') > > it is necessary that the bytes are really in the sequence > > =A0 =A0'u','p','l','e','P','r','e','l' > > The symbol PC-Prelude_4618 refers to the middle of this sequence - it sho= uld > not start a new section of memory, separated from the previous section. > > >> It appears that it is trying to pointer addition with a void*. This is >> ok with gcc as a >> "non-standard extension", but it will not work with plan9. >> >> So far I did this to make those section compile >> >> 1. changed userLabel define >> --#define userLabel(fun) ((unsigned)fun) >> ++#define userLabel(fun) ((unsigned*)fun) >> >> 2. removed void* pointer addition by writing a script >> from #define CT_v249 =A0 =A0((void*)startLabel+464) >> to #define CT_v249 =A0 =A0 =A0((unsigned char*)startLabel+464) > > OK, that seems like a reasonable change - it should preserve the invarian= ts > I described above. > > If you manage to get nhc98 bootstrapped on plan9, do please send your > changes to me, so that I can incorporate them into the main nhc98 tree - > then everyone else can benefit too. > Hi Malcolm Thank you for your explanation of the bytecode. I really havn't understand the nhc98comp operation yet. I am basically just running the c files through the plan9 compiler and fix what ever issues come up. I am still doing a lot of guessing here, but I a few more questions. 1. The hc files are generated by nhc98comp? I will still need to modify nhc98comp to always produce the unsigned char*? 2. I am also bypassing nhc98 script during the prelude build. I am created a separate script to compile prelude under plan9. The script just loads the hc files into the C compiler. 3. I am still guessing here, but If item 2 is an ok approach is it possible to simply compile src/runtime/Runtime.a and use the .o files from a unix build? thanks fernan --=20 http://www.fernski.com