build: keep the prebuilt cache out of the crate source tree; opt-in localization of bundled C symbols - #33
Merged
adsharma merged 1 commit intoSep 7, 2026
Conversation
…ocalization of bundled C symbols - The downloaded prebuilt archive now lives under OUT_DIR (or LBUG_PREBUILT_CACHE_DIR for a persistent, shared cache) instead of .cache/lbug-prebuilt inside CARGO_MANIFEST_DIR. For a registry dependency that directory is ~/.cargo/registry/src/…, which Cargo treats as immutable; writing there broke `cargo vendor`, read-only registries and offline builds. An archive already present in the legacy location is still used. - LBUG_LOCALIZE_BUNDLED_SYMBOLS=1 (Linux, static) partially links liblbug.a into one relocatable object, makes every strong unmangled symbol outside the lbug_* C API local, and archives it back. liblbug.a exports zstd, lz4, brotli, simsimd, yyjson and CRoaring with their ordinary names (192 ZSTD_*, 194 roaring/bitset/… including bare helpers such as `get` and `union`); a binary that also links zstd-sys, lz4-sys, simsimd or croaring-sys fails with rust-lld on Linux (duplicate symbol), while ld64 on macOS silently keeps whichever copy comes first. Opt-in because an extension that resolves one of those symbols from the host binary would stop finding it. Weak (COMDAT) symbols stay global so the linker can still deduplicate them. Verified: 0 ZSTD_/roaring_/simsimd_/LZ4 globals remain, 179 lbug_* and the mangled lbug:: API do, and the examples crate links and runs. - Crate docs: the two new variables, a bulk-loading section (COPY FROM and the Arrow table registration; one MERGE per row measured at tens of milliseconds each), and a note on the buffer pool's host-sized default. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013H2j2wjVBdmiK6v5sWM4u1
Contributor
|
The CI here tests only Linux. Will test windows/mac before merging. |
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.
Two build-script changes found while driving
lbug0.20.2 from a Rust graph adapter on x86_64 Linux. Both keep the default build byte-for-byte the same for anyone who does not opt in.Prebuilt cache location
build.rsdownloaded the prebuilt archive into.cache/lbug-prebuiltinsideCARGO_MANIFEST_DIR. For a registry dependency that is~/.cargo/registry/src/…/lbug-0.20.2/, which Cargo treats as immutable: it brokecargo vendor, read-only registries and offline builds. The archive now lives underOUT_DIR, or underLBUG_PREBUILT_CACHE_DIRfor a persistent cache shared between builds. An archive already present in the legacy location is still used, so existing checkouts do not re-download.Opt-in localization of bundled C symbols
liblbug.abundles zstd, lz4, brotli, simsimd, yyjson and CRoaring with their ordinary global names (192ZSTD_*, 194 roaring/bitset symbols including bare helpers such asgetandunion). A binary that also linkszstd-sys,lz4-sys,simsimdorcroaring-sys(here through Lance and Arrow) fails with rust-lld on Linux:duplicate symbol: ZSTD_compressBoundand nineteen more before the linker stops; ld64 on macOS silently takes the first definition, which is why it only shows up on Linux. WithLBUG_LOCALIZE_BUNDLED_SYMBOLS=1(Linux, static library only) the build script partially links the archive into one relocatable object, keeps everylbug_*C API symbol, C++-mangled symbol and weak symbol global, makes the rest local, and archives it back underOUT_DIR. Without the variable nothing changes.Verified on Debian 13 x86_64 against the prebuilt archive: the localized library links into a binary that also links
zstd-sysandsimsimdwithout--allow-multiple-definition, and the crate's tests pass either way. The crate docs list both variables.Context
Measurements and notes from the strain harness that motivated this, written for the maintainer: https://github.com/querygraph/adversarial-graph/blob/main/LADYBUG-NOTES.md (load path, point-lookup cost, buffer-pool sizing, and this packaging section).
🤖 Generated with Claude Code
https://claude.ai/code/session_013H2j2wjVBdmiK6v5sWM4u1