Skip to content

build: don't install libcuopt into conda env by default - #1650

Open
ramakrishnap-nv wants to merge 8 commits into
mainfrom
no-default-conda-install
Open

build: don't install libcuopt into conda env by default#1650
ramakrishnap-nv wants to merge 8 commits into
mainfrom
no-default-conda-install

Conversation

@ramakrishnap-nv

@ramakrishnap-nv ramakrishnap-nv commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • build.sh previously ran cmake --install into \$CONDA_PREFIX on every build. Agents or developers that rebuilt without reinstalling (e.g. called ninja directly) would run the stale installed library rather than freshly compiled code — a silent mismatch with no easy diagnosis path.
  • Default is now build-only. Pass --install to explicitly opt in to installing into the active conda environment.
  • The old -n (no-install) flag is removed since build-only is now the default.
  • The separate make ninja-build code path (only reachable via -n) is replaced by a single cmake --build call with an optional --target install.
  • The conda recipe for libcuopt already passed -n explicitly; that flag is dropped since it is now redundant — the recipe's separate cmake --install cpp/build output step is unaffected.

🤖 Generated with Claude Code

`build.sh` previously ran `cmake --install` into `$CONDA_PREFIX` on
every build, so agents or developers that called `ninja` directly (or
rebuilt without reinstalling) would run stale installed libraries rather
than their freshly compiled code.

Change the default to build-only and add `--install` to opt in when an
explicit conda-env install is wanted.  The `-n` (no-install) flag is
removed since it is now the default behaviour.

Also simplify the cmake invocation: the separate `make ninja-build`
code path that was only reachable via `-n` is replaced by a single
`cmake --build` call with an optional `--target install`.

The conda recipe for libcuopt already passed `-n` explicitly; that flag
is dropped since it is now redundant.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Ramakrishna Prabhu <ramakrishnap@nvidia.com>
@ramakrishnap-nv
ramakrishnap-nv requested review from a team as code owners July 31, 2026 18:59
The previous commit accidentally removed the `make ninja-build` path
that was used for build-only (no-install) invocations. Restore it as
the default path; the `--install` flag takes the cmake install path.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Ramakrishna Prabhu <ramakrishnap@nvidia.com>
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

build.sh now skips installation by default and uses --install to enable it. The libcuopt recipe removes the obsolete -n option. Documentation describes the updated build behavior. Version logging now includes the containing shared library path.

Changes

Build and version behavior

Layer / File(s) Summary
Build flag and default behavior
build.sh
build.sh replaces -n with --install. Builds do not install by default.
Conditional build execution
build.sh
The script uses the default build path without installation and invokes the install target when --install is set.
Package and documentation integration
conda/recipes/libcuopt/recipe.yaml, skills/cuopt-developer/references/build_and_test.md, CONTRIBUTING.md
The recipe removes -n. The documentation describes non-installing default builds and explicit installation.
Shared library path logging
cpp/src/utilities/version_info.cpp
print_version_info resolves and logs the shared library path, or "<unknown>" when unavailable.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: kaatish, rg20, jameslamb, tmckayus

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: builds no longer install libcuopt into the conda environment by default.
Description check ✅ Passed The description accurately explains the build behavior change, the new --install flag, removal of -n, and the conda recipe update.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch no-default-conda-install

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

CI Test Summary

✅ All 31 test job(s) passed.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Ramakrishna Prabhu <ramakrishnap@nvidia.com>
@ramakrishnap-nv ramakrishnap-nv self-assigned this Jul 31, 2026
@ramakrishnap-nv ramakrishnap-nv added breaking Introduces a breaking change improvement Improves an existing functionality labels Jul 31, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@build.sh`:
- Around line 391-395: Add regression tests covering the build.sh mode
selection: verify the default invocation runs the ninja-build target without
installation, and verify --install invokes the CMake install target. Place the
tests in the appropriate existing test framework and assert the $CONDA_PREFIX
side-effect contract.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: bde3be73-b4fe-4052-aea2-04411db0b9af

📥 Commits

Reviewing files that changed from the base of the PR and between 8d245ad and 024cd08.

📒 Files selected for processing (1)
  • build.sh

Comment thread build.sh Outdated
Comment on lines 391 to 395
elif hasArg --install; then
cmake --build "${LIBCUOPT_BUILD_DIR}" --target ${INSTALL_TARGET} ${VERBOSE_FLAG} ${JFLAG}
else
# Manual make invocation to start its jobserver
make ${JFLAG} -C "${REPODIR}/cpp" LIBCUOPT_BUILD_DIR="${LIBCUOPT_BUILD_DIR}" VERBOSE_FLAG="${VERBOSE_FLAG}" PARALLEL_LEVEL="${PARALLEL_LEVEL}" ninja-build

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add regression coverage for both build modes.

Verify that a default invocation runs ninja-build without installation and that --install invokes the CMake install target. This protects the $CONDA_PREFIX side-effect contract.

As per coding guidelines, contributors must add unit tests for code changes, using GoogleTest examples under cpp/src/tests for C/C++ and pytest examples under python/cuopt/cuopt/tests for Python.

🧰 Tools
🪛 Shellcheck (0.11.0)

[info] 392-392: Double quote to prevent globbing and word splitting.

(SC2086)


[info] 395-395: Double quote to prevent globbing and word splitting.

(SC2086)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@build.sh` around lines 391 - 395, Add regression tests covering the build.sh
mode selection: verify the default invocation runs the ninja-build target
without installation, and verify --install invokes the CMake install target.
Place the tests in the appropriate existing test framework and assert the
$CONDA_PREFIX side-effect contract.

Source: Coding guidelines

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@CONTRIBUTING.md`:
- Around line 177-178: Update the installation-path documentation around the
--install description to refer to the `$PREFIX` environment variable instead of
`$INSTALL_PREFIX`, matching build.sh’s supported configuration while preserving
the existing `$CONDA_PREFIX` fallback wording.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ed5a9bcb-77bd-4389-9873-ce84833be922

📥 Commits

Reviewing files that changed from the base of the PR and between 024cd08 and 935f423.

📒 Files selected for processing (1)
  • CONTRIBUTING.md

Comment thread CONTRIBUTING.md Outdated
- CONTRIBUTING.md referenced \$INSTALL_PREFIX but build.sh derives the
  install prefix from \$PREFIX (falling back to \$CONDA_PREFIX); use the
  correct variable name
- Double-quote \$VERBOSE_FLAG and \$JFLAG in the cmake/make invocations
  to silence shellcheck SC2086 and prevent word splitting

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Ramakrishna Prabhu <ramakrishnap@nvidia.com>
Adds the resolved library path to the version line that cuopt_cli prints
at the start of every solve. Makes it immediately visible which library
is actually loaded — build-dir or conda-installed.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Ramakrishna Prabhu <ramakrishnap@nvidia.com>
@ramakrishnap-nv
ramakrishnap-nv requested a review from a team as a code owner July 31, 2026 19:37
@ramakrishnap-nv
ramakrishnap-nv requested review from kaatish and rg20 July 31, 2026 19:37

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
cpp/src/utilities/version_info.cpp (1)

178-181: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Use a data anchor for the dladdr lookup.

The current call converts &print_version_info from a function pointer to void*. With position-independent code, dladdr can resolve a PLT entry and report the wrong object. Use a function-local static data object, such as static constexpr char library_anchor = 0;, and pass &library_anchor to dladdr. Add a C++ test for the reported library path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cpp/src/utilities/version_info.cpp` around lines 178 - 181, Update the dladdr
lookup in print_version_info to use a function-local static data anchor, such as
library_anchor, instead of converting the function pointer to void*. Preserve
the existing "<unknown>" fallback and add a C++ test that verifies the reported
library path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cpp/src/utilities/version_info.cpp`:
- Around line 178-189: Add GoogleTest coverage under cpp/src/tests for the
library-path resolution used by print_version_info, verifying both successful
dladdr lookup and the "<unknown>" fallback. If print_version_info depends on
unavailable CUDA or logging setup, extract the lookup into a small testable
helper and test that helper without changing the existing logging behavior.
- Around line 15-16: Update the CMake target configuration for the targets
containing version_info.cpp to define _GNU_SOURCE and link ${CMAKE_DL_LIBS};
ensure the compile definition enables Dl_info/dladdr declarations and the loader
library is applied to every affected target.

---

Nitpick comments:
In `@cpp/src/utilities/version_info.cpp`:
- Around line 178-181: Update the dladdr lookup in print_version_info to use a
function-local static data anchor, such as library_anchor, instead of converting
the function pointer to void*. Preserve the existing "<unknown>" fallback and
add a C++ test that verifies the reported library path.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 94a672d2-7897-4134-90ac-3ccf6a3e3533

📥 Commits

Reviewing files that changed from the base of the PR and between f85de73 and 2bdcf0c.

📒 Files selected for processing (1)
  • cpp/src/utilities/version_info.cpp

Comment thread cpp/src/utilities/version_info.cpp Outdated
Comment on lines +15 to +16
#include <dlfcn.h>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

rg -n -C 5 \
  'CMAKE_DL_LIBS|_GNU_SOURCE|target_link_libraries|dladdr|dlfcn\.h' \
  --glob 'CMakeLists.txt' \
  --glob '*.cmake' \
  --glob '*.cpp' \
  --glob '*.hpp' \
  --glob '*.h' \
  .

Repository: NVIDIA/cuopt

Length of output: 18267


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- version_info.cpp ---'
sed -n '1,30p;165,195p' cpp/src/utilities/version_info.cpp

printf '%s\n' '--- cuopt target configuration ---'
sed -n '640,785p' cpp/CMakeLists.txt

printf '%s\n' '--- feature and linker definitions ---'
rg -n -C 4 \
  '_GNU_SOURCE|CMAKE_CXX_STANDARD|add_compile_definitions|target_compile_definitions|target_compile_options|CMAKE_DL_LIBS|dladdr|Dl_info' \
  --glob 'CMakeLists.txt' \
  --glob '*.cmake' \
  --glob '*.cpp' \
  --glob '*.hpp' \
  --glob '*.h' \
  .

Repository: NVIDIA/cuopt

Length of output: 19298


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- CUOPT_CXX_FLAGS definitions ---'
rg -n -C 5 \
  'CUOPT_CXX_FLAGS|CMAKE_CXX_FLAGS|CXXFLAGS|_GNU_SOURCE|CMAKE_DL_LIBS' \
  --glob 'CMakeLists.txt' \
  --glob '*.cmake' \
  --glob '*.yaml' \
  --glob '*.yml' \
  --glob '*.sh' \
  .

printf '%s\n' '--- dlfcn.h feature guards ---'
for header in /usr/include/dlfcn.h /usr/include/*/dlfcn.h; do
  if [ -f "$header" ]; then
    printf '%s\n' "--- $header ---"
    rg -n -C 3 'Dl_info|dladdr|__USE_GNU|_GNU_SOURCE' "$header"
  fi
done

Repository: NVIDIA/cuopt

Length of output: 11664


Define the GNU feature macro and link the dynamic loader.

version_info.cpp uses GNU-only Dl_info and dladdr, but the build defines neither _GNU_SOURCE nor ${CMAKE_DL_LIBS}. Add the feature macro as a target compile definition and link ${CMAKE_DL_LIBS} to the targets that contain these objects. Linux builds can otherwise fail during compilation or linking.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cpp/src/utilities/version_info.cpp` around lines 15 - 16, Update the CMake
target configuration for the targets containing version_info.cpp to define
_GNU_SOURCE and link ${CMAKE_DL_LIBS}; ensure the compile definition enables
Dl_info/dladdr declarations and the loader library is applied to every affected
target.

Comment thread cpp/src/utilities/version_info.cpp Outdated
Comment on lines +178 to +189
Dl_info dl_info{};
const char* lib_path = (dladdr(reinterpret_cast<void*>(&print_version_info), &dl_info) && dl_info.dli_fname)
? dl_info.dli_fname
: "<unknown>";
CUOPT_LOG_INFO("cuOpt version: %d.%d.%d, git hash: %s, host arch: %s, device archs: %s, lib: %s",
CUOPT_VERSION_MAJOR,
CUOPT_VERSION_MINOR,
CUOPT_VERSION_PATCH,
CUOPT_GIT_COMMIT_HASH,
CUOPT_CPU_ARCHITECTURE,
CUOPT_CUDA_ARCHITECTURES);
CUOPT_CUDA_ARCHITECTURES,
lib_path);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add GoogleTest coverage for the new library-path logging.

Add a test under cpp/src/tests for the successful path lookup and the "<unknown>" fallback. Extract the lookup into a small testable helper when print_version_info requires unavailable CUDA or logging setup. No test change is included in the supplied context.

As per coding guidelines, C++ changes must add unit tests with GoogleTest under cpp/src/tests.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cpp/src/utilities/version_info.cpp` around lines 178 - 189, Add GoogleTest
coverage under cpp/src/tests for the library-path resolution used by
print_version_info, verifying both successful dladdr lookup and the "<unknown>"
fallback. If print_version_info depends on unavailable CUDA or logging setup,
extract the lookup into a small testable helper and test that helper without
changing the existing logging behavior.

Source: Coding guidelines

ramakrishnap-nv and others added 2 commits July 31, 2026 14:47
conda's \$LDFLAGS injects -rpath,\$CONDA_PREFIX/lib into every linked
binary, which means a previously installed libcuopt.so in the conda env
always shadows the freshly compiled build-dir copy regardless of RUNPATH
ordering. When building without --install, explicitly remove any
libcuopt*.so* from the conda prefix so the build-dir library is the
only copy available.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Ramakrishna Prabhu <ramakrishnap@nvidia.com>
- Remove dladdr/lib-path debug print added during local testing
- Fix shellcheck SC2010: replace ls|grep with compgen glob check

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Ramakrishna Prabhu <ramakrishnap@nvidia.com>

@mlubin mlubin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe hold off on landing until after 26.08, we don't want broken build scripts at release time.

@ramakrishnap-nv ramakrishnap-nv added the do not merge Do not merge if this flag is set label Jul 31, 2026
The unconditional removal broke conda-python-build: rattler-build
legitimately installs libcuopt into the host prefix before running
./build.sh cuopt, and we were deleting it immediately.

Scope the removal to invocations that actually rebuild libcuopt
(default/libcuopt/cuopt_grpc_server targets); Python-only builds
are left untouched.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Ramakrishna Prabhu <ramakrishnap@nvidia.com>
@rg20
rg20 removed the request for review from kaatish August 3, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Introduces a breaking change do not merge Do not merge if this flag is set improvement Improves an existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants