Motivation
EDG Core currently depends on github.com/mattn/go-sqlite3 for its metadata store. go-sqlite3 is a cgo wrapper around the SQLite C library, which means:
-
Windows builds require a gcc toolchain (mingw-w64 or equivalent). Default go build on Windows ships without cgo, producing a binary that fails at runtime:
Failed to create store: ... go-sqlite3 requires cgo to work. This is a stub
Field engineers spinning up edg-core on a Windows IPC, devs running quick smoke tests, or CI runners that don't have gcc installed all hit this wall.
-
Cross-compilation is awkward. GOOS=linux go build from a Windows host without a Linux gcc cross-toolchain silently produces the same broken stub.
-
CGO_ENABLED=1 leaks into downstream Dockerfiles, CI matrices, and release pipelines. Every contributor environment needs to be cgo-capable.
Discovered during Beckhoff adapter smoke testing on Windows — edg-core started NATS successfully but exited immediately when initializing the metadata store.
Proposed change
Replace the SQLite driver with modernc.org/sqlite, a pure-Go transpilation of the SQLite C source. No cgo required.
Scope
Out of scope
- Adapter SDK code (no sqlite usage)
- Migration of any production deployments — the on-disk SQLite format is identical, so existing
metadata.db files keep working.
Risk
- Performance:
modernc.org/sqlite is ~10-30% slower than cgo in microbenchmarks. EDG Core uses sqlite for asset metadata (low write rate, mostly read), so this should not matter in practice. Worth a quick benchmark before merging.
- Subtle SQL behaviour differences: Both drivers target the same SQLite engine version, so feature coverage matches; differences are usually in driver-level features (custom functions, connection hooks) which EDG Core doesn't currently use.
golang-migrate driver maturity: The modernc.org-backed migrate driver is less battle-tested than the mattn variant. Verify by running all existing migrations on a fresh DB.
Acceptance criteria
Workaround until then
Install mingw-w64 (e.g. via winget install BrechtSanders.WinLibs.POSIX.UCRT) and build with CGO_ENABLED=1. This is what we're doing in the Beckhoff smoke test setup currently.
Motivation
EDG Core currently depends on
github.com/mattn/go-sqlite3for its metadata store.go-sqlite3is a cgo wrapper around the SQLite C library, which means:Windows builds require a gcc toolchain (mingw-w64 or equivalent). Default
go buildon Windows ships without cgo, producing a binary that fails at runtime:Field engineers spinning up edg-core on a Windows IPC, devs running quick smoke tests, or CI runners that don't have gcc installed all hit this wall.
Cross-compilation is awkward.
GOOS=linux go buildfrom a Windows host without a Linux gcc cross-toolchain silently produces the same broken stub.CGO_ENABLED=1 leaks into downstream Dockerfiles, CI matrices, and release pipelines. Every contributor environment needs to be cgo-capable.
Discovered during Beckhoff adapter smoke testing on Windows — edg-core started NATS successfully but exited immediately when initializing the metadata store.
Proposed change
Replace the SQLite driver with
modernc.org/sqlite, a pure-Go transpilation of the SQLite C source. No cgo required.Scope
go.mod: dropgithub.com/mattn/go-sqlite3, addmodernc.org/sqliteinternal/core/store*.go(and anywhere else usingsql.Open("sqlite3", ...)): change driver name to"sqlite"github.com/golang-migrate/migrate/v4/database/sqlite3→.../sqlite(the modernc-compatible package)modernc.org/sqlitefollows SQLite-standard PRAGMAs but some_pragma=DSN extensions differmattn/go-sqlite3Out of scope
metadata.dbfiles keep working.Risk
modernc.org/sqliteis ~10-30% slower than cgo in microbenchmarks. EDG Core uses sqlite for asset metadata (low write rate, mostly read), so this should not matter in practice. Worth a quick benchmark before merging.golang-migratedriver maturity: The modernc.org-backed migrate driver is less battle-tested than the mattn variant. Verify by running all existing migrations on a fresh DB.Acceptance criteria
go build ./...succeeds on Windows with no gcc toolchain installed.edg-core -config deploy/configs/core/config.dev.yamlstarts cleanly on Windows and creates metadata.db.metadata.dbfrom this branch is byte-readable bysqlite3CLI (rules out exotic file format issues).Workaround until then
Install mingw-w64 (e.g. via
winget install BrechtSanders.WinLibs.POSIX.UCRT) and build withCGO_ENABLED=1. This is what we're doing in the Beckhoff smoke test setup currently.