CMD: build
The pig build command simplifies the full workflow for building PostgreSQL extensions from source. It provides build infrastructure setup, dependency management, and compilation environments for standard and custom PostgreSQL extensions across supported operating systems.
| Command | Description | Notes |
|---|---|---|
build spec |
Initialize build specification directory | |
build repo |
Initialize required repositories | Requires sudo or root |
build tool |
Initialize build tools | Requires sudo or root |
build rust |
Install Rust toolchain | Requires sudo or root |
build pgrx |
Install and initialize pgrx | Requires sudo or root |
build proxy |
Initialize build proxy | |
build get |
Download source tarballs | |
build dep |
Install extension build dependencies | Requires sudo or root |
build ext |
Build extension packages | Requires sudo or root |
build pkg |
Complete pipeline: get, dep, ext | Requires sudo or root |
Quick Start
The fastest way to set up a build environment and build an extension:
For finer control:
Build Infrastructure
Directory Layout
Build output locations:
- EL systems:
~/ext/pkg/, also accessible through~/rpmbuild/RPMS/ - Debian systems:
~/ext/pkg/, also accessible through~/debbuild/DEBS/
build spec
Set up build specifications and directory layout.
What it does:
- Downloads the RPM or DEB build specification tarball.
- Creates
~/ext/{pkg,src,log,tmp}and the platform build directory. - Links
RPMS/DEBSandSOURCESto~/ext/pkgand~/ext/src. - Syncs makefiles, specs, and Debian packaging files with incremental
rsync.
Working directory: ~/ext/ stores sources, packages, logs, and temporary files. The platform packaging directory is ~/rpmbuild/ or ~/debbuild/.
build repo
Initialize package repositories required for building extensions.
What it does: initializes build repositories with pig repo set -ru: remove old repositories, add required repositories, and refresh package caches.
Options:
-m|--mirror: prefer China mirrors (Tencent Cloud first for PGDG).-b|--beta: include the PostgreSQL beta repository module, currently for PG19 beta builds.
build tool
Install development tools and compilers.
Toolsets:
- Minimal (
mini): GCC/Clang compilers, Make, core build tools, PostgreSQL development headers, and basic libraries. - Default: minimal tools plus extra compilers, development libraries, and packaging tools such as
rpmbuildanddpkg-dev. - Full (
full): default tools plus language-specific development tools and advanced debugging or profiling utilities.
On EL systems, the default build toolset installs explicit PostgreSQL development/server packages for the stable active majors. Use --beta when you also need the current beta major.
build rust
Install the Rust toolchain required by Rust-based extensions.
Installed components: Rust compiler (rustc), Cargo, Rust standard library, and development tools.
Options:
-y|--yes: force Rust reinstallation even if Cargo already exists.-m|--mirror: downloadrustupfrom the China mirror and write~/.cargo/config.tomlforrsproxy.cn.
build pgrx
Install and initialize PGRX, the PostgreSQL extension framework for Rust.
Prerequisites: Rust toolchain and PostgreSQL development headers must be installed first.
Options:
-v|--pgrx: cargo-pgrx version to install.--pg: comma-separated PostgreSQL majors,initfor no PostgreSQL arguments, or empty for auto-detection.-b|--beta: include the current beta major during auto-detection.
build proxy
Configure a proxy for build environments with restricted internet access.
build get
Download extension source tarballs.
Arguments to pig build get are extension names, package names, or source filenames. Unknown names are treated as source filenames. It does not expand all or std into built-in package sets; list the target package names explicitly for batch downloads.
Some source packages do not map directly to extension names, so pig build get includes special aliases for direct source downloads.
Common special source aliases include: babelfish / babelfish-17 / babelfish-18, ivorysql, orioledb / orioledb-16 / orioledb-17 / orioledb-18, cloudberry / cloudberry-backup / cloudberry-pxf, pgedge / pgedge-15 / pgedge-16 / pgedge-17 / pgedge-18, polardb, polarstore, zlog, pdu, pgdog, rdkit, onesparse, libpgfeutils, and libfq.
build dep
Install dependencies required to build extensions.
Options:
--pg: specify one or more PostgreSQL major versions. If omitted, pig infers versions from extension metadata or local PostgreSQL installations.
build ext
Compile extensions and create installation packages.
Options:
--pg: specify one or more PostgreSQL major versions.-s|--symbol: build debug symbol packages (RPM only).
build pkg
Run the complete build pipeline: download, dependency installation, and build.
Options:
--pg: specify one or more PostgreSQL major versions.-s|--symbol: build debug symbol packages (RPM only).-m|--mirror: prefer thepigsty.ccmirror when downloading source files.
pig build pkg cloudberry is a suite workflow: it downloads the full Cloudberry source bundle, builds the core package first, installs the local artifact, then builds cloudberry-backup and cloudberry-pxf.
Common Workflows
Workflow 1: Build a Standard Extension
Workflow 2: Build a Rust Extension
Workflow 3: Build Multiple Versions
Troubleshooting
Build Tools Not Found
Missing Dependencies
PostgreSQL Headers Not Found
Rust/PGRX Issues
Extension Build Matrix
Common Extensions to Build
| Extension | Type | Build Time | Complexity | Special Requirements |
|---|---|---|---|---|
| pg_repack | C | Fast | Simple | None |
| pg_partman | SQL/PLPGSQL | Fast | Simple | None |
| citus | C | Medium | Medium | None |
| timescaledb | C | Slow | Complex | CMake |
| postgis | C | Very slow | Complex | GDAL, GEOS, Proj |
| pg_duckdb | C++ | Medium | Medium | C++17 compiler |
| pgroonga | C | Medium | Medium | Groonga libraries |
| pgvector | C | Fast | Simple | None |
| plpython3 | C | Medium | Medium | Python development |
| pgrx extensions | Rust | Slow | Complex | Rust, PGRX |