Haskell on Risc OS
James Hobson (3319) 13 posts |
Hello! Thought I’d mention that I have just finished building the JHC as a cross compiler to risc os! If you want to have a play, you can find a docker image here |
Paolo Fabio Zaino (28) 1882 posts |
Nice work James, I’d have suggested to put this in Announcements. You can build GCC 10 from the regular GCCSDK, so which version do you need? |
James Hobson (3319) 13 posts |
Well I need a newer cross compiler. You need ghc to build ghc, so I need to begin by cross compiling. I may try with some older ghc versions that will work with the old version of the cross compiler, but arm support and general cross-compiling support is much better in the newer ghc releases. Is there a way to move this post to Announcements, or shall I make a new post? |
Paolo Fabio Zaino (28) 1882 posts |
I don’t think ther eis a way to move a post here, others may know more. |
Julie Stamp (8365) 474 posts |
I’ve managed to make a module using jhc. I can’t make it runnable though, and RMKill goes wrong. I can call (say through a *-command) functions like
however jhc won’t let me export a function
which is bad as I was hoping to hold some Haskell data like a [Int] as the module’s global variable. Maybe they never actually finished putting in support for StablePtr in jhc? |
Julie Stamp (8365) 474 posts |
I’ll say way we can’t make a module runnable yet. When you compile your module, jhc provides it with a garbage collector (gc). The gc claims one-megabyte-sized blocks (‘megablocks’) from the system, which need to be aligned to a page-boundary. That is, a megablock should start at an address &xxxxx000. The SharedCLibrary does indeed have a function, aligned_alloc, to claim such a block. However, the stubs that gccsdk 4.7.4 provides for the SharedCLibrary don’t include an entry for aligned_alloc. But why are we able to write *-commands in Haskell? Because these run in supervisor mode, and ‘claim from the system’ in this case means claim from the RMA using OS_Module. So we can supply the gc with a definition
which will work with the other functions (malloc etc.) in this mode. But why are we able to write applications (not in a module) at all? Because a normal application can be linked with UnixLib which supplies its own C heap with a similar function, ‘memalign’, available to use. One solution then is to arrange for the release of an updated libunixlib.a that has the required stub in it. I’m hoping someone else who knows how to compile libunixlib.a can do this! |
Luke Evans (1706) 8 posts |
Haskell is my jam… so just have to give a big thumbs-up to James’ efforts here. I’d love to play Haskell on RiscOS once it’s fully working. |
James Hobson (3319) 13 posts |
Hello! Been a while. I have another update. As for stubbing, not that hard. The code is in the cross compiler directory (gcc4/riscos I think). BUT! The update is in the form of a new announcement Progress my friends. Progress |
James Hobson (3319) 13 posts |
I’ve posed it in the wrong place again… One day I’ll learn how to use a web browser |