Repository navigation
Conversation
`ZVEC_LIB_DIR` is documented as the highest priority source for the native library, but an unusable value only prints a warning and resolution continues with the sibling checkout, the submodule, `vendor/lib`, a cached or downloaded prebuilt SDK, or a source build. A typo, a stale path, or a directory holding an incomplete SDK therefore links a different copy of the library than the one the environment selected, without failing. `ZVEC_STRICT_LIB=1` makes the explicit configuration the only accepted source: `ZVEC_LIB_DIR` must be set and must contain the platform library, every substitute is skipped, and a missing or invalid directory fails the build script with the expected file name and target instead of falling back. The mode is off by default, is enabled only by `1` or `true`, and never acquires anything. `has_zvec_lib` now shares its platform file-name table with the failure message so both report the same artifacts for the current target. Tests: `zvec-sys/tests/build_script.rs` gains six cases — explicit directory required, incomplete directory rejected, valid directory accepted, every other value leaving the mode off, acquisition unreachable, and the platform file-name table for Linux, macOS and Windows.
…ding Review findings on the strict-artifact mode: - `ZVEC_STRICT_LIB=true` (and `True`/`TRUE`) is now exercised, and the values other toolchains read as "yes" (`yes`, `on`) are pinned as off, so the accepted word is exactly `true`, case-insensitively, which the README now states. - Strict mode no longer takes the cppjieba dictionary from a sibling checkout or the submodule: a dictionary from a different copy of the SDK is the same silent substitution the mode refuses. `resolve_jieba_dict_dir` stops after the configured directory in strict mode, and the test asserts the non-strict sibling pick and the strict refusal on one fixture. - The failure message reads "one of a, b, c" where the platform accepts several artifact names, so the MinGW message no longer reads as if all three were required. - README: the `true` casing, the dictionary rule, and the include-path consequence stated outright -- headers may still come from a sibling checkout, which decides what downstream build scripts see rather than what the linker uses. Verified: build-script tests 19 passed (three new), workspace 232 passed and 0 failed, `clippy -D warnings` clean, and five real build runs -- strict with `1` and with `TRUE`, missing directory, unset directory, and the non-strict fallback.
mrcs64
marked this pull request as ready for review
October 16, 2026 20:52
Upstream removed build-script cppjieba dictionary discovery in zvec-ai#21 (the dictionary is now embedded in libzvec_c_api). Resolve by dropping the remaining dictionary handling from this branch: the strict-mode dictionary paragraphs in README, the ZVEC_RUST_JIEBA_DICT_DIR registration, and the test that covered resolve_jieba_dict_dir. Strict mode now constrains only the native library, as the upstream design implies.
Contributor
Author
|
GitHub Actions on this repo are currently blocked by an account billing lock, so |
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.
Problem
ZVEC_LIB_DIRis documented as the highest priority source for the native library, but a value that cannot be used is not an error. Fromzvec-sys/build.rs:Resolution then continues with the sibling checkout, the submodule,
vendor/lib, a cached or downloaded prebuilt SDK, or a source build. A typo, a stale path, or a directory that holds an incomplete SDK therefore links a different copy of the library than the one the environment selected, and the build succeeds. For a reproducible, audited or offline build that is the worst outcome: the mistake is silent.The existing test
invalid_explicit_library_directory_falls_back_to_vendorpins the current behavior deliberately, so this is an opt-in addition rather than a change.Solution
ZVEC_STRICT_LIB=1makes the explicit configuration the only accepted source. Inresolve_lib_dir, the substitution chain is skipped entirely:and
mainreports the unresolved case as an error, whatever the acquisition settings say:1or the wordtrue, the latter case-insensitively(
TRUE,True); every other value -- including an empty one and theyes/onthat othertoolchains accept -- leaves the resolution order unchanged, so it cannot be switched on by
accident.
ZVEC_PREBUILT_URL, the prebuilt cache,ZVEC_REPO_URLand the source build all sit behind the early return.ZVEC_INCLUDE_DIRresolution isdeliberately unchanged -- a strict build can still take headers from a sibling checkout, which
decides what downstream build scripts see rather than what the linker uses, so a build that must
pin headers sets
ZVEC_INCLUDE_DIRitself.DOCS_RSbuilds still return before resolutionbecause they never link.
has_zvec_liband the failure message now share one platform file-name table, so both name the same artifacts:libzvec_c_api.so,libzvec_c_api.dylib,zvec_c_api.lib(MSVC), or the MinGW.dll.a/.lib/.dllalternatives. Where more than one name is valid the failure message says "one of", so a MinGW
message cannot read as if all three were required.
ZVEC_*variable next toZVEC_LIB_DIRandZVEC_AUTO_BUILD, registered withcargo:rerun-if-env-changed.Tests
zvec-sys/tests/build_script.rsgains eight cases, using the existing temporary-directory fixture:strict_mode_requires_an_explicit_library_directoryZVEC_LIB_DIRthe script fails and names the expected file; a validvendor/libsubstitute is not consulted and is not modifiedstrict_mode_rejects_an_incomplete_directory_and_never_falls_backstrict_mode_accepts_an_explicit_library_directorystrict_mode_stays_off_for_every_other_value"",0,false,nokeep the documented fallback tovendor/libstrict_mode_never_reaches_acquisitionZVEC_AUTO_BUILD=1, a working download path and a valid substitute present, the failure is still the strict one, no download tool ran and no source checkout was createdplatform_library_names_are_honouredstrict_is_enabled_by_one_or_the_word_true_however_it_is_cased1,true,TRUE,Trueenable the mode;yes,on,2, a leading-spacetrueand the empty string do notthe_expected_names_read_as_one_of_where_several_are_validThe acquisition test keeps its clone URL pointed at a nonexistent local path, so a wrong implementation fails fast instead of fetching a repository. Disabling strict mode in the implementation makes exactly the three behavior-sensitive cases fail, so the suite discriminates rather than merely passing.
Validation
Linux x86_64,
ZVEC_LIB_DIRpointing at thezvec-prebuilt-x86_64-unknown-linux-gnuSDK from the v0.7.2 release:Real build-script runs, not only in-process tests:
Compatibility and limitations
cargo check,cargo docandcargo publishverification also fail while strict mode is on and the library is absent. That is the intended meaning of the mode; onlyDOCS_RSbuilds keep skipping resolution, as they do today.ZVEC_LIB_DIRby the same platform rule the linker uses; it does not verify ABI compatibility or the architecture of the library it finds.mainafter chore(vendor): track zvec c133f20; feat(fts)!: adapt to the embedded jieba dictionary #21:libzvec_c_apinow embeds the cppjieba dictionary, sothe build script no longer resolves or publishes one and strict mode has nothing to constrain
there. The dictionary-specific parts this branch carried (the
ZVEC_RUST_JIEBA_DICT_DIRregistration,
resolve_jieba_dict_dirand its test) are dropped in that merge.cargo fmt --check,cargo clippy -p zvec-rust-sys --all-targets -- -D warnings,cargo test -p zvec-rust-sys --test build_script(18 passed) andcargo check --workspace --all-targets.Windows.