Repository navigation
Conversation
The loadable extension exported every non-static function and sqlite3_api, 111 symbols in all. SQLite opens an extension with RTLD_GLOBAL, so with two builds of sqlite-vec loaded into one process, the second build's vec0 calls bound to the first build's functions: loading a build with the rescore index and then one built with SQLITE_VEC_ENABLE_RESCORE=0 crashed the process when the second connection created a table. Compile with -fvisibility=hidden, as vlasky/sqlite-vec@e8f156b does, and give SQLITE_VEC_API default visibility so sqlite3_vec_init stays exported. The static branch uses the attribute only with GCC and Clang outside Windows, so MSVC still compiles SQLITE_VEC_STATIC builds.
MayCXC
added a commit
to MayCXC/sqlite-vec
that referenced
this pull request
Oct 23, 2026
This was referenced Oct 23, 2026
Closed
mceachen
pushed a commit
to photostructure/sqlite-vec
that referenced
this pull request
Oct 24, 2026
…VC in static builds
With -DSQLITE_VEC_STATIC the template defines SQLITE_VEC_API as
__attribute__((visibility("default"))) on every compiler. MSVC has no
__attribute__, so a static build with it stops at the header's declaration
of sqlite3_vec_init(); with MSVC 19.44 on windows-2022:
cl /c /W4 /Ivendor/ /O2 /DSQLITE_CORE /DSQLITE_VEC_STATIC sqlite-vec.c
sqlite-vec.h(33): error C2143: syntax error: missing ')' before '('
sqlite-vec.h(33): error C2091: function returns function
The loadable build, which CI compiles with cl.exe, takes the _WIN32 branch
and is unaffected.
The static branch now applies the attribute only under GCC and Clang outside
Windows, the guard asg017#340 uses, and defines SQLITE_VEC_API
empty otherwise. With GCC and Clang the static objects are byte-identical
before and after. sqlite-vec.h regenerates from the template at release, as
it does for the template's other changes.
vlasky
pushed a commit
to vlasky/sqlite-vec
that referenced
this pull request
Oct 28, 2026
With -DSQLITE_VEC_STATIC the template defines SQLITE_VEC_API as
__attribute__((visibility("default"))) on every compiler. MSVC has no
__attribute__, so a static build with it stops at the header's declaration
of sqlite3_vec_init(); with MSVC 19.44 on windows-2022:
cl /c /W4 /Ivendor/ /O2 /DSQLITE_CORE /DSQLITE_VEC_STATIC sqlite-vec.c
sqlite-vec.h(34): error C2143: syntax error: missing ')' before '('
sqlite-vec.h(34): error C2091: function returns function
The loadable build, which CI compiles with cl.exe, takes the _WIN32 branch
and is unaffected.
The static branch now applies the attribute only under GCC and Clang outside
Windows, the guard asg017#340 uses, and defines SQLITE_VEC_API
empty otherwise. With GCC and Clang the static objects are byte-identical
before and after. sqlite-vec.h regenerates from the template with the next
version bump, as it does for the template's other changes.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
dist/vec0.soexports every non-static function in sqlite-vec.c, andsqlite3_apiwith them: on Linux arm64,nm -D --defined-only dist/vec0.solists 111 symbols, among themarray_append,bitmap_new, thediskann_*helpers andvec0Filter_fullscan. SQLite opens an extension withRTLD_GLOBAL, so the calls inside one library can bind to another library's exported function of the same name. With two builds of sqlite-vec in one process, the second build runs the first build's code:Loaded alone,
bfails withvec0 constructor error: could not parse vector column 'embedding float[8] indexed by rescore(quantizer=bit)'. Loaded aftera, the process crashes with SIGSEGV on that statement.This PR compiles with
-fvisibility=hidden, as vlasky/sqlite-vec@e8f156b does for vlasky's fork (it says it was inspired by #149, which its author closed without a review) and as photostructure/sqlite-vec's Makefile does, which has that commit in its history.SQLITE_VEC_APIgets default visibility sosqlite3_vec_initstays exported;nm -Dthen lists it alone, and with this PR the reproduction fails onbthe waybfails when loaded alone. One difference from vlasky's header: theSQLITE_VEC_STATICbranch uses__attribute__((visibility("default")))only with GCC and Clang outside Windows, so MSVC can still compile aSQLITE_VEC_STATICbuild and MinGW does not warn about an ignored attribute. A Windows DLL already exports only its__declspec(dllexport)functions, so Windows builds are unchanged.site/compiling.md's manual Linux and macOS commands pass the flag too, with a sentence on why; the documented Linux command, built from this branch, exportssqlite3_vec_initalone and loads.Test.
test_exports_only_entry_pointopensdist/vec0withctypesand checks thatsqlite3_vec_initresolves andsqlite3_api,bitmap_newandvec0Filter_fullscando not. On main it fails withAssertionError: sqlite3_api.make test-loadablepasses (240 passed, 66 skipped), and the build adds no warnings to main's 12.This merges cleanly with #293, #304 and #305, which also touch the Makefile or the tests.