ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.4.3
1 參考 GitHub - ghcjs/ghcjs at ghc-8.4
1.1 getting and preparing the source tree
add step
git checkout ghc-8.4
git clone https://github.com/ghcjs/ghcjs.git
cd ghcjs
git checkout ghc-8.4
git submodule update --init --recursive
./utils/makePackages.sh
1.2 building the compiler
You can use
cabal-install
and stack
to set up a build environment that contains these packages.1.2.1 Cabal new-build
stack install cabal-install
cabal update
cabal new-configure
cabal new-build
1.2.2 link to executables
DON'T DO THIS, IT IS NOT NECESSARY
Since cabal new-build does not install executables or wrapper scripts, we need to make them accessible by hand. You can do this by creating symlinks to the /utils/dist-newstyle-wrapper.sh script.
For example if the
.bin
directory is in your PATH
:cd .bin
ln -s ../utils/dist-newstyle-wrapper.sh ghcjs
ln -s ../utils/dist-newstyle-wrapper.sh ghcjs-pkg
ln -s ../utils/dist-newstyle-wrapper.sh haddock-ghcjs
ln -s ../utils/dist-newstyle-wrapper.sh hsc2hs-ghcjs
ln -s ../utils/dist-newstyle-wrapper.sh ghcjs-boot
ln -s ../utils/dist-newstyle-wrapper.sh ghcjs-run
1.2.4 install haddock
error message: Haddock's resource directory does not exist!
this step is useless for above error message.
cabal install haddock
stack haddock
1.3 Booting GHCJS
ghcjs-boot
when invoked without arguments, ghcjs-boot will build the libraries from
boot.tar
(unless the current directory contains a boot.yaml
file), installed in GHCJS' data directory (boot.tar
is generated by the makePackages.sh
script and included in a source distribution).1.4 Test
$ echo 'main = putStrLn "Hello World!"' > helloWorld.hs
$ stack exec -- ghcjs -o helloWorld helloWorld.hs
$ node helloWorld.jsexe/all.js
Hello world!
test is OK.
I don't know why. But these steps are work for me to install ghcjs with ghc-8.4.3
2 參考 Peachful Space - ghcjs on Arch Linux 和以下指令:(FAIL)
this is not work.
# install stack, haskell-stack, node.js and alex using pacman
$ sudo pacman -S stack haskell-stack nodejs alex
$ cd && git clone https://github.com/ghcjs/ghcjs.git
# if you `stack setup` now you'll get an error saying /usr/lib/libtinfo.so.5 cannot be found
# install libtinfo from AUR
$ cd ~/build-aur
$ git clone https://aur.archlinux.org/libtinfo.git
$ cd libtinfo
$ makepkg -sri
# introducing the terrible hack... I know, but it's the only way I can make it work
$ sudo ln -s /usr/lib/libtinfo.so /usr/lib/libtinfo.so.5
$ cd ~/ghcjs
$ stack setup
$ stack build
$ stack exec -- ghcjs-boot --dev
$ echo 'main = putStrLn "Hello World!"' > helloWorld.hs
$ stack exec -- ghcjs -o helloWorld helloWorld.hs
$ node helloWorld.jsexe/all.js
Hello world!