Skip to content

Use rapids_cmake_support_conda_env so executables link in any conda env#1275

Draft
rgsl888prabhu wants to merge 2 commits into
NVIDIA:mainfrom
rgsl888prabhu:fix/cmake-conda-env-support
Draft

Use rapids_cmake_support_conda_env so executables link in any conda env#1275
rgsl888prabhu wants to merge 2 commits into
NVIDIA:mainfrom
rgsl888prabhu:fix/cmake-conda-env-support

Conversation

@rgsl888prabhu
Copy link
Copy Markdown
Collaborator

libcuopt.so links gRPC/Protobuf/Abseil as PRIVATE, so their SONAMEs end up in libcuopt.so's DT_NEEDED but aren't propagated to consumers (cuopt_cli, cuopt_grpc_server, all tests). When ld links those targets it walks libcuopt.so's DT_NEEDED to resolve transitive symbols and needs $CONDA_PREFIX/lib on its search path. Today this only works when the conda env was created with the conda-forge compiler shims (cxx-compiler / gxx_linux-64 / gcc_linux-64), whose activation scripts export LDFLAGS=... -Wl,-rpath-link,$CONDA_PREFIX/lib -Wl,--allow-shlib-undefined .... Envs without those packages fail at link time on cuopt_cli and ~30 test executables, even though libcuopt.so itself builds in the same build.sh run.

Adopts the standard RAPIDS pattern (rapids_cmake_support_conda_env, already used by cudf/cuml/raft/rmm). $<BUILD_INTERFACE:> keeps conda_env out of the installed cuopt CMake config; no-op when $CONDA_PREFIX is unset (wheel CI).

Checklist

  • I am familiar with the Contributing Guidelines.
  • Testing
    • New or existing tests cover these changes
    • Added tests
    • Created an issue to follow-up
    • NA
  • Documentation
    • The documentation is up to date with these changes
    • Added new documentation
    • NA

libcuopt.so links gRPC, Protobuf, and Abseil as PRIVATE deps, so their
SONAMEs end up in libcuopt.so's DT_NEEDED but are not propagated to
consumer targets (cuopt_cli, cuopt_grpc_server, all tests). When ld
links those consumers it walks libcuopt.so's DT_NEEDED to validate
transitive symbol references and needs to locate libgrpc++.so.*,
libprotobuf.so.*, libabsl_*.so.* on disk.

Today this works only when the surrounding shell's LDFLAGS already
carries -Wl,-rpath-link,$CONDA_PREFIX/lib (and/or
-Wl,--allow-shlib-undefined), which is exported by the conda-forge
compiler activation scripts shipped with cxx-compiler / gxx_linux-64 /
gcc_linux-64. Conda envs missing those packages fail to link
cuopt_cli and ~30 test executables, even though libcuopt.so itself
builds successfully in the same run.

Adopt the standard RAPIDS pattern (cudf, cuml, raft, rmm) by wiring
$CONDA_PREFIX/lib into the build via rapids_cmake_support_conda_env,
applied through link_libraries() with a BUILD_INTERFACE generator
expression so the dependency is not recorded in the exported
cuopt-config.cmake.

- No-op when $CONDA_PREFIX is unset (e.g. manylinux wheel CI).
- BUILD_INTERFACE keeps conda_env out of the installed cuopt CMake
  config; downstream find_package(cuopt) consumers are unaffected.
- -L is link-time only; DT_NEEDED, INSTALL_RPATH and the wheel
  binaries are bit-identical to today.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Ramakrishna Prabhu <ramakrishnap@nvidia.com>
@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented May 21, 2026

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@rgsl888prabhu rgsl888prabhu self-assigned this May 21, 2026
@rgsl888prabhu rgsl888prabhu added non-breaking Introduces a non-breaking change improvement Improves an existing functionality labels May 21, 2026
Initial attempt used link_libraries($<BUILD_INTERFACE:conda_env>), but
CMake's export-validity check inspects INTERFACE_LINK_LIBRARIES before
generator expressions are evaluated and still requires conda_env to be
in an export set. The same check also failed on FetchContent-pulled
papilo-core, which inherited conda_env via the directory-level command.

Switch to the cudf pattern: drop the directory-level link, install
conda_env into the cuopt-exports set, and add $<TARGET_NAME_IF_EXISTS:
conda_env> per-target on cuopt, cuopt_cli, cuopt_grpc_server, and the
ConfigureTest helper.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Ramakrishna Prabhu <ramakrishnap@nvidia.com>
@rgsl888prabhu
Copy link
Copy Markdown
Collaborator Author

/ok to test ea972dc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improves an existing functionality non-breaking Introduces a non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant