Skip to content

Compiling Stalwart

Compiling Stalwart from the source has the main advantage that binaries are built with optimizations specific to your hardware which may result in better performance. Another advantage is that you may enable or disable features to suit your needs, thus reducing the size of the binary and the memory footprint.

To compile Stalwart you need the latest version of Rust. The fastest way to install rust is with rustup. On Unix systems run the following in your terminal, then follow the onscreen instructions

Terminal window
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

If you are running Windows 64-bit, download and run rustup‑init.exe, then follow the onscreen instructions.

Clone the Stalwart repository:

Terminal window
$ git clone https://github.com/stalwartlabs/stalwart.git
$ cd stalwart

Find and then check out the latest tagged release, for example:

Terminal window
$ git tag --sort=-version:refname | head -1
v0.16.0
$ git checkout tags/v0.16.0

If you are compiling the Foundation DB backend, download and install the Foundation DB client library.

For example, to compile Stalwart with the RocksDB, ElasticSearch support and Enterprise features:

Terminal window
$ cargo build --release -p stalwart --no-default-features --features "rocks elastic redis enterprise"

Or, to compile the FoundationDB backend:

Terminal window
$ cargo build --release -p stalwart --no-default-features --features "foundationdb enterprise"

Once the compilation process is completed, the Stalwart binary will be available under target/release/stalwart.

You can enable the following features when compiling Stalwart by using the --features flag:

  • rocks: RocksDB backend
  • sqlite: SQLite backend
  • foundationdb: FoundationDB backend
  • postgres: PostgreSQL backend
  • mysql: MySQL backend
  • s3: S3 backend
  • azure: Azure backend
  • elastic: ElasticSearch backend
  • redis: Redis backend
  • nats: NATS backend
  • zenoh: Eclipse Zenoh backend
  • kafka: Kafka backend
  • enterprise: Enterprise features