Skip to content

Commit 49d3ec7

Browse files
authored
Merge pull request #1194 from IntersectMBO/js/without-nix
Add script for preparing the wasm libraries for building without Nix
2 parents 1eaf53e + d30f3be commit 49d3ec7

3 files changed

Lines changed: 389 additions & 1 deletion

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
project: cardano-wasm
2+
pr: 1194
3+
kind:
4+
- maintenance
5+
description: |
6+
Add `scripts/wasm-without-nix/build-wasm-libs.sh` for building the wasm32-wasi
7+
C library dependencies (libsodium, libsecp256k1, libblst) without Nix

cardano-wasm/README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ Enter the Nix shell by writing `nix develop .#wasm` on a shell in this folder an
1313
For the installation we will need some dependencies. In Debian based distros we can install them using apt like this:
1414

1515
```bash
16-
sudo apt install happy pkgconf libtool git wget curl jq unzip zstd tar gzip
16+
sudo apt install happy pkgconf libtool make automake autoconf file git wget curl jq unzip zstd tar gzip
1717
```
1818

19+
(`jq`, `unzip`, `zstd`, `wget` and `curl` are needed by ghc-wasm-meta's installer rather than by the build itself, and `happy` is needed by some Haskell dependencies during the build.)
20+
1921
#### Installing `ghc` for wasm
2022

2123
Then it is necessary to get `ghc` for wasm, and you see how to do that [here](https://gitlab.haskell.org/haskell-wasm/ghc-wasm-meta#getting-started-without-nix). At the moment, it is necessary to install a version of `ghc` that has `base <= 4.20`, so I would recommend installing `wasm32-wasi-9.10` like this:
@@ -40,8 +42,18 @@ And that should not return:
4042
wasm32-wasi-ghc: command not found
4143
```
4244

45+
If the reported version is not 9.10.x, double-check the `FLAVOUR` used above before continuing: with a different `base` version the build will only fail much later, with confusing dependency resolution errors.
46+
4347
Then we need to compile three libraries to WASM: `libblst`, `libsodium`, and `libsecp256k1`.
4448

49+
The script [`scripts/wasm-without-nix/build-wasm-libs.sh`](../scripts/wasm-without-nix/build-wasm-libs.sh) automates all the steps in this section: it builds the same pinned versions of the libraries as the Nix build, installs them into a prefix of your choice, verifies the results are really wasm, and generates a `cabal.project` fragment that points the build at them. From the root of this repository run:
50+
51+
```bash
52+
PREFIX=wasm-libs SRC_ROOT=wasm-libs-src ./scripts/wasm-without-nix/build-wasm-libs.sh
53+
```
54+
55+
and then follow the instructions it prints at the end (in particular, exporting `PKG_CONFIG_PATH`). In that case you can skip straight to the [Compiling `cardano-wasm` section](#compiling-cardano-wasm). The rest of this section explains the equivalent manual steps.
56+
4557
In order to not interfere with the system library installation, we will create a folder to serve as our prefix:
4658

4759
```bash

0 commit comments

Comments
 (0)