Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software:2222/vole.git

A free and open-source forge that lives in your Git repo.

Link SQLite dynamically through cgo

95425af7072b041bff198499b9285ee2582283bc · Keenan Nemetz · 11d ago · parent 7defd797

Link SQLite dynamically through cgo

modernc.org/sqlite is a pure-Go translation of SQLite and the largest thing in
the binary: it is about 4 MB of the 23.1 MB the release flags produce, while the
cgo driver against the system library costs about 0.25 MB. With the same flags
the amd64 binary drops to 19.3 MB (16% smaller), the .deb from 18.1 MB to 8.0 MB,
and the cgo driver is also faster on database-heavy paths: the repository index,
sessions, and the CI run store.

The trade is that the binary is no longer self-contained. It needs
libsqlite3.so.0 at runtime, so the .deb depends on libsqlite3-0 and the .rpm on
sqlite-libs, and building needs a C compiler and the SQLite development headers.
arm64 is still cross-compiled on the amd64 release image, with
gcc-aarch64-linux-gnu and libsqlite3-dev:arm64 installed beside the amd64 ones;
both architectures still build byte for byte from the same tag.

The DSNs carried modernc-only pragma parameters. mattn/go-sqlite3 spells them
_busy_timeout, _journal_mode, and _foreign_keys, and the driver is sqlite3, so
the connections keep the busy timeout, WAL mode, immediate write transactions,
and foreign keys they had before. The release image also defines the ci user the
verify image already has, so the release test step runs ssh as the host's uid
when the workflow is reproduced locally.

.vole/images/verify.yaml +7−3

@@ -1,6 +1,7 @@
1 1 # The image .vole/workflows/verify.yaml runs in. It carries everything the steps call: the Go toolchain
2 # (with gcc, so -race works), git and the ssh client and keygen the server tests
3 # spawn, and python3 for the link check.
2 # (with gcc, so -race works), the SQLite development headers the driver links
3 # against, git and the ssh client and keygen the server tests spawn, and python3
4 # for the link check.
4 5 #
5 6 # The toolchain is the one go.mod pins (go 1.27.3), and the base image is pinned
6 7 # by digest so the scanner and the compiler that pass a push are the ones the
@@ -20,10 +21,13 @@ version: 1
20 21 from: golang:1.27.3-bookworm@sha256:972b4110ba0f47539a975c31e52c64765e1ff19f2d74469ae4a595c6676e80a5
21 22 env:
22 23 CGO_ENABLED: "1"
24 # Link the system SQLite instead of compiling the driver's bundled copy, so the
25 # tests run against the same library the release packages depend on.
26 GOFLAGS: "-tags=libsqlite3"
23 27 # Opt in to the cache the runner mounts at /cache. Nothing is cached unless the
24 28 # job points at it; see docs/runner.md.
25 29 GOMODCACHE: "/cache/go-mod"
26 30 GOCACHE: "/cache/go-build"
27 31 run:
28 - apt-get update && apt-get install -y --no-install-recommends git git-lfs openssh-client python3 ca-certificates && rm -rf /var/lib/apt/lists/*
32 - apt-get update && apt-get install -y --no-install-recommends libsqlite3-dev git git-lfs openssh-client python3 ca-certificates && rm -rf /var/lib/apt/lists/*
29 33 - useradd --uid 1000 --create-home --shell /bin/sh ci