Skip to content

version: expose the resolved build version in header and runtime - #120

Merged
Xuanwo merged 6 commits into
mainfrom
xuanwo/c-version-introspection
Nov 22, 2026
Merged

Xuanwo merged 6 commits into
mainfrom
xuanwo/c-version-introspection

Conversation

@Xuanwo

@Xuanwo Xuanwo commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Implements the version introspection slice of #99. Includes current main (#121) with coverage removed.

The public header exposes LANCEDB_VERSION_MAJOR, LANCEDB_VERSION_MINOR, LANCEDB_VERSION_PATCH, LANCEDB_VERSION_STRING and the LANCEDB_VERSION alias. lancedb_version() returns the same resolved version from the loaded library as a static, NUL-terminated string owned by the library; callers must not free it.

The checked-in header keeps 0.0.0-dev so direct C17 use still works without a generated file. CMake and the package builder render the same version block from the existing tag/override/dev resolution. Direct Cargo builds resolve the public LANCEDB_VERSION override or exact peeled tags at HEAD in build.rs, with a dev fallback for source trees without Git.

Reviewed follow-up fixes included:

  • CMake tracks the effective symbolic HEAD ref, its loose file, and its closest existing ancestor. A packed-only nested branch that creates its hierarchy on the next update now reconfigures instead of reusing the old tag.
  • Reftable repositories watch reftable/tables.list in both the per-worktree and common Git directories. build.rs watches the same path for direct Cargo builds.
  • Generated headers live under <build>/generated/include; in-source configure no longer overwrites include/lancedb.h, and consumer, Doxygen and install paths use the dedicated directory.
  • The generated header is rewritten only when its rendered bytes change, so non-tag branch advances leave its mtime unchanged and do not rebuild consumers for identical content. LF and version validation remain.
  • The strict C17 consumer composes the numeric release core with two-level stringification and checks a NUL, - or + boundary. It keeps exact header/runtime equality and numeric macro consistency without sscanf, CRT suppression or toolchain-specific code.

Validation on 08a0c700ae118988a719f85f0530777c8b9e7599 (tree 4a0f23bcb0f3af77c549b59eb81d950e5a712dc3):

  • python3 .github/scripts/test_package.py: 28 tests passed.
  • python3 .github/scripts/test_release.py: 32 tests passed.
  • Integrated CMake configure with the dev default; the generated header moved to build/generated/include/lancedb.h and the source template stayed at 0.0.0-dev.
  • Strict C17 compilation with GCC 11.5 and Clang 15.0 for both the checked-in and generated headers; lancedb_source_header_c17 builds through CMake.
  • check-abi: host LP64 and MSVC LLP64 both matched 147 extern functions, 25 structs and 5 enums.
  • Nested packed and reftable fixtures under Ninja and Unix Makefiles moved a branch off an annotated preview tag; installed header and runtime changed from 0.2.0-preview.1 to 0.0.0-dev without a manual reconfigure. Linked-worktree reftable refs passed the same test.
  • Direct Cargo reftable reproduction: the old build.rs stayed at 0.2.0-preview.1 after the branch moved off tag; the new build.rs produced 0.0.0-dev.
  • Reconfiguring an unchanged 0.0.0-dev branch left the generated header mtime unchanged under both Ninja and Make.
  • Repeated in-source configure (0.7.0, then 0.7.1) left the checked-in template at 0.0.0-dev.
  • C17 consumer runtime passed for 0.0.0-dev and 0.2.0-preview.1+build.5 on prepared head d2173bf; the current merge only appends build: remove code coverage support #121's coverage removal and these build-system fixes.
  • The original Windows failure was sscanf under MSVC /W4 /WX; that call is gone. The Windows job on 484bb82 covers the unchanged C17 consumer, but this new head still needs its newly triggered native checks. No coverage check is expected after build: remove code coverage support #121.

Refs #99.

Render the public header version macros from the same tag or override that CMake and the package manifest use, and expose lancedb_version() from the library as a static string. Direct Cargo builds resolve the same tags without requiring CMake or Python.

Package creation renders the header for its manifest version, and release verification derives the expected header from the exact tagged source plus the tag version. Keep the checked-in header usable directly with its development defaults.

Refs #99
CMake configuration watched HEAD and tag refs but not the branch ref behind a symbolic HEAD, so an incremental build after moving the branch off a release tag reused the old version. Track the effective symbolic ref path plus its parent, covering loose, packed and linked-worktree refs.

Render generated headers under ${CMAKE_BINARY_DIR}/generated/include instead of ${CMAKE_BINARY_DIR}/include. In-source configuration no longer overwrites include/lancedb.h, and consumer and install paths follow the dedicated directory.

Refs #99
Replace sscanf with two-level stringification of the numeric version macros and compare the runtime version prefix plus a valid -, + or NUL boundary. The exact header/runtime comparison and numeric macro assertion remain, without CRT deprecation warnings on MSVC.

Validated with strict C17 source, CMake-generated and package headers on GCC and Clang, the C17 consumer for dev and +build versions, package/release fixtures and the host/MSVC LLP64 ABI check.
…ders

Watch the closest existing ancestor of a missing loose symbolic ref so a packed nested branch that creates its hierarchy on the next update still reconfigures. Watch reftable/tables.list in both the per-worktree and common Git directories, and teach build.rs the same reftable path for direct Cargo builds.

Only rewrite the generated header when the rendered bytes differ. Non-tag branch advances then leave its mtime unchanged and do not rebuild consumers for identical content; LF and version validation remain in place.

Validated with nested packed and reftable fixtures under Ninja and Unix Makefiles, including linked-worktree reftable refs, installed header/runtime comparisons, direct Cargo reftable builds and unchanged header mtimes.
@Xuanwo
Xuanwo merged commit ab46e9b into main Nov 22, 2026
9 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.

1 participant