Skip to content

fix(visibility): restrict RAFT_EXPORT to core/ and raft_runtime/ only#3019

Merged
rapids-bot[bot] merged 4 commits into
NVIDIA:mainfrom
vyasr:fix/detail_symbol_export
May 22, 2026
Merged

fix(visibility): restrict RAFT_EXPORT to core/ and raft_runtime/ only#3019
rapids-bot[bot] merged 4 commits into
NVIDIA:mainfrom
vyasr:fix/detail_symbol_export

Conversation

@vyasr

@vyasr vyasr commented May 16, 2026

Copy link
Copy Markdown
Contributor

Restrict symbol exports from libraft.so to only the public API surface:

  • include/raft/core/ (non-detail): exported via namespace RAFT_EXPORT raft
  • include/raft_runtime/: exported via RAFT_EXPORT on function declarations (lanczos_solver, rmat_rectangular_gen)
  • Everything else (linalg, matrix, random, sparse, spectral, stats, util, label, solver, comms, mr, pmr, and all detail/ namespaces): hidden

With CXX_VISIBILITY_PRESET hidden on raft_objs, this ensures only the intended public symbols are visible in the shared library, preventing symbol interposition between libcuml.so and libcuvs.so for internal raft implementation details.

Changes

  1. Remove RAFT_EXPORT from detail namespaces — prevents internal detail symbols from being exported
  2. Remove RAFT_EXPORT from all non-core directories — linalg, matrix, random, sparse, spectral, stats, util, label, solver, comms, mr, pmr no longer export symbols
  3. Remove RAFT_EXPORT from raft_runtime::matrix::select_k — this function has no .cu source in src/ and is not compiled into libraft.so (it's instantiated by downstream consumers like cuvs)

Verification

  • libraft.so builds and links cleanly
  • cuvs compiles successfully against these changes (tested distance, brute_force, cagra, select_k, sparse_distance translation units)

Contributes to https://github.com/rapidsai/build-infra/issues/53

@copy-pr-bot

copy-pr-bot Bot commented May 16, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@vyasr vyasr force-pushed the fix/detail_symbol_export branch from d4d6a90 to 8febe8b Compare May 16, 2026 20:28
@vyasr vyasr self-assigned this May 16, 2026
@vyasr vyasr added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels May 16, 2026
@vyasr vyasr force-pushed the fix/detail_symbol_export branch from 8febe8b to 0190094 Compare May 16, 2026 20:29
vyasr added a commit to vyasr/cuvs that referenced this pull request May 16, 2026
Temporarily points cuvs at vyasr/raft@fix/detail_symbol_export so CI
exercises the fix that removes RAFT_EXPORT from detail namespace
declarations in raft headers.

Changes:
- cpp/cmake/thirdparty/get_raft.cmake: RAFT_FORK=vyasr,
  RAFT_PINNED_TAG=fix/detail_symbol_export
- ci/use_conda_packages_from_prs.sh: downloads libraft conda artifacts
  from NVIDIA/raft#3019 via rapids-get-pr-artifact
- ci/use_wheels_from_prs.sh: downloads libraft wheel artifacts from
  NVIDIA/raft#3019
- All conda CI scripts (build_cpp, build_python, build_docs, build_go,
  build_java, build_rust, test_cpp, test_python): source
  use_conda_packages_from_prs.sh after conda strict channel priority
- build_wheel_libcuvs.sh: source use_wheels_from_prs.sh after
  rapids-init-pip

Revert these changes once NVIDIA/raft#3019 is merged and picked up
by the nightly.
vyasr added a commit to vyasr/cuvs that referenced this pull request May 16, 2026
Temporarily points cuvs at vyasr/raft@fix/detail_symbol_export so CI
exercises the fix that removes RAFT_EXPORT from detail namespace
declarations in raft headers.

Changes:
- cpp/cmake/thirdparty/get_raft.cmake: RAFT_FORK=vyasr,
  RAFT_PINNED_TAG=fix/detail_symbol_export
- ci/use_conda_packages_from_prs.sh: downloads libraft conda artifacts
  from NVIDIA/raft#3019 via rapids-get-pr-artifact
- ci/use_wheels_from_prs.sh: downloads libraft wheel artifacts from
  NVIDIA/raft#3019
- All conda CI scripts (build_cpp, build_python, build_docs, build_go,
  build_java, build_rust, test_cpp, test_python): source
  use_conda_packages_from_prs.sh after conda strict channel priority
- build_wheel_libcuvs.sh: source use_wheels_from_prs.sh after
  rapids-init-pip

Revert these changes once NVIDIA/raft#3019 is merged and picked up
by the nightly.
@vyasr vyasr force-pushed the fix/detail_symbol_export branch from 0190094 to 88c309e Compare May 16, 2026 20:54
@vyasr vyasr changed the base branch from main to release/26.06 May 16, 2026 21:06
vyasr added a commit to vyasr/cuvs that referenced this pull request May 16, 2026
Temporarily points cuvs at vyasr/raft@fix/detail_symbol_export so CI
exercises the fix that removes RAFT_EXPORT from detail namespace
declarations in raft headers.

Changes:
- cpp/cmake/thirdparty/get_raft.cmake: RAFT_FORK=vyasr,
  RAFT_PINNED_TAG=fix/detail_symbol_export
- ci/use_conda_packages_from_prs.sh: downloads libraft conda artifacts
  from NVIDIA/raft#3019 via rapids-get-pr-artifact
- ci/use_wheels_from_prs.sh: downloads libraft wheel artifacts from
  NVIDIA/raft#3019
- All conda CI scripts (build_cpp, build_python, build_docs, build_go,
  build_java, build_rust, test_cpp, test_python): source
  use_conda_packages_from_prs.sh after conda strict channel priority
- build_wheel_libcuvs.sh: source use_wheels_from_prs.sh after
  rapids-init-pip

Revert these changes once NVIDIA/raft#3019 is merged and picked up
by the nightly.
@aamijar

aamijar commented May 17, 2026

Copy link
Copy Markdown
Contributor

So we are reverting some of the changes from an earlier PR right? #3006

@vyasr vyasr changed the title fix(visibility): remove RAFT_EXPORT from detail namespace declarations fix(visibility): restrict RAFT_EXPORT to core/ and raft_runtime/ only May 19, 2026
@vyasr

vyasr commented May 19, 2026

Copy link
Copy Markdown
Contributor Author

So we are reverting some of the changes from an earlier PR right? #3006

Sort of. The core change in #3006 is hiding symbols by default. That behavior has not changed. However, in that first PR I was more conservative in what APIs were actually hidden by exporting lots of symbols. This PR is effectively going further by removing a lot of the explicit exports, which means that we'll be hiding even more symbols. In particular, we have removed export from all header-only parts of raft except for the core/ directory, which contains the types that are part of public APIs in other libraries and therefore need public visibility.

vyasr added a commit to vyasr/cuml that referenced this pull request May 19, 2026
…isibility)

Temporarily points cuml at the symbol visibility branches for both raft
and cuvs so CI exercises the combined changes:

- NVIDIA/raft#3019: restrict RAFT_EXPORT to core/ and raft_runtime/
- NVIDIA/cuvs#2101: add symbol visibility controls to cuvs

Changes:
- cpp/cmake/thirdparty/get_raft.cmake: FORK=vyasr,
  PINNED_TAG=fix/detail_symbol_export
- cpp/cmake/thirdparty/get_cuvs.cmake: FORK=vyasr,
  PINNED_TAG=test/raft-detail-visibility
- ci/use_conda_packages_from_prs.sh: downloads libraft + libcuvs conda
  artifacts from the respective PRs via rapids-get-pr-artifact
- ci/use_wheels_from_prs.sh: downloads libraft + libcuvs wheel artifacts
- All conda CI scripts (build_cpp, build_python, build_docs, test_cpp,
  test_python_common, test_notebooks): source
  use_conda_packages_from_prs.sh
- build_wheel_libcuml.sh: source use_wheels_from_prs.sh

Revert these changes once both PRs are merged and picked up by nightly.
@vyasr vyasr force-pushed the fix/detail_symbol_export branch from 14edb3a to ec6b596 Compare May 21, 2026 00:41
@vyasr vyasr requested review from a team as code owners May 21, 2026 00:41
@vyasr vyasr requested a review from KyleFromNVIDIA May 21, 2026 00:41
@vyasr vyasr changed the base branch from release/26.06 to main May 21, 2026 00:49
vyasr added 3 commits May 20, 2026 18:27
Prevent symbol interposition between libcuml.so and libcuvs.so by
removing RAFT_EXPORT attribute from all detail namespace blocks so
internal symbols get hidden visibility (matching CMake's
CXX_VISIBILITY_PRESET hidden on raft_objs).
Remove RAFT_EXPORT from namespace declarations in all non-core directories
(linalg, matrix, random, sparse, spectral, stats, util, label, solver,
comms, mr, pmr). With CXX_VISIBILITY_PRESET hidden on raft_objs, only
symbols in core/ (the public API surface) and raft_runtime/ (the compiled
library entry points) are now exported from libraft.so.

This prevents symbol interposition between libcuml.so and libcuvs.so for
internal raft implementation details outside core/.
…libraft.so)

select_k is declared in raft_runtime but has no corresponding .cu source
in src/ — it's an inl-style header instantiated by consumers (cuvs), not
by libraft itself. The RAFT_EXPORT annotation was a no-op.
@vyasr vyasr force-pushed the fix/detail_symbol_export branch from ec6b596 to d91b7d6 Compare May 21, 2026 03:26
@vyasr vyasr removed the request for review from a team May 21, 2026 14:39
@vyasr vyasr removed request for a team and KyleFromNVIDIA May 21, 2026 14:39
rapids-bot Bot pushed a commit to NVIDIA/cuvs that referenced this pull request May 21, 2026
Add proper symbol visibility controls to libcuvs.so, compatible with the raft visibility restrictions in NVIDIA/raft#3019.

### Motivation

With raft restricting exports to only `core/` and `raft_runtime/`, cuvs needs its own visibility controls to:
1. Prevent symbol interposition between libcuml.so and libcuvs.so
2. Export only the intended public API from libcuvs.so
3. Keep internal implementation details hidden

### Changes

- **Add `CUDA_VISIBILITY_PRESET hidden` to `cuvs_objs`** — all symbols hidden by default
- **Add `CUVS_EXPORT` to public API symbols** — mark symbols that must be visible in libcuvs.so
- **Fix NVCC compatibility** — use `struct CUVS_EXPORT` on definitions (not instantiations) for NVCC
- **Fix `__half` type visibility** — add cuda_fp16.hpp wrapper to handle type visibility across TUs
- **Fix brute_force, cagra, resize_list exports** — ensure all needed symbols are exported
- **Fix remaining linker errors** — 4 additional hidden symbols that needed export
- **Fix CI rattler-build** — restore `rapids-rattler-channel-string` in both build_cpp.sh and build_python.sh

### CI note

The `test(ci): build against vyasr/raft#3019` commit that pins raft to the visibility branch will be reverted before merge (once raft#3019 is merged to release/26.06).

Depends on NVIDIA/raft#3019

Contributes to rapidsai/build-infra#53

Authors:
  - Vyas Ramasubramani (https://github.com/vyasr)

Approvers:
  - Divye Gala (https://github.com/divyegala)

URL: #2101
@divyegala

Copy link
Copy Markdown
Contributor

/merge

@rapids-bot rapids-bot Bot merged commit 5361e5e into NVIDIA:main May 22, 2026
79 checks passed
@vyasr vyasr deleted the fix/detail_symbol_export branch May 22, 2026 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvement / enhancement to an existing function non-breaking Non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants