feat: support system-installed OpenBLAS via VSAG_USE_SYSTEM_DEPS#2117
Conversation
Introduce a small policy framework (VSAG_USE_SYSTEM_DEPS=AUTO/ON/OFF with per-dependency VSAG_USE_SYSTEM_<DEP> overrides) and wire only OpenBLAS into it. Additional dependencies will be migrated in follow-up changes. For OpenBLAS the resolution order is: 1. an existing OpenBLAS::OpenBLAS target, 2. find_package(OpenBLAS CONFIG), 3. a manual search for libopenblas + cblas.h / lapacke.h, 4. the bundled ExternalProject build (AUTO / OFF only). The legacy USE_SYSTEM_OPENBLAS option keeps its previous "try system, fall back to bundled" semantics for backward compatibility. Signed-off-by: Xiangyu Wang <wxy407827@antgroup.com> Assisted-by: ClaudeCode:claude-opus-4.7
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 Require kind labelWonderful, this rule succeeded.
🟢 Require version labelWonderful, this rule succeeded.
🟢 Require linked issue for feature/bug PRsWonderful, this rule succeeded.
|
There was a problem hiding this comment.
Code Review
This pull request introduces a unified mechanism for managing system third-party dependencies in VSAG, replacing the legacy USE_SYSTEM_OPENBLAS option with a more flexible VSAG_USE_SYSTEM_DEPS policy (supporting AUTO, ON, and OFF modes) and per-dependency overrides like VSAG_USE_SYSTEM_OPENBLAS. It updates the OpenBLAS configuration to check for pre-existing targets, use find_package in CONFIG mode, or perform a manual search. The review feedback highlights that using NO_DEFAULT_PATH in the manual search for OpenBLAS and LAPACKE libraries restricts CMake from searching standard system locations on other architectures or respecting user-specified paths (like CMAKE_PREFIX_PATH). Removing NO_DEFAULT_PATH is recommended to improve portability.
There was a problem hiding this comment.
Pull request overview
Adds a small CMake policy framework to optionally reuse system-provided third-party dependencies (starting with OpenBLAS), while keeping the legacy USE_SYSTEM_OPENBLAS option working with its prior “try system, fall back to bundled” behavior.
Changes:
- Introduce
VSAG_USE_SYSTEM_DEPS(AUTO/ON/OFF) plus per-dependency overrides likeVSAG_USE_SYSTEM_OPENBLAS. - Update OpenBLAS resolution to prefer an existing
OpenBLAS::OpenBLAStarget /find_package(OpenBLAS CONFIG)before falling back to a manual search, then bundled build when allowed. - Document the new system-deps options and the OpenBLAS resolution order.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| extern/openblas/openblas.cmake | Implements policy-driven system OpenBLAS discovery and fallback to bundled build. |
| DEVELOPMENT.md | Documents new system dependency policy options and OpenBLAS resolution order. |
| cmake/VSAGOptions.cmake | Adds cache options for global and OpenBLAS-specific system-deps policies. |
| cmake/VSAGHelpers.cmake | Adds helper functions to resolve/validate policies and fail with actionable messages. |
- Drop NO_DEFAULT_PATH from the manual OpenBLAS / LAPACKE search so CMake
also consults CMAKE_PREFIX_PATH and standard multiarch locations on less
common architectures, after VSAG's curated path list (gemini-code-assist).
- Re-publish BLAS_LIBRARIES as a cache STRING so superbuild / downstream
consumers see it on both BLAS backends, matching MKL's behaviour (Copilot).
- Clarify in DEVELOPMENT.md that the legacy USE_SYSTEM_OPENBLAS switch maps
to AUTO ("try system, fall back to bundled"), not ON (Copilot).
Signed-off-by: Xiangyu Wang <wxy407827@antgroup.com>
Assisted-by: ClaudeCode:claude-opus-4.7
Repoint every x86 CI job at the appropriate variant tag introduced in the previous PR and turn on `-DUSE_SYSTEM_OPENBLAS=ON` for the OpenBLAS-backed jobs so they reuse the `libopenblas-dev` package shipped in `vsaglib/vsag:ci-x86-openblas` instead of rebuilding OpenBLAS from source on every run. Image routing: * `pr-ci.yml`, `coverage.yml`, `lint.yml`, `check_compatibility.yml`, `performance.yml`, `generate_old_version_index.yml` → `vsaglib/vsag:ci-x86-openblas`. * `asan_build_and_test.yml`, `tsan_build_and_test.yml`, `asan_with_simd_option.yml`, and the SIMD / TSAN matrices in `daily_test.yml` → `vsaglib/vsag:ci-x86-mkl` (these jobs already build with `VSAG_ENABLE_INTEL_MKL=ON`). * Daily x86 ASan in `daily_test.yml` uses the `-openblas` image but intentionally does NOT set `USE_SYSTEM_OPENBLAS`, so it keeps exercising `ExternalProject_Add(openblas)` end-to-end — that is now the dedicated guard for the from-source build path. `USE_SYSTEM_OPENBLAS=ON` is forwarded via `EXTRA_DEFINED` (existing Makefile plumbing) rather than introducing a new `make` flag, so this change does not touch `Makefile` and does not collide with the in-flight `VSAG_USE_SYSTEM_OPENBLAS` CMake option being added in antgroup#2117. CircleCI's `prepare_env_and_create_swap_file` step now also installs `liblapacke-dev` so CMake's `find_path(LAPACKE_INCLUDE NAMES lapacke.h)` probe succeeds against the system OpenBLAS. Release artifacts (`scripts/release/dist.sh`, `docker/Dockerfile.dist_*x86`) and `make pyvsag` are intentionally not changed: they continue to build OpenBLAS from source and statically link it. Refs: antgroup#2118 Signed-off-by: Xiangyu Wang <wxy407827@antgroup.com> Assisted-by: OpenCode:claude-opus-4.7
Repoint every x86 CI job at the appropriate variant tag introduced in the previous PR and turn on `-DUSE_SYSTEM_OPENBLAS=ON` for the OpenBLAS-backed jobs so they reuse the `libopenblas-dev` package shipped in `vsaglib/vsag:ci-x86-openblas` instead of rebuilding OpenBLAS from source on every run. Image routing: * `pr-ci.yml`, `coverage.yml`, `lint.yml`, `check_compatibility.yml`, `performance.yml`, `generate_old_version_index.yml` → `vsaglib/vsag:ci-x86-openblas`. * `asan_build_and_test.yml`, `tsan_build_and_test.yml`, `asan_with_simd_option.yml`, and the SIMD / TSAN matrices in `daily_test.yml` → `vsaglib/vsag:ci-x86-mkl` (these jobs already build with `VSAG_ENABLE_INTEL_MKL=ON`). * Daily x86 ASan in `daily_test.yml` uses the `-openblas` image but intentionally does NOT set `USE_SYSTEM_OPENBLAS`, so it keeps exercising `ExternalProject_Add(openblas)` end-to-end — that is now the dedicated guard for the from-source build path. `USE_SYSTEM_OPENBLAS=ON` is forwarded via `EXTRA_DEFINED` (existing Makefile plumbing) rather than introducing a new `make` flag, so this change does not touch `Makefile` and does not collide with the in-flight `VSAG_USE_SYSTEM_OPENBLAS` CMake option being added in antgroup#2117. CircleCI's `prepare_env_and_create_swap_file` step now also installs `liblapacke-dev` so CMake's `find_path(LAPACKE_INCLUDE NAMES lapacke.h)` probe succeeds against the system OpenBLAS. Release artifacts (`scripts/release/dist.sh`, `docker/Dockerfile.dist_*x86`) and `make pyvsag` are intentionally not changed: they continue to build OpenBLAS from source and statically link it. Refs: antgroup#2118 Signed-off-by: Xiangyu Wang <wxy407827@antgroup.com> Assisted-by: OpenCode:claude-opus-4.7
Repoint every x86 CI job at the BLAS-variant image introduced in the previous PR and pass `-DUSE_SYSTEM_OPENBLAS=ON` (via the existing `EXTRA_DEFINED` Makefile knob) to the OpenBLAS-backed jobs so they reuse the pre-installed `libopenblas-dev` instead of rebuilding OpenBLAS from source on every run. Routing: * `pr-ci`, `coverage`, `lint`, `check_compatibility`, `performance`, `generate_old_version_index` → `ci-x86-openblas`. All except `generate_old_version_index` also set `USE_SYSTEM_OPENBLAS=ON`; the latter builds historical release tags whose CMake does not understand the flag, so the source-build path is kept there. * `asan_build_and_test`, `tsan_build_and_test`, `asan_with_simd_option`, daily SIMD / TSAN → `ci-x86-mkl` (these jobs already build with `VSAG_ENABLE_INTEL_MKL=ON`). * Daily x86 ASan → `ci-x86-openblas` but deliberately leaves `USE_SYSTEM_OPENBLAS` unset, so `ExternalProject_Add(openblas)` keeps getting exercised end-to-end as the dedicated guard for the from-source build path. CircleCI's `prepare_env_and_create_swap_file` step also installs `liblapacke-dev` so CMake's `find_path(LAPACKE_INCLUDE NAMES lapacke.h)` probe succeeds against the system OpenBLAS. Forwarding `USE_SYSTEM_OPENBLAS` via `EXTRA_DEFINED` keeps `Makefile` untouched and avoids colliding with the in-flight `VSAG_USE_SYSTEM_OPENBLAS` CMake option in antgroup#2117. Release artifacts (`scripts/release/dist.sh`, `docker/Dockerfile.dist_*x86`) and `make pyvsag` are unchanged and still build OpenBLAS from source. Refs: antgroup#2118 Signed-off-by: Xiangyu Wang <wxy407827@antgroup.com> Assisted-by: OpenCode:claude-opus-4.7
Repoint every x86 CI job at the BLAS-variant image introduced in the previous PR and pass `-DUSE_SYSTEM_OPENBLAS=ON` (via the existing `EXTRA_DEFINED` Makefile knob) to the OpenBLAS-backed jobs so they reuse the pre-installed `libopenblas-dev` instead of rebuilding OpenBLAS from source on every run. Routing: * `pr-ci`, `coverage`, `lint`, `check_compatibility`, `performance`, `generate_old_version_index` → `ci-x86-openblas`. All except `generate_old_version_index` also set `USE_SYSTEM_OPENBLAS=ON`; the latter builds historical release tags whose CMake does not understand the flag, so the source-build path is kept there. * `asan_build_and_test`, `tsan_build_and_test`, `asan_with_simd_option`, daily SIMD / TSAN → `ci-x86-mkl` (these jobs already build with `VSAG_ENABLE_INTEL_MKL=ON`). * Daily x86 ASan → `ci-x86-openblas` but deliberately leaves `USE_SYSTEM_OPENBLAS` unset, so `ExternalProject_Add(openblas)` keeps getting exercised end-to-end as the dedicated guard for the from-source build path. CircleCI's `prepare_env_and_create_swap_file` step also installs `liblapacke-dev` so CMake's `find_path(LAPACKE_INCLUDE NAMES lapacke.h)` probe succeeds against the system OpenBLAS. Forwarding `USE_SYSTEM_OPENBLAS` via `EXTRA_DEFINED` keeps `Makefile` untouched and avoids colliding with the in-flight `VSAG_USE_SYSTEM_OPENBLAS` CMake option in antgroup#2117. Release artifacts (`scripts/release/dist.sh`, `docker/Dockerfile.dist_*x86`) and `make pyvsag` are unchanged and still build OpenBLAS from source. Refs: antgroup#2118 Signed-off-by: Xiangyu Wang <wxy407827@antgroup.com> Assisted-by: OpenCode:claude-opus-4.7
Summary
VSAG_USE_SYSTEM_DEPS=AUTO/ON/OFF, with per-dependencyVSAG_USE_SYSTEM_<DEP>overrides) incmake/VSAGOptions.cmakeandcmake/VSAGHelpers.cmake.USE_SYSTEM_OPENBLAS=ONswitch working with its previous "try system, fall back to bundled" semantics — no behavioural regression for current users.This is a focused replacement for #1958, which tried to migrate all bundled dependencies at once and accumulated 36 files / +638 LoC of churn. Here only 4 files change.
Resolution order for OpenBLAS
When the resolved policy is not
OFF, the build resolves OpenBLAS in this order and stops at the first hit:OpenBLAS::OpenBLAStarget already defined by a parent project,find_package(OpenBLAS CONFIG),libopenblaspluscblas.h/lapacke.hunder common system prefixes,ExternalProject_Addbuild (AUTO/OFFonly;ONfails configuration here).Test plan
Local CMake configure + build smoke tests (no system OpenBLAS installed on the dev box):
cmake -S . -B build -DENABLE_LIBAIO=OFF— AUTO policy falls back to the bundled OpenBLAS,cmake --build build --target vsagsucceeds end-to-end.cmake -S . -B build -DENABLE_LIBAIO=OFF -DVSAG_USE_SYSTEM_OPENBLAS=ON— fails configuration with the expected actionable error fromvsag_fail_missing_system_dep.cmake -S . -B build -DENABLE_LIBAIO=OFF -DVSAG_USE_SYSTEM_OPENBLAS=OFF— forces the bundled build.cmake -S . -B build -DENABLE_LIBAIO=OFF -DVSAG_USE_SYSTEM_DEPS=OFF— global override forces bundled build.cmake -S . -B build -DENABLE_LIBAIO=OFF -DUSE_SYSTEM_OPENBLAS=ON(legacy switch) — falls back to bundled (no FATAL), matching pre-change behaviour.Notes
System Deps Smokejob once we have more than one dependency to exercise.find_package(OpenBLAS CONFIG)/OpenBLAS::OpenBLASpaths are mirrored from the previously CI-validated logic in feat: support external third-party dependencies #1958, with the reviewer fixes folded in (no double-defined imported targets, noFORCEon cache variables).Closes: #2116
Refs: #1949
🤖 Generated with Claude Code