Skip to content

Commit 3985e7d

Browse files
authored
Add symbol checking in CI (#28)
This PR adds verification that no spdlog or fmt symbols are part of the dynamic symbol table for the rapids_logger binaries.
1 parent 46070bb commit 3985e7d

File tree

5 files changed

+48
-6
lines changed

5 files changed

+48
-6
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ if(RAPIDS_LOGGER_HIDE_ALL_SPDLOG_SYMBOLS)
8484
FMT_OPTION ${RAPIDS_LOGGER_FMT_OPTION} CPM_ARGS OPTIONS "BUILD_SHARED_LIBS OFF"
8585
"SPDLOG_BUILD_SHARED OFF"
8686
)
87-
set_target_properties(spdlog PROPERTIES CXX_VISIBILITY_PRESET hidden POSITION_INDEPENDENT_CODE ON)
87+
set_target_properties(spdlog PROPERTIES POSITION_INDEPENDENT_CODE ON)
8888
target_link_options(rapids_logger PRIVATE "LINKER:--exclude-libs,libspdlog")
8989
else()
9090
rapids_cpm_spdlog(

ci/build_static.sh

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ source rapids-date-string
77

88
rapids-logger "Static cpp build"
99

10+
# Make sure we have an updated CMake
11+
python -m pip install -U cmake
12+
pyenv rehash
13+
1014
cmake -S . -B build -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTS=ON
1115
cmake --build build
1216
ctest --test-dir build --output-on-failure

ci/build_wheel.sh

+13-5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ set -euo pipefail
55

66
package_name="rapids_logger"
77
package_dir="python/rapids-logger"
8+
dist_dir="${package_dir}/dist"
9+
final_dir="${package_dir}/final_dist"
810

911
source rapids-configure-sccache
1012

@@ -13,16 +15,22 @@ rapids-generate-version > ./VERSION
1315
rapids-logger "Building '${package_name}' wheel"
1416
sccache --zero-stats
1517
python -m pip wheel \
16-
-w "${package_dir}/dist" \
18+
-w "${dist_dir}" \
1719
-v \
1820
--no-deps \
1921
--disable-pip-version-check \
2022
"${package_dir}"
2123
sccache --show-adv-stats
2224

23-
mkdir -p "${package_dir}/final_dist"
25+
mkdir -p "${final_dir}"
2426
python -m auditwheel repair \
25-
-w "${package_dir}/final_dist" \
26-
${package_dir}/dist/*
27+
-w "${final_dir}" \
28+
"${dist_dir}/"*
2729

28-
RAPIDS_PY_WHEEL_NAME="${package_name}" rapids-upload-wheels-to-s3 cpp "${package_dir}/final_dist"
30+
# Check that no undefined symbols are present in the shared library
31+
WHEEL_EXPORT_DIR="$(mktemp -d)"
32+
unzip -d "${WHEEL_EXPORT_DIR}" "${final_dir}/*"
33+
LOGGER_LIBRARY=$(find "${WHEEL_EXPORT_DIR}" -type f -name 'librapids_logger.so')
34+
./ci/check_symbols.sh "${LOGGER_LIBRARY}"
35+
36+
RAPIDS_PY_WHEEL_NAME="${package_name}" rapids-upload-wheels-to-s3 cpp "${final_dir}"

ci/check_symbols.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
# Copyright (c) 2025, NVIDIA CORPORATION.
3+
4+
set -eEuo pipefail
5+
6+
echo "checking for symbol visibility issues"
7+
8+
LIBRARY="${1}"
9+
10+
echo ""
11+
echo "Checking exported symbols in '${LIBRARY}'"
12+
symbol_file="./symbols.txt"
13+
readelf --dyn-syms --wide "${LIBRARY}" \
14+
| c++filt \
15+
> "${symbol_file}"
16+
17+
for lib in fmt spdlog; do
18+
echo "Checking for '${lib}' symbols..."
19+
if grep -E "${lib}\:\:" "${symbol_file}"; then
20+
echo "ERROR: Found some exported symbols in ${LIBRARY} matching the pattern ${lib}::."
21+
exit 1
22+
fi
23+
done
24+
25+
echo "No symbol visibility issues found in ${LIBRARY}"

conda/recipes/rapids-logger/recipe.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ build:
1818
# Run tests from the build directory since they're cheap.
1919
ctest --test-dir build/ --output-on-failure
2020
cmake --install build/
21+
# Check that no undefined symbols are present in the shared library
22+
LIB="build/librapids_logger.so"
23+
test -f "${LIB}"
24+
./ci/check_symbols.sh "${LIB}"
25+
2126
2227
requirements:
2328
build:

0 commit comments

Comments
 (0)