Luite Stegeman | 25 Jan 13:37 2013
Picon

GHCJS, JavaScript, cross-platform typechecking with the GHC API and primops

hi all,

I've been working on GHCJS [1] for a while and am trying to get it to
work on 64 bit GHC.

A quick background: GHCJS uses the GHC API to generate STG, which it
then translates to JavaScript. It uses slightly patched versions of
the integer-gmp, base and ghc-prim libraries and supports many GHC
features, including arrays and threading.

All JavaScript numbers are essentially double precision floating
point. With some tricks (using bitwise operators) it's possible to get
reasonable 32 bit integer emulation out of it, but emulating 64 bit
integers would be very slow. Therefore, if we compile Haskell to
JavaScript, it should really be treated as a 32 bit target.

Now this is a problem, with GHC 7.6 and lower, generated STG depended
on the word size of the host, so it was simply impossible to do this
with a 64 bit host. In HEAD, wORD_SIZE_IN_BITS is now in DynFlags, so
I decided to have another go. I'm aiming for the following procedure
to install GHCJS and build a package:

# cabal install ghcjs  -- installs `ghcjs`, `ghcjs-boot`, `ghcjs-pkg`,
`ghcjs-cabal`
# ghcjs-boot             -- build ghc-prim, integer-gmp, base for
GHCJS and register them in its package db
# ghcjs-cabal install myPackage -- cabal wrapper that uses ghcjs instead of ghc

GHCJS instructs the GHC API to build 32 bit code [2] and sets
preprocessor definitions so that libraries also expect 32 bit code.
(Continue reading)


Gmane