fix(vfs): resolve make vfs build failures #874
Merged
+41
−10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes VFS build failures across all platforms (macOS and Linux) and adds CI protection to prevent future regressions.
The VFS builds were broken by commit f5b166a (feat(vfs): add observability PRAGMAs and relative time parsing #856) on Dec 1, 2025. The pre-built binaries in
dist/were from Nov 26 (before this change), which is why they still worked.Root Cause Analysis
Issue 1: Missing
-DSQLITE3VFS_LOADABLE_EXTC Preprocessor FlagSymptom:
Cause:
The
sqlite3vfs.hheader from the psanford/sqlite3vfs library uses conditional compilation:The Go build step already passes
-tags SQLITE3VFS_LOADABLE_EXT, but Go build tags only affect Go code compilation — they don't define C preprocessor macros. The subsequent gcc/clang commands that compilesrc/litestream-vfs.cinto a shared library were missing the-DSQLITE3VFS_LOADABLE_EXTflag.Without this flag, the C compiler tried to include
sqlite3-binding.h(used by mattn/go-sqlite3 for embedded builds), which doesn't exist in oursrc/directory. We bundlesqlite3ext.hinstead because we're building a loadable extension.Fix:
Added
-DSQLITE3VFS_LOADABLE_EXTto all 5 VFS build targets in the Makefile:vfs(macOS native)vfs-linux-amd64vfs-linux-arm64vfs-darwin-amd64vfs-darwin-arm64Issue 2:
const char*vschar*Type MismatchSymptom:
Cause:
CGO generates C function declarations from Go
//exportcomments. It does not preserveconstqualifiers — all pointer parameters become non-const.The C source file manually declared:
But CGO generated (in
litestream-vfs.h):C treats
const char*andchar*as incompatible types, causing a compilation error.Fix:
src/litestream-vfs.cline 14 fromconst char*tochar*(const char*)tsto(char*)tsIssue 3:
int64_tvslong long intType Conflict (Linux Only)Symptom (only after fixing Issues 1 & 2):
Cause:
This is a subtle platform-specific issue with 64-bit integer types on Linux.
The Go CGO preamble had:
On Linux x86_64,
<stdint.h>defines:int64_taslong intBut SQLite's
sqlite3.hdefines:sqlite3_int64aslong long int(viasqlite_int64)Both
long intandlong long intare 64-bit on Linux x86_64, but C treats them as distinct, incompatible types. When we include both headers, the compiler sees two conflicting definitions forsqlite3_int64.On macOS, both map to
long long int, so this issue didn't appear there.Fix:
Changed the CGO preamble in
cmd/litestream-vfs/main.goto use SQLite's exact type definitions:This ensures type compatibility with
sqlite3.hacross all platforms.Changes Summary
Makefile-DSQLITE3VFS_LOADABLE_EXTto gcc/clang in all 5 VFS targetssrc/litestream-vfs.cconst char*→char*in declaration (L14) and call (L109)cmd/litestream-vfs/main.goint64_t/uint64_t→long long int/unsigned long long int.github/workflows/commit.ymlVFS Build Test (macOS)andVFS Build Test (Linux)CI jobsTest Plan
make vfsbuilds successfully on macOS (native ARM64)make vfs-linux-amd64builds successfully via DockerWhy CI Was Added
The VFS build jobs were recently added to
release.ymlbut had never been triggered (no releases since they were added). This meant the build failures went unnoticed. Adding VFS build tests tocommit.ymlensures every PR is tested before merge.Fixes #873
🤖 Generated with Claude Code