Skip to content


Set up development environment

You can set up development environment simply using envd. It will create a docker container and install all the dependencies for you.

pip install envd
git clone
envd up

Or you can setup development environment following these steps manually:

  1. Install base dependency.
sudo apt install -y \
    bison \
    build-essential \
    ccache \
    flex \
    gcc \
    git \
    gnupg \
    libreadline-dev \
    libssl-dev \
    libxml2-dev \
    libxml2-utils \
    libxslt-dev \
    lsb-release \
    pkg-config \
    tzdata \
    xsltproc \
  1. Install clang-16. Other versions of clang are not supported.
sudo sh -c 'echo "deb$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-16 main" >> /etc/apt/sources.list'
wget --quiet -O - | sudo apt-key add -
sudo apt-get update
sudo apt-get install -y --no-install-recommends clang-16
  1. Install Rust. Do not install rustc using a package manager.
curl --proto '=https' --tlsv1.2 -sSf | sh
  1. Clone the Repository.
git clone
  1. Install cargo-pgrx.
cargo install cargo-pgrx --version $(grep -o 'pgrx = { version = "=[^"]*' Cargo.toml | cut -d = -f 4)
cargo pgrx init

cargo-pgrx is a helpful tool to develop a PostgreSQL extension. You can read the document in

Cross compilation

Assuming that you build binary and schema for aarch64 target in x86_64 host environment, you can follow these steps:

  1. Install cross compilation toolchain.
sudo apt install crossbuild-essential-arm64
sudo apt install qemu-user-static

Set environment variables.


Set emulator, linker and sysroot for Rust by adding the following section to the end of ~/.cargo/config.toml.

runner = ["qemu-aarch64-static", "-L", "/usr/aarch64-linux-gnu"]
linker = "aarch64-linux-gnu-gcc"

BINDGEN_EXTRA_CLANG_ARGS_aarch64_unknown_linux_gnu = "-isystem /usr/aarch64-linux-gnu/include/ -ccc-gcc-name aarch64-linux-gnu-gcc"
  1. Generate PostgreSQL header files on target architecture. It can be done with cargo-pgrx and you can also take advantages of files under vendor/pgrx_config and vendor/pgrx_binding. For details, please refer to the documentation of pgrx.


Debug information included in the compiled binary even in release mode so you can always use gdb for debugging.

For a debug build, backtrace is printed when a thread in background worker process panics, but not for a session process error. For a release build, backtrace is never printed. But if you set environment variable RUST_BACKTRACE to 1, all backtraces are printed. It's recommended for you to debug a release build with the command RUST_BACKTRACE=1 cargo pgrx run --release.