-
Notifications
You must be signed in to change notification settings - Fork 217
[DRAFT] refactor(tests): replace cuopt_static with CUOPT_INTERNAL_EXPORT + version script #1574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
de5c69c
4c8c0ec
24f5d0e
094e8fd
867c13b
0a3abfc
702c97d
8f169d3
7189539
ddfc668
8d7160b
74dfed7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| #!/bin/bash | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| set -eEuo pipefail | ||
|
|
||
| echo "checking for symbol visibility issues" | ||
|
|
||
| LIBRARY="${1}" | ||
|
|
||
| echo "" | ||
| echo "Checking exported symbols in '${LIBRARY}'" | ||
| symbol_file="$(mktemp)" | ||
| match_file="$(mktemp)" | ||
| trap 'rm -f "${symbol_file}" "${match_file}"' EXIT | ||
|
|
||
| # Ignore WEAK and UNIQUE symbols since UNIQUE symbols should be exported and | ||
| # WEAK symbols may come from template instantiations. | ||
| # Ignore symbols containing "_error" since these are likely exception types | ||
| # and should be exported. | ||
|
|
||
| readelf --dyn-syms --wide "${LIBRARY}" \ | ||
| | awk '$7 != "UND" && $5 != "WEAK" && $5 != "UNIQUE"' \ | ||
| | c++filt --no-params \ | ||
| | awk '$0 !~ /_error/' \ | ||
| > "${symbol_file}" | ||
|
|
||
| patterns=( | ||
| 'cub::' | ||
| 'thrust::' | ||
| 'raft::' | ||
| 'rmm::' | ||
| 'cuopt::mathematical_optimization::detail' | ||
| 'cuopt::routing::detail' | ||
| 'grpc::' | ||
| 'google::protobuf' | ||
| 'tbb::' | ||
| 'absl::' | ||
| 'dejavu::' | ||
| 'papilo::' | ||
| 'boost::' | ||
| 'pslp_' | ||
| ) | ||
|
|
||
| failed=0 | ||
|
|
||
| for pattern in "${patterns[@]}"; do | ||
| echo "Checking for '${pattern}' symbols..." | ||
|
|
||
| awk -v pattern="${pattern}" ' | ||
| BEGIN { has_trailing_scope = (substr(pattern, length(pattern) - 1) == "::") } | ||
| $1 ~ /^[0-9]+:/ { | ||
| symbol = "" | ||
| for (i = 8; i <= NF; ++i) { | ||
| symbol = symbol (i == 8 ? "" : " ") $i | ||
| } | ||
|
|
||
| sub(/<.*/, "", symbol) | ||
| sub(/^.*[[:space:]](for|to)[[:space:]]+/, "", symbol) | ||
|
|
||
| if (has_trailing_scope) { | ||
| matched = (index(symbol, pattern) == 1) | ||
| } else { | ||
| matched = (symbol == pattern || index(symbol, pattern "::") == 1) | ||
| } | ||
|
|
||
| if (matched) { print } | ||
| } | ||
| ' "${symbol_file}" > "${match_file}" | ||
|
|
||
| matches=$(awk 'END { print NR }' "${match_file}") | ||
| if [[ "${matches}" -ne 0 ]]; then | ||
| sed -n '1,20p' "${match_file}" | ||
| echo "ERROR: Found exported symbols in ${LIBRARY} matching the pattern ${pattern}." | ||
| echo "ERROR: Total matching symbols: ${matches}" | ||
| failed=1 | ||
| fi | ||
| done | ||
|
|
||
| if [[ "${failed}" -ne 0 ]]; then | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "No symbol visibility issues found in ${LIBRARY}" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| /* clang-format off */ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| /* clang-format on */ | ||
|
|
||
| #pragma once | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Use the repository-required include-guard form. Both changed headers use
As per coding guidelines, C++ headers must use 📍 Affects 2 files
🤖 Prompt for AI AgentsSource: Coding guidelines |
||
|
|
||
| #if defined(__GNUC__) || defined(__clang__) | ||
| #define CUOPT_EXPORT __attribute__((visibility("default"))) | ||
| // Marks internal symbols that are exported solely for test access. | ||
| // These are NOT part of the stable public API and may change without notice. | ||
| #define CUOPT_INTERNAL_EXPORT __attribute__((visibility("default"))) | ||
| #else | ||
| #define CUOPT_EXPORT | ||
| #define CUOPT_INTERNAL_EXPORT | ||
| #endif | ||
There was a problem hiding this comment.
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:
Repository: NVIDIA/cuopt
Length of output: 3260
🏁 Script executed:
Repository: NVIDIA/cuopt
Length of output: 4006
🏁 Script executed:
Repository: NVIDIA/cuopt
Length of output: 621
Make
pslp_match the prefix.pslp_goes through the non-::branch, so it only matches the exact symbolpslp_or symbols starting withpslp_::; plain prefixed symbols likepslp_fooare skipped. If this entry is meant to cover the PSLP symbol prefix, add explicit prefix handling and a regression fixture.🤖 Prompt for AI Agents
Source: Path instructions