Re: Haskell on ARM (was Re: ANN: Topkata)

2008/6/25 Braden Shepherdson
Jeremy Shaw wrote:
If any does attempt to build for the ARM, please, please, please, document what you do in the wiki. And, if you do, edit the wiki as you go, you definitely won't be able to remember what you did after the fact. (Or, at the very least, use some program to capture everything you do so that you can refer to it later).
And, finally, I heard vague rumors a while ago that made me think that GHC 6.10 might have a pure ANSI-C backend? Is there any truth to this? That would make porting much easier if it meant you did not have to do steps 1-4.
j. ps. I would be happy to try to answer any questions if someone tries a port. I would still like to run GHC on my 770, and I hope to own an iPhone if they fix a few ommisions (bluetooth keyboard support, and similar stuff).
I recently acquired the ARM-based Nokia N810 (and <3 it), powered by Maemo. Running a uname -a on it:
Linux Nokia-N810-42-19 2.6.21-omap1 #2 Fri Nov 16 16:24:58 EET 2007 armv6l unknown
I would love a working GHC implementation on it, if for nothing else than how awesome it would be. Whether that means using a C back-end or native compilation doesn't matter to me so much.
I might be one to attempt this, as I know C and ARM-ish asm decently well and have a powerful desktop to compile on. I have no familiarity with GHC internals, though. Lastly, I won't have anything like the time to attempt this seriously until mid-September or so.
Oops, forgot to Cc the list. Next year I'll be working on a project for my undergraduate computing course at UNSW that will involve getting GHC to target the Nintendo DS. It'll require cross-compilation, because the DS isn't powerful enough to actually run GHC (4M main ram and a 66MHz processor). It'll also require that I significantly strip down the runtime system, as the current RTS won't fit in 4M and leave any left over for the main application. I'll be documenting the whole process, but I won't be starting until next year... Jeremy

At Fri, 27 Jun 2008 09:57:29 +1000, Jeremy Apthorp wrote:
Next year I'll be working on a project for my undergraduate computing course at UNSW that will involve getting GHC to target the Nintendo DS. It'll require cross-compilation, because the DS isn't powerful enough to actually run GHC (4M main ram and a 66MHz processor).
Cool! By cross-compilation, I assume you mean, a version of GHC which runs on x86, but generates ARM assembly? Another option might be to use a nintendo DS emulator which has been configured to support more RAM and CPU power ? A true cross-compiler would be nice though, because it will run much faster. GHC does have some support for cross-compilation, but in the current implementation, it is mostly (entirely?) there for bootstrapping. I have no idea how the ghc backend rewrite for 6.10 will affect this. Hope this helps, j.

Thanks for sharing your experences. I just tried to port GHC 6.8.3 to my TI Davincci (c6446) board by following the GHC Wiki Building/Porting page [1]. Both arm-compile and cross-compile version have failed unfortunately. So, I turn to try compile an local GHC on linux. It takes me so many time. I can not finish building it before off work. [1] http://hackage.haskell.org/trac/ghc/wiki/Building/Porting#PortingGHCtoanewpl... ------------------ L.Guo 2008-07-02 ------------------------------------------------------------- From: Jeremy Shaw At: 2008-06-28 02:57:38 Subject: Re: [Haskell-cafe] Re: Haskell on ARM (was Re: ANN: Topkata) Cool! By cross-compilation, I assume you mean, a version of GHC which runs on x86, but generates ARM assembly? Another option might be to use a nintendo DS emulator which has been configured to support more RAM and CPU power ? A true cross-compiler would be nice though, because it will run much faster. GHC does have some support for cross-compilation, but in the current implementation, it is mostly (entirely?) there for bootstrapping. I have no idea how the ghc backend rewrite for 6.10 will affect this. Hope this helps, j. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Could we start documenting this on the wiki ? It will be interesting to keep track of what we have tried, what attempts failed and why. -- Don leaveye.guo:
Thanks for sharing your experences.
I just tried to port GHC 6.8.3 to my TI Davincci (c6446) board by following the GHC Wiki Building/Porting page [1]. Both arm-compile and cross-compile version have failed unfortunately.
So, I turn to try compile an local GHC on linux. It takes me so many time. I can not finish building it before off work.
[1] http://hackage.haskell.org/trac/ghc/wiki/Building/Porting#PortingGHCtoanewpl...
------------------ L.Guo 2008-07-02
------------------------------------------------------------- From: Jeremy Shaw At: 2008-06-28 02:57:38 Subject: Re: [Haskell-cafe] Re: Haskell on ARM (was Re: ANN: Topkata)
Cool!
By cross-compilation, I assume you mean, a version of GHC which runs on x86, but generates ARM assembly? Another option might be to use a nintendo DS emulator which has been configured to support more RAM and CPU power ?
A true cross-compiler would be nice though, because it will run much faster. GHC does have some support for cross-compilation, but in the current implementation, it is mostly (entirely?) there for bootstrapping. I have no idea how the ghc backend rewrite for 6.10 will affect this.
Hope this helps, j. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Don Stewart wrote:
Could we start documenting this on the wiki ?
It will be interesting to keep track of what we have tried, what attempts failed and why.
-- Don
I've added some new sections to the top of the wiki page, above the original attempts. It's now quite long, since it contains details of the problems I encountered trying to build an unregisterised 6.9.20080614 as a first experiment. It ultimately failed because hc-file bootstrapping to a new platform has been broken since 6.8. Only platforms with an existing GHC prior to 6.8 have 6.8 or later now, because of this. A bug[1] has been up since mid-2007 detailing the problem. There's a self-proclaimed "quick hack" diff[2], posted with the following comment:
The diff I uploaded contains some comments inline. It's for ghc-6.8.2 but also applies to the latest stable snapshot (ghc-6.8.2.20080401).
As written earlier, it's possible to create a HC file bundle (with some additional created files) and to build a stage1 compiler with this. I'm a little bit uncertain how to proceed -- either go ahead using libcompat (which is a little bit ugly), or try to rebuild all the libraries immediately with that stage1 compiler (but without using utils/ghc-pkg, since it's not yet buildable), then build the remaining tools.
The bug is milestoned for 6.10.1, and the owner, Ian Lynagh (Igloo), said on #haskell that 6.10.1 merely meant "soon". So, assuming some GHC dev doesn't swoop down and fix this, what options are left to the project in the short term? An unregisterised build of an old 6.6 should work, that would get us a working, though aging, GHC. Unfortunately a lot of the porting work to move from that first unregisterised build to a registerised one (even without native code-gen) wouldn't be transferable to a later 6.9 or 6.10, since 6.9 has moved from using the Evil Mangler to libffi. As to running GHC on a real ARM device, several steps beyond the first unregisterised build would have to be taken, regardless of GHC version: 1. Registerise it. Pre-6.9, this means porting parts of the Evil Mangler, for which there is a guide. Post-6.9, this is much easier. 2. Native code-gen. Registerised or not, a GHC without native code generation relies on a working gcc. That means a GHC for ARM without NCG would only allow compilation of apps in the development environment, though the binaries should work on the device. 3. Finally, even GHC with native code-gen seems to rely on ld and maybe a few other binutils, but this is much, much lighter than installing all of gcc. So, moving forward I intend to run an unregisterised 6.6 build, just to prove that it can be done. Where we go from there is up in the air. I'd be inclined at that point to wait for 6.10 if #1346 really gets fixed. Fully porting an old version seems like extra work that will hopefully be obsoleted. Comments here or on the wiki page are most welcome, I'll be documenting the quirks and changes for the second attempt with 6.6 there too. And if someone in the GHC know wants to work #1346, they would be my hero. Braden Shepherdson shepheb [1] http://hackage.haskell.org/trac/ghc/ticket/1346 [2] http://hackage.haskell.org/trac/ghc/attachment/ticket/1346/ghc.diff

Braden Shepherdson wrote:
So, assuming some GHC dev doesn't swoop down and fix this, what options are left to the project in the short term?
An unregisterised build of an old 6.6 should work, that would get us a working, though aging, GHC. Unfortunately a lot of the porting work to move from that first unregisterised build to a registerised one (even without native code-gen) wouldn't be transferable to a later 6.9 or 6.10, since 6.9 has moved from using the Evil Mangler to libffi.
Sorry for the delay in replying. I'm not sure if you're aware, but when you have an unregisterised 6.6 working, you can use that to build an unregisterised 6.8 and later versions. Building the unregisterised 6.6 would just be a stepping stone to the latest version, and only needs to be done once. This may be moot if we get bootstrapping working again, but until then I'd guess going via 6.6 is the easiest route. For the registerised port, you really need a native code generator (the mangler is on death row, yay). At a rough guess, I'd say porting the NCG would take a couple of weeks or so for someone unfamiliar with the code. Hopefully we'll improve that when we refactor the NCG as part of the backend overhaul. Cheers, Simon

Simon Marlow wrote:
For the registerised port, you really need a native code generator (the mangler is on death row, yay). At a rough guess, I'd say porting the NCG would take a couple of weeks or so for someone unfamiliar with the code. Hopefully we'll improve that when we refactor the NCG as part of the backend overhaul.
Is there any documentation on the NCG? I ported 6.6 to HPUX 11 some time ago and looked at the NCG but didn't do it for PA-RISC because it was going to take too much time to understand. I was leaning towards the approach of trying to translate the code generator for another processor into PA-RISC. -- Joe Buehler

Joe Buehler wrote:
Simon Marlow wrote:
For the registerised port, you really need a native code generator (the mangler is on death row, yay). At a rough guess, I'd say porting the NCG would take a couple of weeks or so for someone unfamiliar with the code. Hopefully we'll improve that when we refactor the NCG as part of the backend overhaul.
Is there any documentation on the NCG? I ported 6.6 to HPUX 11 some time ago and looked at the NCG but didn't do it for PA-RISC because it was going to take too much time to understand. I was leaning towards the approach of trying to translate the code generator for another processor into PA-RISC.
There's some old documentation, some of it is still relevant but probably much of it is out of date now: http://darcs.haskell.org/ghc/docs/comm/the-beast/ncg.html the best doc is the code, I'm afraid (but it has lot of illuminating comments and you can get a long way with cut-and-paste). Cheers, Simon

has there been any movement on this topic? i'm also interested in haskell on
arm
do you guys thing telling ghc to emit C and then compiling that for arm is a
better route than
getting direct compilation to work?
-dan
On Fri, Jul 25, 2008 at 3:55 AM, Simon Marlow
Joe Buehler wrote:
Simon Marlow wrote:
For the registerised port, you really need a native code generator (the
mangler is on death row, yay). At a rough guess, I'd say porting the NCG would take a couple of weeks or so for someone unfamiliar with the code. Hopefully we'll improve that when we refactor the NCG as part of the backend overhaul.
Is there any documentation on the NCG? I ported 6.6 to HPUX 11 some time ago and looked at the NCG but didn't do it for PA-RISC because it was going to take too much time to understand. I was leaning towards the approach of trying to translate the code generator for another processor into PA-RISC.
There's some old documentation, some of it is still relevant but probably much of it is out of date now:
http://darcs.haskell.org/ghc/docs/comm/the-beast/ncg.html
the best doc is the code, I'm afraid (but it has lot of illuminating comments and you can get a long way with cut-and-paste).
Cheers, Simon
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Dan Mead wrote:
has there been any movement on this topic? i'm also interested in haskell on arm
do you guys thing telling ghc to emit C and then compiling that for arm is a better route than getting direct compilation to work?
If you look on the GHC-on-ARM page[1], you'll find my attempts to bootstrap GHC 6.6 (the last version where cross-compiling GHC actually worked) to ARM. The only success I had was in using jhc (not GHC) to generate portable C, which cross-compiled and ran fine (on my Nokia N810). GHC's C wouldn't compile out of the box, and I'm not sure what libraries or other hackery is required to make it do so. Details of the failed cross-compilation and success with jhc are on the wiki page[1]. I'd love to have this working, but I have no time at all this term. Braden Shepherdson shepheb [1] http://hackage.haskell.org/trac/ghc/wiki/ArmLinuxGhc
-dan
On Fri, Jul 25, 2008 at 3:55 AM, Simon Marlow
mailto:marlowsd@gmail.com> wrote: Joe Buehler wrote:
Simon Marlow wrote:
For the registerised port, you really need a native code generator (the mangler is on death row, yay). At a rough guess, I'd say porting the NCG would take a couple of weeks or so for someone unfamiliar with the code. Hopefully we'll improve that when we refactor the NCG as part of the backend overhaul.
Is there any documentation on the NCG? I ported 6.6 to HPUX 11 some time ago and looked at the NCG but didn't do it for PA-RISC because it was going to take too much time to understand. I was leaning towards the approach of trying to translate the code generator for another processor into PA-RISC.
There's some old documentation, some of it is still relevant but probably much of it is out of date now:
http://darcs.haskell.org/ghc/docs/comm/the-beast/ncg.html
the best doc is the code, I'm afraid (but it has lot of illuminating comments and you can get a long way with cut-and-paste).
Cheers, Simon
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org mailto:Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
------------------------------------------------------------------------
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Wednesday 28 January 2009 08:15:44 am Braden Shepherdson wrote:
Dan Mead wrote:
has there been any movement on this topic? i'm also interested in haskell on arm
do you guys thing telling ghc to emit C and then compiling that for arm is a better route than getting direct compilation to work?
If you look on the GHC-on-ARM page[1], you'll find my attempts to bootstrap GHC 6.6 (the last version where cross-compiling GHC actually worked) to ARM.
The only success I had was in using jhc (not GHC) to generate portable C, which cross-compiled and ran fine (on my Nokia N810). GHC's C wouldn't compile out of the box, and I'm not sure what libraries or other hackery is required to make it do so.
Details of the failed cross-compilation and success with jhc are on the wiki page[1].
I'd love to have this working, but I have no time at all this term.
Braden Shepherdson shepheb
Have you considered trying to bootstrap ghc with jhc?
Regards,
--
Conrad Meyer

Conrad Meyer wrote:
On Wednesday 28 January 2009 08:15:44 am Braden Shepherdson wrote:
Dan Mead wrote:
has there been any movement on this topic? i'm also interested in haskell on arm
do you guys thing telling ghc to emit C and then compiling that for arm is a better route than getting direct compilation to work? If you look on the GHC-on-ARM page[1], you'll find my attempts to bootstrap GHC 6.6 (the last version where cross-compiling GHC actually worked) to ARM.
The only success I had was in using jhc (not GHC) to generate portable C, which cross-compiled and ran fine (on my Nokia N810). GHC's C wouldn't compile out of the box, and I'm not sure what libraries or other hackery is required to make it do so.
Details of the failed cross-compilation and success with jhc are on the wiki page[1].
I'd love to have this working, but I have no time at all this term.
Braden Shepherdson shepheb
Have you considered trying to bootstrap ghc with jhc?
Regards,
Unfortunately this is not possible. The Haskell code in GHC relies on some GHC-only extensions. jhc can't compile GHC because it doesn't have those extensions. jhc can't even compile itself, since it too relies on those extensions. Braden Shepherdson shepheb

ghc llvm port would enable arm support as well. i know there were
some issues with llvm when this was discusses a couple of years ago.
has anyone checked if that's the case?
On Wed, Jan 28, 2009 at 3:14 PM, Braden Shepherdson
Conrad Meyer wrote:
On Wednesday 28 January 2009 08:15:44 am Braden Shepherdson wrote:
Dan Mead wrote:
has there been any movement on this topic? i'm also interested in haskell on arm
do you guys thing telling ghc to emit C and then compiling that for arm is a better route than getting direct compilation to work?
If you look on the GHC-on-ARM page[1], you'll find my attempts to bootstrap GHC 6.6 (the last version where cross-compiling GHC actually worked) to ARM.
The only success I had was in using jhc (not GHC) to generate portable C, which cross-compiled and ran fine (on my Nokia N810). GHC's C wouldn't compile out of the box, and I'm not sure what libraries or other hackery is required to make it do so.
Details of the failed cross-compilation and success with jhc are on the wiki page[1].
I'd love to have this working, but I have no time at all this term.
Braden Shepherdson shepheb
Have you considered trying to bootstrap ghc with jhc?
Regards,
Unfortunately this is not possible. The Haskell code in GHC relies on some GHC-only extensions. jhc can't compile GHC because it doesn't have those extensions. jhc can't even compile itself, since it too relies on those extensions.
Braden Shepherdson shepheb
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

does the haskell on llvm compiler support the ghc extentions?
On Wed, Jan 28, 2009 at 7:27 PM, Anatoly Yakovenko
ghc llvm port would enable arm support as well. i know there were some issues with llvm when this was discusses a couple of years ago. has anyone checked if that's the case?
On Wed, Jan 28, 2009 at 3:14 PM, Braden Shepherdson
wrote: Conrad Meyer wrote:
On Wednesday 28 January 2009 08:15:44 am Braden Shepherdson wrote:
Dan Mead wrote:
has there been any movement on this topic? i'm also interested in haskell on arm
do you guys thing telling ghc to emit C and then compiling that for
arm
is a better route than getting direct compilation to work?
If you look on the GHC-on-ARM page[1], you'll find my attempts to bootstrap GHC 6.6 (the last version where cross-compiling GHC actually worked) to ARM.
The only success I had was in using jhc (not GHC) to generate portable C, which cross-compiled and ran fine (on my Nokia N810). GHC's C wouldn't compile out of the box, and I'm not sure what libraries or other hackery is required to make it do so.
Details of the failed cross-compilation and success with jhc are on the wiki page[1].
I'd love to have this working, but I have no time at all this term.
Braden Shepherdson shepheb
Have you considered trying to bootstrap ghc with jhc?
Regards,
Unfortunately this is not possible. The Haskell code in GHC relies on some GHC-only extensions. jhc can't compile GHC because it doesn't have those extensions. jhc can't even compile itself, since it too relies on those extensions.
Braden Shepherdson shepheb
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

i don't think haskell on llvm exists, so the answer would be no
On Thu, Jan 29, 2009 at 8:36 AM, Dan Mead
does the haskell on llvm compiler support the ghc extentions?
On Wed, Jan 28, 2009 at 7:27 PM, Anatoly Yakovenko
wrote: ghc llvm port would enable arm support as well. i know there were some issues with llvm when this was discusses a couple of years ago. has anyone checked if that's the case?
On Wed, Jan 28, 2009 at 3:14 PM, Braden Shepherdson
wrote: Conrad Meyer wrote:
On Wednesday 28 January 2009 08:15:44 am Braden Shepherdson wrote:
Dan Mead wrote:
has there been any movement on this topic? i'm also interested in haskell on arm
do you guys thing telling ghc to emit C and then compiling that for arm is a better route than getting direct compilation to work?
If you look on the GHC-on-ARM page[1], you'll find my attempts to bootstrap GHC 6.6 (the last version where cross-compiling GHC actually worked) to ARM.
The only success I had was in using jhc (not GHC) to generate portable C, which cross-compiled and ran fine (on my Nokia N810). GHC's C wouldn't compile out of the box, and I'm not sure what libraries or other hackery is required to make it do so.
Details of the failed cross-compilation and success with jhc are on the wiki page[1].
I'd love to have this working, but I have no time at all this term.
Braden Shepherdson shepheb
Have you considered trying to bootstrap ghc with jhc?
Regards,
Unfortunately this is not possible. The Haskell code in GHC relies on some GHC-only extensions. jhc can't compile GHC because it doesn't have those extensions. jhc can't even compile itself, since it too relies on those extensions.
Braden Shepherdson shepheb
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Hello Jeremy, Jeremy Apthorp wrote:
Next year I'll be working on a project for my undergraduate computing course at UNSW that will involve getting GHC to target the Nintendo DS. It'll require cross-compilation, because the DS isn't powerful enough to actually run GHC (4M main ram and a 66MHz processor). It'll also require that I significantly strip down the runtime system, as the current RTS won't fit in 4M and leave any left over for the main application.
Maybe one of these would help (running Linux) .. http://www.iyonix.com/ It'd be good too have a native code generator support for ARM (not via C). Many years ago I tinkered with implementing a lazy FPL on ARM (on my Acorn Risc PC). I never even started the compiler but got a basic single threaded RTS and mark-sweep-compact garbage collector up and running (written in ARM assembler). It wasn't really useable for real programs though as I had to write my function definitions as comments and actually implement the graph reduction code by hand in assembler :-) But I remember the ARM instruction set had some really useful features that made things like checking for stack-heap collision cheap and if you got the register allocation right (which is not hard on the ARM) you could construct the overwhelming majority of heap records using a single STMIA instruction. Almost seemed like it's instruction set was designed for efficient FPL implementation :-) Regards -- Adrian Hey
participants (11)
-
Adrian Hey
-
Anatoly Yakovenko
-
Braden Shepherdson
-
Conrad Meyer
-
Dan Mead
-
Don Stewart
-
Jeremy Apthorp
-
Jeremy Shaw
-
Joe Buehler
-
L.Guo
-
Simon Marlow