Skip to content

Add symbol visibility checks#1215

Draft
bdice wants to merge 4 commits into
NVIDIA:mainfrom
bdice:fix-symbol-visibility
Draft

Add symbol visibility checks#1215
bdice wants to merge 4 commits into
NVIDIA:mainfrom
bdice:fix-symbol-visibility

Conversation

@bdice
Copy link
Copy Markdown
Contributor

@bdice bdice commented May 14, 2026

Summary

  • Adds a ci/check_symbols.sh exported-symbol guard modeled on cuDF, with cuOpt-specific forbidden internal namespace patterns.
  • Wires the symbol check into the libcuopt conda recipe after installing libmps_parser and libcuopt.
  • Starts hidden-by-default symbol visibility treatment by adding export macros for libcuopt C API and libmps_parser parser/writer APIs.

Status

This is intentionally opened as a draft. The new guard is useful, but libcuopt.so still exports CUB/Thrust/RAFT/RMM and cuOpt detail symbols after the initial hidden-visibility pass.

Validation

  • cmake --build /home/coder/cuopt/cpp/build/latest --target mps_parser cuopt -j 8 passed.
  • ./ci/check_symbols.sh /home/coder/cuopt/cpp/build/latest/libmps_parser/libmps_parser.so passed.
  • ./ci/check_symbols.sh /home/coder/cuopt/cpp/build/latest/libcuopt.so currently fails as expected; first failing pattern is cub:: with 1910 matches in the rebuilt library.
  • C API exports remain visible in the rebuilt libcuopt.so (cuOptCreateProblem, cuOptGetFloatSize, cuOptSolve, cuOptDestroySolution).

References

Signed-off-by: Bradley Dice <bdice@bradleydice.com>
@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented May 14, 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.

Signed-off-by: Bradley Dice <bdice@bradleydice.com>
@bdice
Copy link
Copy Markdown
Contributor Author

bdice commented May 14, 2026

Update: split the visibility work from the CUDA template-stub work.

Committed a4664278 with visibility-only fixes:

  • Keeps -static-global-template-stub=false in place for now; no .cu include workaround remains.
  • Applies hidden visibility to libcuopt only when BUILD_TESTS=OFF, so package builds get hidden symbols while developer/test builds can continue linking internal tests.
  • Adds explicit exports for installed/public C++ surfaces needed by cuopt_cli, cuopt_grpc_server, gRPC mappers/client, CPU problem/solution types, settings, and mps_parser public classes.

Validation:

  • build-cuopt-cpp -j0 passes.
  • build-cuopt-cpp -j0 -DBUILD_TESTS=OFF --target cuopt cuopt_cli cuopt_grpc_server passes.
  • ./ci/check_symbols.sh cpp/build/latest/libmps_parser/libmps_parser.so passes.
  • ./ci/check_symbols.sh cpp/build/latest/libcuopt.so still fails on cub:: in the package-style build; that is the separate CUDA template-stub issue to fix next without including .cu files.

Signed-off-by: Bradley Dice <bdice@bradleydice.com>
@bdice
Copy link
Copy Markdown
Contributor Author

bdice commented May 14, 2026

Update: fixed the CUDA template-stub portion without including .cu files.

Committed e04db5c5:

  • Removed -static-global-template-stub=false.
  • Added host wrapper functions around cross-TU templated CUDA kernels so kernel addresses are taken/launched in the same .cu that defines them.
  • Updated feasibility-jump and insertion/ejection launch sites to use wrappers.
  • No .cu source includes were added.

Reference pattern from rapidsai/cudf#14726: CUDA kernels should have internal/hidden linkage rather than relying on externally visible template stubs.

Validation:

  • build-cuopt-cpp -j0 -DBUILD_TESTS=OFF --target cuopt cuopt_cli cuopt_grpc_server passes.
  • build-cuopt-cpp -j0 passes.
  • Hidden package build symbol counts: cub:: 0, thrust:: 0.
  • ./ci/check_symbols.sh cpp/build/latest/libmps_parser/libmps_parser.so passes.
  • ./ci/check_symbols.sh cpp/build/latest/libcuopt.so now advances past cub::/thrust:: and fails on raft::; that is the next remaining visibility category.

Signed-off-by: Bradley Dice <bdice@bradleydice.com>
@bdice
Copy link
Copy Markdown
Contributor Author

bdice commented May 14, 2026

Update: refactored C++ exports to namespace-level annotations in 2563e8fd.

Details:

  • Kept the C API function-level CUOPT_EXPORT annotations.
  • Changed public C++ API headers to use namespace-level export syntax compatible with GCC, e.g. namespace cuopt { namespace CUOPT_EXPORT linear_programming { ... } }.
  • Changed public mps-parser headers to namespace cuopt { namespace MPS_PARSER_EXPORT mps_parser { ... } }.
  • Removed most scattered class/function-level exports from those C++ declarations.

Validation after this refactor:

  • build-cuopt-cpp -j0 -DBUILD_TESTS=OFF --target cuopt cuopt_cli cuopt_grpc_server passes.
  • build-cuopt-cpp -j0 passes.
  • Hidden package symbol counts remain cub:: 0, thrust:: 0.
  • ci/check_symbols.sh still fails next on raft::, which is the next visibility category.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hide internal C++ symbols exported from libcuopt

1 participant