
Luite
Via HWN I read your GHCJS posthttp://weblog.luite.com/wordpress/?p=14&date=2013-06-03 this morning. Great work.
It's silly that you should need to patch GHC. One alternative is to absorb your patchhttps://github.com/ghcjs/ghcjs.github.com/blob/master/patches/ghc-ghcjs.patc..., or a successor. I think it mostly just extends the FFI and target types with new cases. The patch doesn't actually include any JS generation, so I'm far from sure how that happens.
But it would be even better to make it easier to people to add new backends without modifying GHC, via some kind of plugin interface.
I'm underwater with POPL right now, but do discuss on ghc-devs any details that would help you.
Simon
From: ghc-devs-bounces@haskell.org [mailto:ghc-devs-bounces@haskell.org] On Behalf Of Luite Stegeman
Sent: 14 June 2013 21:12
To: Carter Schonwald
Cc: ghc-devs@haskell.org
Subject: Re: status of template haskell + cross compiling plans for 7.8?
We've had TH working in GHCJS [1] for a few months now, compiling once for the host platform, and once for the target.
Our GHCJS GHC patch [2] (that we hope to get merged before 7.8) adds, among other things, WayCustom to the Ways in DynFlags, which just adds a custom token to the filename extension. This, uhm, way (sorry), we generate native files ".o" and ".hi", and ArchJavaScript files ".js_o" and ".js_hi" in the same directory. TH always uses the native files.
We had to patch Cabal [3] to install the extra files (but we needed to patch Cabal anyway to add the GHCJS compiler flavour), but other than that it seems to work. GHC loads the native .a files when running TH, we do our own JavaScript linking.
Another thing we patched is the GHC.Prim interface, which is different for 32 and 64 bit code. When we generate code for ArchJavaScript, we load a custom GHC.Prim for 32 bit, while we use the regular GHC.Prim when we generate the native code.
It's all a bit hacky, but maybe this approach can be used as a basis for getting TH working in a real GHC. We could take some shortcuts to make a pseudo-mutltitarget compiler by just tacking an extra code generator onto a non-crosscompiling GHC. I'd be happy to help or discuss to make it more general.
Luite
[1] https://github.com/ghcjs / http://weblog.luite.com/wordpress/?p=14
[2] https://github.com/ghcjs/ghcjs.github.com/blob/master/patches/ghc-ghcjs.patc...
[3] https://github.com/ghcjs/ghcjs.github.com/blob/master/patches/cabal-ghcjs.pa...
On Thu, Jun 13, 2013 at 11:43 PM, Carter Schonwald