Repository navigation
Take darts-clone from the Bazel Central Registry - #1312
Merged
Merged
Conversation
BYVoid
marked this pull request as ready for review
August 26, 2026 19:42
The Bazel build now depends on the darts-clone BCR module instead of compiling third_party/darts_clone/darts.h. Module 0.32h.bcr.1 is upstream darts-clone v0.32h plus the copy_array() and validate() helpers the vendored header carries, so every entry point SentencePiece uses (build, set_array, copy_array, validate, exactMatchSearch, commonPrefixSearch, traverse, array, size) behaves identically; the module additionally has commonLongestPrefixSearch and an honoured save() offset, neither of which SentencePiece calls. The module exports the header as "darts.h", so the includes lose the third_party/darts_clone prefix. The CMake build still compiles the vendored copy and gains that directory on its include path.
BYVoid
force-pushed
the
claude/darts-clone-bcr
branch
from
August 31, 2026 19:20
50738c3 to
6d52aa4
Compare
1 task
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.
The Bazel build depends on the
darts-cloneBCR module instead of compilingthird_party/darts_clone/darts.h. The CMake build is unchanged and still compiles the vendored copy.0.32h.bcr.1vs.third_party/darts_clone/darts.hBoth declare
DARTS_VERSION "0.32"and both carry thecopy_array()andvalidate(max_value_limit)helpers this repo added — the module'sdarts_header_compat.patchis derived from those, and its compat test cites commitd685ef31.diffbetween the two headers is 108 lines:0.32h.bcr.1copy_array()validate(max_value_limit)commonLongestPrefixSearch()save()offsetargumentfseekBLOCK_SIZE,UPPER_MASK, …static constexpr intenumsize_t→id_typenarrowingstatic_castThe vendored copy predates the
v0.32htag, which is wherecommonLongestPrefixSearch()and thesave()offset fix landed; the module is that tag plus the two helpers above. The remaining differences are theenum/constexprspelling, the addedstatic_casts, andvalidate()'selse { if }rewritten aselse if— same semantics.SentencePiece calls
build,set_array,copy_array,validate,exactMatchSearch,commonPrefixSearch,traverse,arrayandsize. All behave identically.commonLongestPrefixSearch()andsave()are never called, so the two additions are inert here.Why the module rather than the vendored header
Known provenance. The module records exactly what it is:
s-yata/darts-clonev0.32h, pinned by SHA-256 of the release tarball, plus four named patches that are themselves hash-pinned.third_party/darts_clone/darts.his an undated snapshot of an unrecorded revision with local edits folded in — the only way to learn what was changed, as the table above shows, is to diff it against upstream and guess which side each difference came from.Upgrades become a version bump. The vendored copy has drifted behind
v0.32hand silently lost thesave()offset fix along the way. Moving it forward today means re-applying the two helpers by hand onto a new upstream drop and re-reviewing the result; with the module it is one line inMODULE.bazel, and the helpers travel as a patch that fails loudly if it stops applying.One copy per build. Bazel consumers that depend on both SentencePiece and darts-clone currently get two
Darts::DoubleArraydefinitions from two include paths. Going through the registry lets minimal version selection resolve them to a single copy, which matters for a header-only library whose types cross the ABI boundary innormalizer.handmodel_interface.h.The helpers are covered. The module ships
darts_clone_compat_test.cc, which exercisesvalidate()andcopy_array()— the two additions this repo depends on — so a bad patch rebase is caught in the registry's presubmit rather than here.Visible in dependency tooling. A
bazel_depwith a version appears inMODULE.bazel.lock,bazel mod graph, and any SBOM generated from them. A checked-in header does not.The vendored copy is not deleted: the CMake build still compiles it, so this change reduces the number of builds that depend on the unlabelled snapshot from two to one rather than to zero. Retiring it entirely would mean giving CMake its own way to fetch darts-clone, which is out of scope here.
Include path
The module exports the header as
darts.h(strip_include_prefix = "include"), so the seven#include "third_party/darts_clone/darts.h"lines lose the prefix.src/CMakeLists.txtgainsthird_party/darts_cloneon its include path so the CMake build resolves the same spelling against the vendored copy.Verified locally on macOS/arm64:
bazel test //...22/22 pass,cmake --buildsucceeds.🤖 Generated with Claude Code