Skip to content

fix(c/driver/sqlite): detect sqlite3_load_extension via compile check#4471

Merged
lidavidm merged 2 commits into
apache:mainfrom
fornwall:fix-sqlite-load-extension-detection
Jul 9, 2026
Merged

fix(c/driver/sqlite): detect sqlite3_load_extension via compile check#4471
lidavidm merged 2 commits into
apache:mainfrom
fornwall:fix-sqlite-load-extension-detection

Conversation

@fornwall

@fornwall fornwall commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

The build detected sqlite3_load_extension() availability with a plain-text search of sqlite3.h. That heuristic is unreliable: the identifier also appears in comments and inside blocks guarded by SQLITE_OMIT_LOAD_EXTENSION, so the symbol can be textually present in the header yet not actually declared/linkable. Apple's system SQLite is built with load extension omitted, so the search matched but sqlite.cc then failed to compile with "use of undeclared identifier 'sqlite3_load_extension'".

This started failing when the macos-latest (Apple Silicon) CI runner image was rolled to one whose SQLite omits the function; the string search never detected the omission. Replace it with a real compile+link probe using CheckSymbolExists, matching how the R package's configure script already detects the same thing.

Closes #4470.

The build detected sqlite3_load_extension() availability with a plain-text
search of sqlite3.h. That heuristic is unreliable: the identifier also
appears in comments and inside blocks guarded by SQLITE_OMIT_LOAD_EXTENSION,
so the symbol can be textually present in the header yet not actually
declared/linkable. Apple's system SQLite is built with load extension
omitted, so the search matched but sqlite.cc then failed to compile with
"use of undeclared identifier 'sqlite3_load_extension'".

This started failing when the macos-latest (Apple Silicon) CI runner image
was rolled to one whose SQLite omits the function; the string search never
detected the omission. Replace it with a real compile+link probe using
CheckSymbolExists, matching how the R package's configure script already
detects the same thing.

Signed-off-by: Fredrik Fornwall <fredrik@fornwall.net>
@fornwall fornwall force-pushed the fix-sqlite-load-extension-detection branch from c78ba3d to 4d8ee68 Compare July 7, 2026 09:40
@fornwall

fornwall commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

@lidavidm I've pushed a new commit (a7e4e07) which will hopefully fix the problems in the first commit (not handling the vcpkg path, and not working with older cmake versions).

@fornwall fornwall force-pushed the fix-sqlite-load-extension-detection branch from 955f76a to a7e4e07 Compare July 8, 2026 00:49
@fornwall

fornwall commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

There seems to be some hang? Not sure what that is about, or if it's caused by this PR, or some problems with new gitlab runners (seems to be specific to those).

@lidavidm lidavidm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix, just one question

Comment thread c/driver/sqlite/CMakeLists.txt
@fornwall fornwall requested a review from lidavidm July 8, 2026 11:24
Handle the vcpkg branch and older cmake distributions.
@fornwall fornwall force-pushed the fix-sqlite-load-extension-detection branch from a7e4e07 to e72b469 Compare July 8, 2026 21:49
@lidavidm lidavidm merged commit 198f39a into apache:main Jul 9, 2026
80 of 87 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQLite driver fails to compile on macOS: use of undeclared identifier 'sqlite3_load_extension'

2 participants