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/git/vole.git

Write over SSH with a registered key:

git clone ssh://git@0.0.0.0:2222/vole.git

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

Link SQLite dynamically through cgo

95425af7072b041bff198499b9285ee2582283bc · Keenan Nemetz · 10d 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/release.yaml +14−2

@@ -6,10 +6,22 @@
6 6 version: 1
7 7 from: golang:1.27.3-bookworm@sha256:972b4110ba0f47539a975c31e52c64765e1ff19f2d74469ae4a595c6676e80a5
8 8 env:
9 CGO_ENABLED: "0"
9 CGO_ENABLED: "1"
10 # Link the system SQLite instead of compiling the driver's bundled copy; the
11 # packages declare the matching runtime library (see packaging/nfpm.yaml).
12 GOFLAGS: "-tags=libsqlite3"
10 13 # Opt in to the runner's cache mount, so a tag build reuses what CI already
11 14 # downloaded and compiled.
12 15 GOMODCACHE: "/cache/go-mod"
13 16 GOCACHE: "/cache/go-build"
14 17 run:
15 - apt-get update && apt-get install -y --no-install-recommends git ca-certificates && rm -rf /var/lib/apt/lists/*
18 # arm64 is built on this amd64 image with a cross compiler, so the arm64
19 # libraries have to be installable beside the amd64 ones. Debian's archive
20 # carries both, so adding the architecture is enough.
21 - dpkg --add-architecture arm64
22 - apt-get update && apt-get install -y --no-install-recommends git ca-certificates gcc libsqlite3-dev:amd64 gcc-aarch64-linux-gnu libsqlite3-dev:arm64 && rm -rf /var/lib/apt/lists/*
23 # The test step spawns ssh and ssh-keygen, which call getpwuid() and exit 255
24 # with "No user exists for uid N" when the container runs as the host's uid and
25 # the image has no passwd entry for it. Same reason, same entry as the verify
26 # image.
27 - useradd --uid 1000 --create-home --shell /bin/sh ci