IRIX 6.5 support for GHC (mips-sgi-irix65)
Note: All trademarks and copyrights are registered and/or property
of their respective owners (SGI, Glasgow Univeristy...).
Here you will find:
- Brief notes on the different models to run GHC.
- Handicaps I found to get a full registerised version.
- Notes to bootstrap an unregisterised version (and run nfib.hc).
- Future projects.
- Download
- Personal notes. (;-))
Brief notes on the different models to run GHC.
Ghc is a compiler for Haskell language, a purely
functional language ( http://www.haskell.org ). This page is not intended
to explain what functional programming is, but briefly, you sholud understand
that due to the large distance between the imperative and the functional
underlying computational models , ghc generates code to be executed
in a virtual machine: the STG (Spin Tag-less Machine) designed originally
by Simon Peyton Jones, among others...
The way the runtime system implements this virtual machine
varies from the close-to-specifications of the original STG design
to the efficiency and fastness of the real STG adhoc implementation
in hardware stock.
In other words, the "theoric,elegant,universal and portable"
versus "hacking,fuzzy,local,fast, efficient" :
- Unregisterised: The purest and most portable model, on a C
compiler (also the less efficient).
- Registerised: Optimizations achieved on the previous model
(Strong dependent on GNU tools, gcc and binutils).
- Mangling action: On the output of 1, several code movements
performed and save-restore stack operations avoided.
- Native Code Generator. Generating assembler code straight,
no C pre-compilation achieved.
Handicaps I found to get a full registerised version (history of a distressing
ha[c|s]ke[r|ll] ).
I'm distressed after more than half a year hacking the ghc internals...
After that, this is all the information I can share with the Haskell community
to aid future porters (not only for those on IRIX ). I will go on hacking
every morning, as Prometeo did in the mitology. Some bugs are fixed and
new ones are discovered...It's my destiny. ;-). After all, Spanish Minister
of Science and Technology (MCyT) has invested some money ( not very much,
by the way...) for no available results... :-(
-
Resgisterised:
- For the time being (07-04-2003) , no registerised version of
GHC is possible. Why ? GNU binutils (asm,ld) are not supported at this platform
(mips-sgi-irix65). The optmizations on the original dessign
imply to use "data-generating" instructions (.word, .half,.byte...)
on the ".text" section (that containing instructionscode, when
info tables are shoved rigth up against the entry code, and the Mips Pro
as,ld , (the corporate assebler and link tools from SGI) doesn't let this.
I have heard that you can control some aspects on the assembler and linker,
but this demand a very strong knowledge of this tools. Only very specialized
embedded software interprises know how to control this, but remember I'm
just a Ph. student, we are just making lambda calculus and not programming
control systems... It would be better to wait for binutils to be delivered
in a short time. ( now Beta testing)....
-
Unregisterised:
- Unless explictly said, we are to try ghc-4.08.2/gcc-2.95
to bootstrap unregisterised, the easiest way . Installing
gcc-2.95 is up to you.
- Ok, lets try the theoretic,universal,portable way. The
first thing you need is the .hc file to boostrap. Becarefull, no every (.hc)
tar-ball from haskell.org is valid to bootstrap in a unregisterised way, even
if it is ghc-4.08.2-mybox-hc.tar.gz. You need a universal unregisterised
hc tar-ball, such as
ghc-4.08.2-unreg-hc.tar.gz
.
.. Please, download it, and my great (and inefficient) effort around
a year would not be wasted !!! It would be usefull for IRIX,HP,LINUX, Solaris...,
for unregisterised versions. See the INSTALL instructions.
- A1:First problem. Theoric portability is not always achievable
. It is on i386-unknow-linux (and others not tested), but mips-sgi-irix65
presents a problem: there is a strongly dependent border in elf format file,
that between the "read only" data section ".rodata" and the "data section",
needed for the macro LOOKS_LIKE_GHC_INFO (q )and the corporate Mips Pro
ld doesn't mark it. FIXED: After dealing two weaks with low-level elf-libraries
I found a way to mark it. Download my unstable patch ,
g
hc-4.08.2-mips-src-20030104.diff
, and you will see what I'm telling about.
- A2:.Second problem. mips-sgi-irix65 elf-files deal
with a gp-register relative section, the ".srdata", ".sdata", in order to
save indirections and optimize addressing modes. If this region is simple
GOT (Global Offset Table) you will have no problems to compile and run...
Download my nfibI.hc
and see your mips-sgi-irix65 box compute the 35 fibonacci..!! But
when final executable is more complex, ( and hsc , the proper haskell compiler
is) this GOT table is automatically split into several gp relative sections,
i.e MULTIGOT. Due to a faulty handling of gp in gcc-2.95 , I can'not proceed
this way, and leave...
- A3: ghc-4.08.2/gcc-3.0 . Mi gozo
en un pozo( In Spanish, "again, my hopes turns distressed" :-( )
gcc-3.0 has fixed the gp faulty handling. Now MULTIGOT runs well,
but... gcc-3.0 allocates const struct pointers (those affecting ghc
info pointer tables) into ".data" sections instead of "section .rodata",
what make useless the general macro LOOKS_LIKE_GHC_INFO(q) as it is defined
in ghc-4.08.2. We must lift into ghc-5.04.2
- A4: ghc-5.04.2/gcc-3.0 . ghc-5.04.2
solves the previous macro in a very elegant and portable way,so this is
my last attempt. As Simon Marlow said, this is a little fuzzy to make bootstrap...but
this my only way to proceed, as I have explained above...
- A5: ghc-X.X/cc. BTW, Don't try any
corporate SGI C compiler. GHC code uses some specific GNU sintax in somewhere.
Search for yor combination and read the bug...
CC/GHC
|
4.08.2
|
5.04.2
|
gcc-2.95
|
A1,A2
|
A2
|
gcc-3.0
|
A3
|
A4
|
cc
|
A5
|
A5
|
Notes to bootstrap an unregisterised version (and run nfib.hc).
The corresponding document "Building the Glasgow Functional Programming
Tools Suite"/Chapter 10 Porting GHC is very helpful...
However, unregisterised bootstraping is fuzzy and there are no many
indications to proceed . Take this script (may be this can contribute to
redefine the bootstrap mode in newer and easier modes...)
Prerequisites:
gmake,gcc-2.95 ... Installing is up to you.
Installing:
WARNING: except ghc-4.08.2-src.tar.gz, mirroring haskell site, and ghc-4.08.2-unreg-h[c|i].tar.gz
, the rest are unstable code.
**Last NEWS
: Edit the ghc-4.08.2/ghc/include/config.h, and fix by hand the lines: (
Give me time to make the patch...)
#define TEXT_SECTION_END_MARKER data_start
#define TEXT_SECTION_END_MARKER_DCL data_start
Running nfib.hc fib(35)
As explained above you have just got a faulty-unregisterised ghc compiler,
in practical terms, not very much, only able to compiler *.hc files, and
only when the output binary is not very complex (single GOT). In fact, the
proper haskell compiler -hsc-, is compiled but runs faulty (it is MULTIGOT).
However, for me it was very encouraging to play the first STG machine in
the world in a mips-sgi-irix65 platform...
Would you like to enjoy too ?
- ghc -optc-DNO_REGS -optc-DUSE_MINIINTERPRETER -fno-asm-mangling -funregisterised
-fvia-C -optc-g nfibI.hc -o nfibI
- ./nfibI
- 29860703
Did you know that a powerfull RTS is in action, pushing and poping many
closures in the heap, applying Beta reductionnfibI.hcs, and a Garbage
Collector is collecting useless closures... ?
Download.
Click here
Future projects.
- Waiting for GNU binutils (asm,ld) to be released for mips-sgi-irix65.
Now Beta testing. ( 2 months ?)
- Perform ghc-5.04.X unregistered bootstrap on IRIX. ( 1 months ?)
- Rewriting the evil mangler script for irix ( 1 month ?).
- Write for the first time a native code generator for mips-sgi-irix65...
( This should require an sponsor...since demands professional effort).
Personal notes.
My acknowledge to the Glasgow Haskell Compiler team...I have learnt very
much with is open source code...
After 7-9 months os code porting, I haven't reached the goal, may be I
will not pass my diploma thesis, but....
I have enjoyed VERY MUCH....
Some of my philosophy has changed and evolved... My lectures on Freud,
and over all , Friederich Nietszche had confirmed me that after an elegant
universal, theorical formalism ( such as the brilliant STG machine, the formal
operational Semantics on Lambda Calculus ...) there are obscure, fuzzy ,
instintive,chaotic, devil and creative forces... Don't you think so? Take
a look into the evil Perl-script mangler under fptools/ghc-driver/ghc-asm.prl
and tell me...
However the only way to improve is the failure and the patching...
Obsession on perfect job is the worst enemy for work well done...
Write some words to rmartine@fdi.ucm.es , the distressed ha[c|s]ke[r|ll]
....
I hope you...
Rafael Martinez Torres. Universidad Complutense de Madrid. 2003.