Sign in

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

vole
Site
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

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

Self-hosted forge that lives in your Git repo.

Cross-compile macOS binaries with the pure-Go SQLite driver

629df77e31a37ae5f986f4019271bb654c7c4bfc · Keenan Nemetz · 12d ago · parent 8cdf2f6b

Cross-compile macOS binaries with the pure-Go SQLite driver

The release published only Linux binaries, and the tree did not compile for
GOOS=darwin: syscall.Statfs_t.Bsize is uint32 there and int64 on Linux. Even
with that fixed, the cgo SQLite driver made a Darwin binary impossible to
produce on a Linux runner without an Apple SDK.

Return to modernc.org/sqlite, the pure-Go driver this project used before the
size change in #91. The DSN shorthand is unchanged because modernc accepts the
same _busy_timeout, _journal_mode, _foreign_keys and _txlock keys mattn does, so
the stores only change their driver name and blank import. With CGO_ENABLED=0
the tree cross-compiles for linux/amd64, linux/arm64, darwin/amd64 and
darwin/arm64 from the pinned release image, and the Linux binaries are static.

The release workflow now builds both Darwin binaries before the checksum step,
so SHA256SUMS covers them and the channel serves them; verify builds them on
every push so a platform mistake fails on the push instead of the tag.

This also fixes two defects in what we shipped:

- The packaged binary needed GLIBC_2.34 while nfpm.yaml declared only git and
  libsqlite3-0, so Debian 11 and Ubuntu 20.04 installed a package that failed at
  exec. A static binary has no libc floor.
- -tags sqlite_fts5 was inert under -tags libsqlite3, because the amalgamation
  it configures is not compiled, so full-text search depended on how the user's
  distribution built libsqlite3.so.0. The engine is now compiled in.

The cost is the size growth measured in #91, reversed deliberately: 19.3 MB with
system SQLite, 23.4 MB with the engine compiled in on linux/amd64. SQLite
security updates now arrive with a Vole release rather than with apt upgrade;
the SBOM names the engine version, which is what makes that triage possible.

Closes: 01M7ZFNCCJDTS2V5RTYQS9QQ84

DEVELOPMENT.md +21−26

@@ -10,16 +10,15 @@ You need:
10 10
11 11 - **Go with toolchain management.** `go.mod` selects Go 1.27.4 and downloads
12 12 that toolchain when needed.
13 - **A C compiler and SQLite development headers.** Install `libsqlite3-dev` on
14 Debian or Ubuntu, or `sqlite-devel` on Fedora or RHEL. Vole links SQLite
15 dynamically and requires FTS5 for global search; those distribution packages
16 provide both.
13 - **No C compiler.** SQLite is compiled in through a pure-Go driver, so the
14 build is static and needs only the Go toolchain. That is what lets the release
15 cross-compile Linux and macOS binaries on Linux.
17 16 - **Git and the OpenSSH client.** The test suite invokes Git and `ssh`.
18 17 - **Python 3** for the documentation and deployment checks.
19 18 - **Optional: Docker, Podman, or nerdctl** to run the complete verification
20 19 workflow in its container image.
21 20
22 The resulting binary needs `libsqlite3.so.0` on the machine that runs it.
21 The resulting binary is static: it needs Git and nothing else at run time.
23 22
24 23 ## Build Vole
25 24
@@ -32,7 +31,7 @@ Clone the repository, then install it from its root:
32 31 ```sh
33 32 git clone <repository-url>
34 33 cd vole
35 go install -tags libsqlite3,sqlite_fts5 ./cmd/vole
34 go install ./cmd/vole
36 35 vole version
37 36 ```
38 37
@@ -49,25 +48,23 @@ output tells you whether the command you are running is the build from this
49 48 checkout or an installed release. `4f8a3da.dirty` marks a build from a checkout
50 49 with uncommitted changes. Re-run `go install` after changing code.
51 50
52 The `libsqlite3` tag links the system SQLite library instead of the driver's
53 bundled copy. The `sqlite_fts5` tag enables full-text search. The release build
54 uses the same tags; [Install](docs/install.md#build-from-source) covers other
55 ways to get `vole`.
51 The release build uses the same command, with no tags and with cgo off, so a
52 binary built here behaves like a packaged one. [Install](docs/install.md#build-from-source)
53 covers other ways to get `vole`.
56 54
57 55 ## Run tests
58 56
59 Run the complete test suite with the same SQLite tags as the build:
57 Run the complete test suite:
60 58
61 59 ```sh
62 CGO_ENABLED=1 go test -tags libsqlite3,sqlite_fts5 ./...
60 CGO_ENABLED=0 go test ./...
63 61 ```
64 62
65 63 Run one package or test while iterating:
66 64
67 65 ```sh
68 CGO_ENABLED=1 go test -tags libsqlite3,sqlite_fts5 ./server/web
69 CGO_ENABLED=1 go test -tags libsqlite3,sqlite_fts5 \
70 -run '^TestDevLogin' ./server/web
66 go test ./server/web
67 go test -run '^TestDevLogin' ./server/web
71 68 ```
72 69
73 70 Add regression tests with the code they cover. Run the race-enabled suite before
@@ -212,9 +209,10 @@ relevant to your change:
212 209
213 210 ```sh
214 211 gofmt -l .
215 CGO_ENABLED=1 go vet -tags libsqlite3,sqlite_fts5 ./...
216 go build -tags libsqlite3,sqlite_fts5 ./...
217 CGO_ENABLED=1 go test -tags libsqlite3,sqlite_fts5 -race -count=1 ./...
212 CGO_ENABLED=0 go vet ./...
213 CGO_ENABLED=0 go build ./...
214 # The race runtime itself needs cgo; the code under test does not.
215 CGO_ENABLED=1 go test -race -count=1 ./...
218 216 python3 scripts/check-deploy.py
219 217 python3 scripts/check-links.py
220 218 ```
@@ -232,8 +230,7 @@ corpora run during ordinary `go test ./...`. To spend longer on one target, name
232 230 it and give it a time budget:
233 231
234 232 ```sh
235 go test -tags libsqlite3,sqlite_fts5 -run '^$' \
236 -fuzz '^FuzzSplitCommand$' -fuzztime=60s ./server/ssh
233 go test -run '^$' -fuzz '^FuzzSplitCommand$' -fuzztime=60s ./server/ssh
237 234 ```
238 235
239 236 When a fuzz run finds a failure, Go writes the input under
@@ -252,20 +249,18 @@ Measure every route for five seconds with four workers:
252 249
253 250 ```sh
254 251 VOLE_LOAD_SCENARIO=all VOLE_LOAD_CONCURRENCY=4 VOLE_LOAD_DURATION=5s \
255 go test -tags load,sqlite_fts5 -run '^TestLoad$' -v ./server
252 go test -tags load -run '^TestLoad$' -v ./server
256 253 ```
257 254
258 255 Measure clones with sixteen workers for thirty seconds:
259 256
260 257 ```sh
261 258 VOLE_LOAD_SCENARIO=clone VOLE_LOAD_CONCURRENCY=16 VOLE_LOAD_DURATION=30s \
262 go test -tags load,sqlite_fts5 -run '^TestLoad$' -v ./server
259 go test -tags load -run '^TestLoad$' -v ./server
263 260 ```
264 261
265 `sqlite_fts5` enables search support. Add `libsqlite3` to the comma-separated
266 tag list when building against system SQLite; without it, the driver uses its
267 bundled copy. Put every required tag on the command line because `-tags`
268 replaces tag settings inherited through `GOFLAGS`.
262 `load` is the only tag these commands need. Put it on the command line because
263 `-tags` replaces tag settings inherited through `GOFLAGS`.
269 264
270 265 | Variable | Default | Values |
271 266 |---|---|---|