-
Notifications
You must be signed in to change notification settings - Fork 247
Hide visibility of non-public symbols #1644
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
Merged
rapids-bot
merged 16 commits into
rapidsai:branch-24.10
from
jameslamb:symbol-visibility
Aug 15, 2024
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
bb2ca48
mark symbols not in rmm:: namespace as hidden
jameslamb 532d24b
do not mark nested namespaces under rmm::
jameslamb 24796a7
formatting
jameslamb 0701559
revert unnecessary changes
jameslamb e9482bf
try making more things private
jameslamb 1c39756
Revert "try making more things private"
jameslamb 7316d2c
revert explicit exporting in source files, set target-specific proper…
jameslamb f6f1649
add symbol-checking in CI, clean up CMake changes
jameslamb 5961267
remove includes, fix up scripts
jameslamb 849e05d
more script chanages
jameslamb 301df5f
fix header
jameslamb e727ebb
try to match what cmakelint wants in CI
jameslamb be3ba09
more cmakelint
jameslamb 84f452a
even more cmakelint
jameslamb e93f26c
update paths
jameslamb 8d5d060
use pushd and popd instead
jameslamb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| #!/bin/bash | ||
| # Copyright (c) 2024, NVIDIA CORPORATION. | ||
|
|
||
| set -eEuo pipefail | ||
|
|
||
| echo "checking for symbol visibility issues" | ||
|
|
||
| WHEEL_FILE=${1} | ||
|
|
||
| raise-symbols-found-error() { | ||
| local pattern="${1}" | ||
|
|
||
| err_msg="ERROR: Found some exported symbols matching the pattern '${pattern}'. | ||
|
|
||
| These should be marked with 'hidden' visibility. | ||
| See https://cmake.org/cmake/help/latest/prop_tgt/LANG_VISIBILITY_PRESET.html and https://gcc.gnu.org/wiki/Visibility for details. | ||
| " | ||
|
|
||
| echo "" | ||
| echo "${err_msg}" | ||
| exit 1 | ||
| } | ||
|
|
||
| WHEEL_EXPORT_DIR="$(mktemp -d)" | ||
|
|
||
| unzip \ | ||
| -d "${WHEEL_EXPORT_DIR}" \ | ||
| "${WHEEL_FILE}" | ||
|
|
||
| dso_files=$( | ||
| find \ | ||
| "${WHEEL_EXPORT_DIR}" \ | ||
| -type f \ | ||
| \( -name '*.so' -o -name '*.so.*' \) | ||
vyasr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ) | ||
|
|
||
| for dso_file in ${dso_files}; do | ||
| echo "" | ||
| echo "checking exported symbols in '${dso_file}'" | ||
| symbol_file="./syms.txt" | ||
| readelf --symbols --wide "${dso_file}" \ | ||
| | c++filt \ | ||
| > "${symbol_file}" | ||
|
|
||
| echo "symbol counts by type" | ||
| echo " * GLOBAL: $(grep --count -E ' GLOBAL ' < ${symbol_file})" | ||
| echo " * WEAK: $(grep --count -E ' WEAK ' < ${symbol_file})" | ||
| echo " * LOCAL: $(grep --count -E ' LOCAL ' < ${symbol_file})" | ||
|
|
||
| # Explanation for '-v' uses here: | ||
| # | ||
| # * 'format_error' symbols are intentionally exported, that type of error | ||
| # can be thrown across library boundaries. See "Problems with C++ exceptions" | ||
| # at https://gcc.gnu.org/wiki/Visibility. | ||
| echo "checking for 'fmt::' symbols..." | ||
| if grep -E 'fmt\:\:' < "${symbol_file}" \ | ||
| | grep -v 'format_error' | ||
| then | ||
| raise-symbols-found-error 'fmt::' | ||
| fi | ||
|
|
||
| # Explanation for '-v' uses here: | ||
| # | ||
| # * trivially-destructible objects sometimes get an entry in the symbol table | ||
| # for a specialization of `std::_Destroy_aux()` called to destroy them. | ||
| # There is one for `spdlog::details::log_msg_buffer like that: | ||
| # | ||
| # 'std::_Destroy_aux<false>::__destroy<spdlog::details::log_msg_buffer*>' | ||
| # | ||
| # That should be safe to export. | ||
| # | ||
| echo "checking for 'spdlog::' symbols..." | ||
| if grep -E 'spdlog\:\:' < "${symbol_file}" \ | ||
| | grep -v 'std\:\:_Destroy_aux' | ||
| then | ||
| raise-symbols-found-error 'spdlog::' | ||
| fi | ||
| echo "No symbol visibility issues found" | ||
| done | ||
|
|
||
| echo "" | ||
| echo "No symbol visibility issues found in any DSOs" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.