OP-Engineering / OP-Engineering/op-sqlite

sqlite-vec: armeabi-v7a libsqlite_vec.so fails to load — undefined `ceil`, libm.so missing from NEEDED

Open
#456 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
1k
Forks
91
Avg merge
11h 53m
Merged PRs (30d)
11

Description

Version: @op-engineering/op-sqlite 18.2.1 (latest), with "op-sqlite": { "sqliteVec": true }
Environment: React Native 0.86.3 (New Architecture), Expo SDK 57, release build with -PreactNativeArchitectures=armeabi-v7a
Device: Infinix X6823, Android 12, 32-bit userland (ro.product.cpu.abilist = armeabi-v7a,armeabi)

What happens

The first open() throws:

Exception in HostFunction: dlopen failed: cannot locate symbol "ceil" referenced by "/data/app/~~…/base.apk!/lib/armeabi-v7a/libsqlite_vec.so"
Cause

The prebuilt android/src/main/libsqlitevec/armeabi-v7a/libsqlite_vec.so leaves ceil undefined but does not list libm.so as a dependency. Output from llvm-readelf (NDK 27.1.12297006):

$ llvm-readelf -d armeabi-v7a/libsqlite_vec.so | grep NEEDED
  0x00000001 (NEEDED)       Shared library: [libdl.so]
  0x00000001 (NEEDED)       Shared library: [libc.so]

$ llvm-readelf --dyn-syms armeabi-v7a/libsqlite_vec.so | awk '$7=="UND"' | grep ceil
  ... UND ceil

The arm64-v8a build has the same NEEDED list but no undefined ceil (presumably the compiler inlines it there), so the failure only shows on 32-bit ARM. On Android, ceil lives in libm.so, and the dynamic linker resolves a library's undefined symbols only from its own NEEDED entries. I only checked armeabi-v7a and arm64-v8a, not x86 / x86_64.

Likely fix

Link the 32-bit libsqlite_vec.so against libm (e.g. -lm) so that libm.so appears in NEEDED.

Repro
  1. Set "op-sqlite": { "sqliteVec": true } in package.json.
  2. Build a release APK for armeabi-v7a and install it on a 32-bit Android device.
  3. Call open({ name: 'test.db' }).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with android/src/main/libsqlitevec/armeabi-v7a/libsqlite_vec.so and inspect its dynamic dependencies and undefined symbols with llvm-readelf. Check the native build inputs that produce this prebuilt library, verify libm.so is listed for the affected ABI, and confirm a release APK can open SQLite on armeabi-v7a without the dlopen error.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, c, react-native, sqlite
Domain
build-system, database, mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.