Skip to content

build: restrict shared-library exports to the public header - #162

Merged
Xuanwo merged 14 commits into
mainfrom
xuanwo/shared-library-export-visibility
Nov 22, 2026
Merged

Xuanwo merged 14 commits into
mainfrom
xuanwo/shared-library-export-visibility

Conversation

@Xuanwo

@Xuanwo Xuanwo commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Restrict the shared library's export surface to the functions declared in include/lancedb.h.

  • Generate the ELF version script, Mach-O exported-symbols list, and MSVC .def from the header's extern "C" declarations in build.rs. No fixed symbol count and no handwritten platform symbols.
  • Export control is an explicit final-target entry: CMake, the package workflow and the README shared build pass -C linker=cmake/export-linker.{sh,cmd} to cargo rustc. Plain cargo build remains the normal path for static, rlib, path-dependency and external-provider development, but does not apply the shared export boundary. This is the compatibility tradeoff.
  • On ELF and Mach-O the wrapper replaces only rustc's generated export control for the final liblancedb link, forwarding caller flags, SONAME/@rpath arguments, response files and -Xlinker/comma paths. On MSVC, the wrapper generates the paired .exp/.dll.lib at link time, then installs the import library.
  • CMake uses one decision for both the wrapper and the install verifier target, and passes --export-target to test_install.py. The configured Cargo linker is resolved through RUSTC_LINKER without overriding an explicit LANCEDB_REAL_LINKER. Linux ELF, Darwin Mach-O and native MSVC (including clang-cl) use the verifier; Windows GNU keeps its normal liblancedb.dll.a installed consumers without dumpbin.
  • Verify the actual installed or packaged header against the dynamic export table and load every public name in check_exports.py. check-install and package.py verify use the same check.
  • Document the incidental dependency exports removed from preview packages (CRC, BLAKE3, AWS-LC jitterentropy). No documented C function or header declaration is removed.

Refs #99.

Verification

  • Native MSVC x64 and arm64 probe (windows-2025 and windows-11-arm), run 45038405647, tested probe SHA 101d608: /DEF alone reproduced the dependency export, while the paired .exp/.dll.lib exported only the public function; a real consumer linked with the import library and ran on both architectures.
  • Five-target build-only package dispatch with publish_release=false, run 45062344184, on 224b99c. Package inputs are unchanged at final head 7114151 (only CMake and install-test wiring changed). Linux x64, Linux arm64 and Apple Silicon passed with exact exports, SONAME/install name and real consumers; Windows x64 and arm64 were still running at handoff.
  • Lightweight fixtures: CMake clang-cl selects the MSVC wrapper and --export-target windows; Windows GNU selects neither; Linux selects the ELF wrapper and --export-target linux. Cargo target-linker forwarding preserves space-containing paths and explicit LANCEDB_REAL_LINKER precedence; wrapper changes re-link. Package/release fixtures pass (36 and 32 tests).
  • Ordinary CI 45066477229 on final head was starting at handoff; the previous Windows x64 native job on 224b99c passed.

Branch base: main 16d6217; actual main observed aa27943; integration tree with actual main is eb469df (no conflicts).

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.

1 participant