Git Product home page Git Product logo

ghcjs-build'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

ghcjs-build's People

Contributors

hamishmack avatar j-mueller avatar luite avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

a1kmm

ghcjs-build's Issues

GHC.TypeLits not installed properly?

Hi,

I'm trying to install linear-1.4 on the vm and I ran into a compile error that I mentioned on their issue tracker ekmett/linear#28

I think I've tracked it down to that both ghc and ghcjs don't have properly working installations of GHC.TypeLits, or it's at least not knowing it's there when it is trying to build linear.

Is this a known/common issue; are there any ways i might be able to resolve this?

use constraints for cabal-src installed packages

if a package gets updated on hackage, it might break our build. We should probably install ghcjs with: cabal install -f-compiler-only --constraint=packagename=version ... with constraints for all cabal-src installed packages.

Prebuilt bindirs not at expected location(s)

When using the prebuilt branch, the binaries are not at the expected/configured paths.

Steps to reproduce (installation as per http://weblog.luite.com/wordpress/?p=14):

% git checkout prebuilt
Branch prebuilt set up to track remote branch prebuilt from origin by rebasing.
Switched to a new branch 'prebuilt'
% vagrant up
There were warnings and/or errors while loading your Vagrantfile.
Your Vagrantfile was written for an earlier version of Vagrant,
<snip>
notice: /Stage[main]//Exec[apt-update]/returns: executed successfully
notice: Finished catalog run in 6.87 seconds
% vagrant ssh
There were warnings and/or errors while loading your Vagrantfile.
Your Vagrantfile was written for an earlier version of Vagrant,
<snip>
Welcome to your Vagrant-built virtual machine.
Last login: Fri Sep 14 06:22:31 2012 from 10.0.2.2
$ which ghcjs
$ echo $PATH
/home/vagrant/ghcjs/bin:/home/vagrant/.cabal/bin:/home/vagrant/ghc/bin:/home/vagrant/jsshell:/home/vagrant/node-v0.10.10-linux-x86/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/vagrant_ruby/bin
$ ls /home/vagrant/ghcjs/bin
ls: cannot access /home/vagrant/ghcjs/bin: No such file or directory
$ ls /home/vagrant/ghcjs
dist  examples  ghcjs.cabal  include  LICENSE  patch  README.markdown  rts  Setup.hs  sources.txt  src  src-bin  test
$ file /home/vagrant/ghcjs/dist/build/ghcjs/ghcjs
/home/vagrant/ghcjs/dist/build/ghcjs/ghcjs: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x3dad54a0f66f0a750dbbba28b017c7a8b799fc60, not stripped
$ ls /home/vagrant/.cabal/bin
ls: cannot access /home/vagrant/.cabal/bin: No such file or directory
$ cat /home/vagrant/.cabal/config 
-- This is the configuration file for the 'cabal' command line tool.
<snip>
install-dirs user
  -- prefix: /home/vagrant/.cabal
  -- bindir: $prefix/bin
<snip>
install-dirs global
  -- prefix: /usr/local
  -- bindir: $prefix/bin
<snip>
  -- htmldir: $docdir/html
  -- haddockdir: $htmldir
$ ls -Al /usr/local/bin/
total 0

Vagrant configuration file for building from scratch didn't work out of the box.

Ubuntu 12.04, Vagrant 1.0.1. The prebuilt branch worked fine out of the box, but I had to do some minor surgery on the master branch to get it to work (mostly just comparing the two and trying to minimise non-essential differences).

Diff of the necessary changes:

diff --git a/Vagrantfile b/Vagrantfile
index 562e633..38a2e4e 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -1,7 +1,7 @@
 # -*- mode: ruby -*-
 # vi: set ft=ruby :

-Vagrant.configure("2") do |config|
+Vagrant::Config.run do |config|
   # All Vagrant configuration is done here. The most common configuration
   # options are documented and commented below. For a complete reference,
   # please see the online documentation at vagrantup.com.
@@ -9,9 +9,7 @@ Vagrant.configure("2") do |config|
   # Every Vagrant virtual environment requires a box to build off of.
   config.vm.box = "precise32"

-  config.vm.provider "virtualbox" do |v|
-    v.customize ["modifyvm", :id, "--cpus", 4, "--memory", 3700, "--ioapic", "on"]
-  end
+  config.vm.customize ["modifyvm", :id, "--cpus", 4, "--memory", 3700, "--ioapic", "on"]

   # The url from where the 'config.vm.box' box will be fetched if it
   # doesn't already exist on the user's system.
@@ -51,7 +49,7 @@ Vagrant.configure("2") do |config|
     puppet.options = "--verbose"
   end

-  config.vm.network :forwarded_port, guest: 3000, host: 3030
+  config.vm.forward_port 3000, 3030


 end

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.