[build] E: Build libsqlite3.so alongside libsqlite3.a#268
Open
esaurez wants to merge 1 commit into
Open
Conversation
Adds a libsqlite3.so link step to the `build` recipe that links the
.so from the (now PIC) static archive via -Wl,--whole-archive so every
sqlite3 entry point becomes part of the .so's .dynsym. Sets
DT_SONAME=libsqlite3.so so consumers that link against it emit a
proper DT_NEEDED entry.
libsqlite3 is self-contained -- no transitive .so deps -- so the .so
records no DT_NEEDED of its own. libc / libm / libz symbols are left
UND via -nostdlib and bind at dlopen time against the host
executable's .dynsym, matching the model already used by libffi.so /
libssl.so.
Changes:
- Makefile.nanvix:
- CONFIGURE_ENV CFLAGS gains -fPIC so the .o files used by
libsqlite3.a are also usable by the .so link.
- `build` recipe extended with a gcc -shared invocation that links
libsqlite3.so from libsqlite3.a after the upstream `make all`
completes.
- LIB_ARTIFACTS gains "libsqlite3.so", so the `install` recipe
copies it to LIB_OUT alongside libsqlite3.a (and `package` /
`verify-package` pick it up via the same list).
- .nanvix/z.py:
- _staged_output_files extended with libsqlite3.so so Windows
tar-copy mode copies the install-staged .so back to the host
workspace after the container exits.
Runtime dependency: the shared-library build becomes useful once the
loader changes in nanvix/nanvix#2473 ([syscall] E: Run dlopen
ctors/dtors and DT_RUNPATH) ship.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Jun 17, 2026
There was a problem hiding this comment.
Pull request overview
Builds and stages a Nanvix-compatible libsqlite3.so alongside the existing static libsqlite3.a, enabling consumers to dlopen() SQLite at runtime (e.g., CPython _sqlite3.so via DT_NEEDED libsqlite3.so) without going through upstream libtool-based --enable-shared.
Changes:
- Add
libsqlite3.soto the staged/install artifacts and to Windows tar-copy output files. - Compile SQLite objects as PIC (
-fPIC) and manually linklibsqlite3.sofromlibsqlite3.avia--whole-archive. - Clean up the newly produced shared object in
make clean.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Makefile.nanvix | Adds PIC compilation and a manual gcc -shared link step to produce/stage libsqlite3.so. |
| .nanvix/z.py | Ensures Windows tar-copy mode also copies the install-staged libsqlite3.so back to the host workspace. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
Builds
libsqlite3.soalongside the existinglibsqlite3.aso consumers candlopensqlite3 at run time instead of statically linking it.Why
Today the Nanvix sqlite port ships only
libsqlite3.a. Anything that wants sqlite3 (e.g., cpython's_sqlite3extension) has to statically embed it into the consumer binary. That works for cpython's monolithicpython.elfbut does not allow:.soconsumers in the same process._sqlite3.sothat resolves sqlite3 viaDT_NEEDED libsqlite3.so(the model already used by_ssl.so→libssl.soand_ctypes.so→libffi.soon Nanvix).Producing
libsqlite3.sohere unblocks the cpython migration of_sqlite3from--whole-archive .a in python.elftoDT_NEEDED .so.What changed
sqlite uses autotools and the upstream
--enable-sharedpath goes throughlibtool, which does not know abouti686-nanvix. Rather than teaching libtool a new platform target, this PR keeps--disable-sharedand linkslibsqlite3.somanually from the.ainside thebuildrecipe, the same approach already taken by nanvix/libffi#235.Concretely:
Makefile.nanvix:CONFIGURE_ENVCFLAGSgains-fPICso the same.ofiles compile into both.aand.so.buildrecipe extended with agcc -sharedinvocation that linkslibsqlite3.sofromlibsqlite3.avia-Wl,--whole-archivewithDT_SONAME=libsqlite3.soand-nostdlib(libc / libm / libz UND, bind at dlopen).LIB_ARTIFACTSgainslibsqlite3.so, so the existinginstallrecipe copies it toLIB_OUTautomatically..nanvix/z.py:_staged_output_filesextended withlibsqlite3.soso Windows tar-copy mode copies the install-staged.soback to the host workspace after the container exits.Architecture
libsqlite3.sohas no transitive.sodependencies (sqlite3 is self-contained; libc/libm/libz symbols are UND), so the loader does not need to walk any DT_NEEDED chain to load it.Dependencies
Runtime dep (already merged upstream):
dlfcninit-array + DT_RUNPATH support. Required for any consumer todlopen("libsqlite3.so")at run time.Validation
Build runs end-to-end inside the toolchain-gcc Docker image:
Structural verification of the produced
libsqlite3.so(~996 KB):SONAME correctly set, no spurious DT_NEEDED, full
sqlite3_*public API exported, libc symbols left UND for runtime binding. The existinglibsqlite3.aandsqlite3.elftest binary continue to build unchanged.