Skip to content
Snippets Groups Projects

Add README

Merged Cheng Shao requested to merge wip/readme into master
1 file
+ 51
0
Compare changes
  • Side-by-side
  • Inline
README.md 0 → 100644
+ 51
0
# `ghc-wasm-meta`
This repo provides convenient methods of using x86_64-linux binary
artifacts of GHC's wasm backend.
## Getting started as a nix flake
This repo is a nix flake. The default output is a derivation that
bundles all provided tools:
```sh
$ nix shell https://gitlab.haskell.org/ghc/ghc-wasm-meta/-/archive/master/ghc-wasm-meta-master.tar.gz
$ echo 'main = putStrLn "hello world"' > hello.hs
$ wasm32-wasi-ghc hello.hs -o hello.wasm
[1 of 2] Compiling Main ( hello.hs, hello.o )
[2 of 2] Linking hello.wasm
$ wasm-run ./hello.wasm
hello world
```
First start will download a bunch of stuff, but won't take too long
since it just patches the binaries and performs little real
compilation. There is no need to set up a binary cache.
## Getting started without nix
For Ubuntu 20.04 and similar glibc-based distros, this repo provides a
`setup.sh` script that installs the provided tools to `~/.ghc-wasm`:
```sh
$ ./setup.sh
...
Everything set up in /home/username/.ghc-wasm.
Run 'source /home/username/.ghc-wasm/env' to add tools to your PATH.
```
After installing, `~/.ghc-wasm` will contain:
- `env` which can be sourced into the current shell to add the tools
to `PATH`
- `add_to_github_path.sh` which can be run in GitHub actions, so
later steps in the same job can access the tools from `PATH`
`setup.sh` can be configured via these environment variables:
- `PREFIX`: installation destination, defaults to `~/.ghc-wasm`
- `BIGNUM_BACKEND`: which `ghc-bignum` backend to use, can be either
`gmp` or `native`, defaults to `gmp`
- `SKIP_GHC`: set this to skip installing `cabal` and `ghc`
`setup.sh` requires `cc`, `curl`, `jq`, `unzip` to run.
Loading