# Build from source

> Toolchain, pinned versions and build commands.

---

LLMS index: [llms.txt](/llms.txt)

---

This page describes the `pgetcd` repository layout, the current root-module dependencies, release build commands, and verification suites. The current tree is untagged; the `v0.1.0-rc2` candidate remains documented in [Releases](/docs/etcd/releases/). To start a local development tenant after building, see [Quick start](/docs/etcd/quickstart/).

## Repository layout {#sources}

| Path | Responsibility |
| --- | --- |
| `cmd/pgetcd` | Gateway binary entry point (`--tenant-config`, `--version`, and internal test modes) |
| `internal/gateway`, `internal/watch` | etcd v3 gRPC service handlers, Watch session multiplexing, and bounded event delivery |
| `internal/pgstore`, `internal/pgprobe` | Certified SQL publication pool, transaction boundaries, and PostgreSQL state probes |
| `internal/tenant`, `internal/tenantservice`, `internal/transport` | Tenant JSON validation, readiness lifecycle, and mTLS listeners |
| `extension/pg_etcd.c`, `extension/pg_kvcore` | C/PGXS PostgreSQL extension, revision/Txn engine, `_tail_v2`, and Lease background workers |
| `versions.lock.json`, `go.mod`, `go.sum` | Pinned upstream reference versions and Go module checksums |
| `tests/`, `scripts/` | SQL suites, official client probes, Watch race tests, and historical gate checkers |
{.wide}

## Toolchain and pinned versions {#versions}

The current root tree after the 2026-11-11 dependency refresh requires the following versions:

| Component | Pinned version | Notes |
| --- | --- | --- |
| Go | `1.27.4` | Static gateway compilation (`CGO_ENABLED=0`) |
| PostgreSQL | `18.6` (`REL_18_6`) | Server headers (`postgresql-server-dev-18`) and `pg_config` for PGXS |
| etcd Go API and `clientv3` | `v3.7.3` | Uses standard `google.golang.org/protobuf` bindings |
| gRPC / protobuf | `v1.85.0` / `v1.36.12` | Upstream generated protobuf bindings are consumed directly; `protoc` is not required for builds |
| `pgx` | `v5.12.0` | PostgreSQL wire driver and connection pool |
| Supporting modules | `grpc-gateway v2.33.0`; `x/net v0.62.0`; `x/sync v0.25.0`; `x/sys v0.50.0`; `x/text v0.44.0` | The complete selected module graph is recorded in `go.mod` and `go.sum` |
| Reference servers (test only) | etcd `v3.6.15`, `v3.7.2`; Kubernetes `v1.36.4`, `v1.37.1` | Locked in `versions.lock.json` for differential and storage probes |
{.wide}

The reference-server modules under `tests/` keep these versions because they are compatibility inputs. They are separate from the root gateway module.

## Build commands {#build}

### Gateway (`pgetcd`) {#build-gateway}

Build a development binary for the local host:

```bash
go build -o .cache/docs-dev/pgetcd ./cmd/pgetcd
```

Build a reproducible static Linux binary (used for the `v0.1.0-rc1` and `v0.1.0-rc2` archives on `amd64` and `arm64`):

```bash
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags "-s -w" -o pgetcd ./cmd/pgetcd
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -trimpath -ldflags "-s -w" -o pgetcd ./cmd/pgetcd
```

### PostgreSQL extension (`pg_etcd`) {#build-extension}

Compile and install the C/PGXS extension against your target PostgreSQL 18 installation:

```bash
make -C extension PG_CONFIG=/path/to/postgresql/bin/pg_config
make -C extension PG_CONFIG=/path/to/postgresql/bin/pg_config install
```

This installs `lib/pg_etcd.so`, `share/extension/pg_etcd.control`, and `share/extension/pg_etcd--0.1.0.sql`. To build inside a clean Debian 13 container (`postgres:18.6`), install `build-essential` and `postgresql-server-dev-18` first and run `make -C extension`. Note that binaries compiled on Debian 13 require `glibc` 2.38 or newer; compile directly on the target distribution when targeting EL8/EL9, Debian 12, or Ubuntu 22.04.

## Verification commands {#verification}

On 2026-11-11, the current untagged tree passed `go build ./cmd/...`, `go test ./...`, and `go vet ./...` on macOS arm64 with Go `1.27.4`. The `pgx` refresh also required the legacy batch-error adapter to implement `pgx.BatchResults.Tx()`. This local check does not replace the Linux release checklist for a future candidate.

| Command | Scope |
| --- | --- |
| `go build ./cmd/...` | Compile gateway and helper commands; passed on the current macOS arm64 tree on 2026-11-11 |
| `go vet ./...` | Static analysis across all non-isolated packages; passed on the current macOS arm64 tree on 2026-11-11 |
| `go test ./...` | Unit and package tests; passed on the current macOS arm64 tree on 2026-11-11 |
| `make -C extension PG_CONFIG=...` | Compile `pg_etcd.so` with zero warnings |
| `python3 tests/sql/run-p1-native.py` | Spin up an isolated temporary PostgreSQL cluster and run the SQL ABI test suites |
| `python3 tests/sql/run-p1-multidb.py` | Verify 8-database Lease worker supervision and tenant isolation on a temporary cluster |
{.wide}

> [!NOTE]
> The repository also contains `make p0-gate`, `make p1-gate`, and `make p2-gate` targets that audit archived evidence from the 2026-10-08 frozen candidate, as well as P3 native/cgroup tests isolated behind `-tags pgetcd_p3`. For `v0.1.0-rcN`, follow the lean release regression checklist described in [Status](/docs/etcd/status/#regression).

---

Backlinks:

- [Operations](/docs/etcd/operations/)
