Installing Juvix¶
Prerequisites¶
You need Clang / LLVM version
13 or later. Note that on macOS the preinstalled clang does not support
the wasm
target, so use e.g. brew install llvm
instead.
For the wasm
and risc0-rust
targets additional optional
dependencies are needed. See
below for
instructions on how to install them.
Shell script¶
We provide a shell script that installs the Juvix compiler binary for Linux and macOS using the GitHub release page.
Copy and paste the following command into your terminal to install Juvix.
curl --proto '=https' --tlsv1.2 -sSfL https://get.juvix.org | sh
In VSCode, install Juvix automatically with the Juvix VSCode extension.
MacOS¶
The easiest way to install Juvix on MacOS is by using Homebrew.
To install the homebrew-juvix tap, run:
brew tap anoma/juvix
To install Juvix, run:
brew install juvix
Helpful information can also be obtained by running:
brew info juvix
Linux x86_64¶
A Juvix compiler binary executable for Linux x86_64 is available on the Juvix release page.
To install this executable, download and unzip the linked file and move
it to a directory on your shell's PATH
.
For example if ~/.local/bin
is on your shell's PATH
, you can install
Juvix as follows:
cd /tmp
curl https://api.github.com/repos/anoma/juvix/releases/latest \
| grep "browser_download_url.*linux" \
| cut -d : -f2,3 | tr -d \" \
| xargs curl -L -o linux_release.zip
unzip linux_release.zip
mv juvix ~/.local/bin/juvix
Building Juvix from source¶
To install Juvix from source you must clone the GitHub repository. Then Juvix can be installed with the following commands. We assume you have Stack and GNU Make installed.
git clone --recursive https://github.com/anoma/juvix.git
cd juvix
make install
The C compiler and linker paths can be specified as options to the
make install
command, e.g.
make install CC=path/to/clang LIBTOOL=path/to/llvm-ar
On macOS, you can alternatively run the following command for Homebrew.
The flag --HEAD
used below is optional – use it to build the latest
version of Juvix in the main
branch on GitHub.
brew install --build-from-source --HEAD juvix --verbose
Building the project with cabal
¶
We recommend using the stack
build tool with this project.
If you prefer the cabal
build tool instead, then you need to generate
the juvix.cabal
file using hpack
before running cabal build
.
You also need to compile the runtime first:
make runtime
cabal build
Installing optional dependencies¶
WebAssembly¶
If you want to compile to WebAssembly, you need to install:
- wasmer
- wasi-sdk
- wasm-ld - the LLVM linker for WASM. On Linux
and newer versions of macOS, you may need to install the
lld
package. On older macOS versions, this is installed as part ofllvm
.
To install wasi-sdk
you need to download libclang_rt
and
wasi-sysroot
precompiled archives from the wasi-sdk release
page and:
-
Extract the
libclang_rt.builtins-wasm32-wasi-*.tar.gz
archive in theclang
installation root (for example/usr/lib/clang/13
on Ubuntu or`brew --prefix llvm`
on macOS).For example on macOS with
homebrew clang
:
cd `brew --prefix llvm`
curl https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-15/libclang_rt.builtins-wasm32-wasi-15.0.tar.gz -OL
tar xf libclang_rt.builtins-wasm32-wasi-15.0.tar.gz
-
Extract the
wasi-sysroot-*.tar.gz
archive on your local system and setWASI_SYSROOT_PATH
to its path.For example:
cd ~
curl https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-15/wasi-sysroot-15.0.tar.gz -OL
tar xf wasi-sysroot-15.0.tar.gz
export WASI_SYSROOT_PATH=~/wasi-sysroot
RISC Zero¶
If you want to compile to RISC Zero via Rust,
using the risc0-rust
target, you need to have
Rust and cargo installed. To compile the
Rust code generated by Juvix for RISC Zero, and then generate and verify the
proof, you need to install the RISC Zero Rust
toolchain.
Checking your setup
Run juvix doctor
in your terminal to validate your setup.