Git Product home page Git Product logo

ghc's Introduction

Introduction

GHCJS is a Haskell to JavaScript compiler that uses the GHC API.

Quick Start - Developing GHCJS

GHCJS contains a library, ghcjs, which contains the JavaScript code generator and a slightly customized variant of the ghc library, and several executable programs.

The repository has several submodules and some files must be generated before the package can be installed.

prerequisites

GHC

You need the same major version of GHC as the version of the GHCJS branch you're building.

cabal-install

cabal-install 3.0 is supported

emscripten emsdk

GHCJS uses a C toolchain, mostly for build system related tasks like the C preprocessor, Autoconf scripts and tools like hsc2hs. Direct support for using compiled foreign libraries from Haskell code may follow at a later date.

Please follow the installation instructions at https://emscripten.org/docs/getting_started/index.html

GHCJS requires the "upstream" emscripten backend, which is the default now. The earlier "fastcomp" backend will not work.

getting and preparing the source tree

$ git clone https://github.com/ghcjs/ghcjs.git
$ cd ghcjs
$ git submodule update --init --recursive

building the compiler

GHCJS depends on a few "local" packages in the source tree. You can use cabal-install and stack to set up a build environment that contains these packages.

Cabal new-install

After the source tree has been prepared, the package can be installed. You may want ensure that binaries of earlier versions are overwritten:

cabal v2-install --overwrite-policy=always --install-method=copy --installdir=inplace/bin

At the time of writing, cabal-install does not support creating symbolic links on Windows, even though this is the default installation method. A workaround is telling it to copy the executables instead:

cabal v1-install --prefix=inplace

v1 style Cabal sandbox

v1 style cabal sandboxes are also supported

if you want to build with a Cabal sandbox, use the makeSandbox.sh script to add the local packages.

$ cabal v1-sandbox init
$ cabal v1-install

stack

or you can use stack:

$ stack --system-ghc --skip-ghc-check install --local-bin-dir=inplace/bin

Booting GHCJS

The ghcjs-boot program builds the "boot" libraries, like ghc-prim, base and template-haskell with GHCJS. After booting, GHCJS can compile regular Haskell programs and packages.

ghcjs-boot needs to be able to find the emscripten toolchain, a nodejs executable. The easiest way to do this is by running the emsdk_env.sh script. After that, you can run ghcjs-boot by pointing it to the boot libraries (the directory containing the boot.yaml file)

$ source ~/emsdk/emsdk_env.sh
$ ./inplace/bin/ghcjs-boot -s ./lib/boot

GHCJS executables and library paths

After booting, you can add the directory containing the GHCJS binaries to your executable PATH. The ghcjs-boot program prints the location after finishing building the libraries.

You can also create a symbolic link for the ghcjs and ghcjs-pkg programs, or use the --with-compiler and --with-hc-pkg flags when using cabal-install

Generating a source distribution

if you work on boot packages that need some for an upstream library, make sure to update the patches in /lib/patches first

$ ./utils/updatePatches.sh

then regenerate the packages

$ ./utils/makePackages.sh

ghc's People

Contributors

batterseapower avatar benl23x5 avatar catamorphism avatar clefru avatar dcoutts avatar dmpots avatar donsbot avatar dreixel avatar erikd avatar ezyang avatar ggreif avatar igfoo avatar int-e avatar jgoerzen avatar josefs avatar kgardas avatar lemmih avatar mchakravarty avatar michalt avatar mkilian avatar nominolo avatar pcapriotti avatar pepeiborra avatar samb avatar simonmar avatar thorkilnaur avatar tibbe avatar twanvl avatar waern avatar yav avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ghc's Issues

Test Suite Breakdown

Priorities

Important

  • ReferenceError: raise
  • ReferenceError: mainZCZCMainzimain

Fix

  • warnings (not output by plain GHC)
  • output syntax
  • not implemented
  • pattern match failure

Possibly fixable

  • --backpack
  • missing primitives

Test configuration

  • nodeSettings.json
  • machine size

Unsupported

  • --interactive
  • SyntaxError (c-syntax)
  • ReferenceError caused by compiled c

Breakdown

total errors (989)

  • 989 unexpected failure
  • 15 uncategorised

ReferenceError (580)

  • 408 "uncaught exception in Haskell thread"
    • 400 "h$raise is not defined"
  • 172 "uncaught exception in Haskell main thread"

backpack (121)

  • 121 "unrecognised flag: --backpack"

interactive (110)

  • 110 "--interactive is not yet supported"

SyntaxError (25)

  • 23 unexpected token
    • 6 '.'
    • 17 'void'
  • 2 unexpected identifier #include

output syntax (44)

  • 44 off-by-prefix @@ -1 +1 @@
  • 39 Linking .* jsexe

warnings (4)

arr016 TestRun TH_spliceViewPat T1T13727b

machine size

arith011 numrun009 numrun012

nodeSettings.json: openBinaryFile: does not exist (No such file or directory) (19)

uncaught exception in Haskell main thread: Error: not implemented (17?)

pattern match failure (7)

misc (3)

cgrun064 T12674 unicode002 T139_A lazy-bs-alloc

unknown

barton-mangler-bug

unknown numeric

arith008 tcrun002

`ReferenceError` test suite failure mode

Supported symbol types:

  • raise
  • mainZCZCMainzimain

Unsupported symbol types:

  • compiled c (hello, foo, bar)

Debugging info:

  • This is a JavaScript exception.
  • None of the errored names show up in git grep, so they mustn't be defined for some reason.
  • Just before sine of the errors, there's a warning warning, unhandled primop which comes from the
    default case of Gen2.Prim.genPrim:
    genPrim _ _ op rs as = PrimInline $
    appS "h$log" [e $ "warning, unhandled primop: "++show op++" "++show (length rs, length as)] #
    f #
    copyRes
    where
      f = ApplStat (var (T.pack $ "h$primop_" ++ show op)) as
      copyRes = mconcat $ zipWith (\r reg -> r |= e reg) rs (enumFrom Ret1)
  • Primops are defined in primop-data-decl.hs-incl
  • Missing primops (11 matches): PrefetchAddrOp3 SetThreadAllocationCounter WriteByteArrayOp_Word8AsInt16 BRev8Op ShrinkSmallMutableArrayOp_Char
  • Missing others: h$opendir h$test_lt h$putchar h$memintrinTest h$log1p h$f5149 h$do_popcnt32 h$stg_word32ToFloatzh h$getOrSetLibHSghcGlobalDynFlags h$sqrt h$splitmix_init h$stg_floatToWord32zh h$func h$splitmix_init h$performGC_ h$foo h$mainZCZCMainzimain h$test_prim_op h$fin h$hello h$qsort h$puts h$test h$f h$var h$write h$free_fn_blob h$call8 h$staticfoo h$i h$printf h$n h$many_floats h$head_bytearray h$is_doubleton_homogenous h$add_all_int8 h$add_all_word8 h$add_all_int16 h$add_all_word16 h$getDbl h$getOrSetLibHSghcFastStringTable h$bar h$ghcjsbn_gcdExtSBigNat h$genSym h$finalize_value h$RtsFlags h$traceEventBinary h$deriv h$printx h$rts_unsafeGetMyCapability h$pipe h$initLinker_
    • Some of these are clearly c-naming (putchar, opendir)
    • Others are clearly haskell generated names (mainZCZCMainzimain)
    • Others look like internal haskell stuff (getSym, RtsFlags)
    • Some look like they come from compiled names (hello, foo, bar)

Request to backport fix for GHC issue 18708 here

There was a GHC issue https://gitlab.haskell.org/ghc/ghc/-/issues/18708 which has been resolved: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6554/diffs?commit_id=917195a1943b783e3745a5e486ee2684c42c1664

The patch was backported to the release branch for GHC 8.10.8: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6554?commit_id=917195a1943b783e3745a5e486ee2684c42c1664

Would it be acceptable for me to backport this here? My goal is to apply the same fix to GHCJS 8.10.7.


In haskell.nix this patch has already been applied to GHC 8.10.7: input-output-hk/haskell.nix#1321

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.