Forking from #5108 (comment)
Original report (from Claude Code): https://github.com/ScottTodd/claude-rocm-workspace/blob/main/reviews/pr_TheRock_5108.md#unit-test-coverage-for-rpath-correctness
Current state
There is no automated validation of RPATH correctness. The existing
therock_test_validate_shared_lib / validate_shared_library.py only checks
that a .so can be dlopen'd — it doesn't verify executable RPATH entries.
Proposed: RPATH validation script
A post-build validation script could catch these issues at CI time rather than
waiting for runtime failures. Approach:
# build_tools/validate_rpath.py
# Walk dist/<subproject>/stage/, find all ELF executables/shared libs,
# read RUNPATH via readelf/pyelftools, verify each $ORIGIN-relative
# path resolves to a directory that actually exists in the stage tree.
This could be wired up similar to therock_test_validate_shared_lib:
# cmake/therock_testing.cmake
function(therock_test_validate_rpath)
# For each ELF binary in the dist tree, verify RPATH entries resolve
add_test(
NAME therock-validate-rpath-${subproject}
COMMAND "${Python3_EXECUTABLE}"
"${THEROCK_SOURCE_DIR}/build_tools/validate_rpath.py"
"${dist_path}"
)
endfunction()
Alternative: CMake-time validation
A lighter approach: add validation in therock_global_post_subproject.cmake
that compares the target's actual install destination (from RUNTIME_OUTPUT_DIRECTORY
or the install() command) against the computed origin. This is tricky because
CMake doesn't reliably expose the install destination as a target property at
configure time — it's set in the install() command, which is a separate
code path.
Recommendation
The script approach is more practical. It could run as a CTest after
ninja install and would catch:
- Missing
THEROCK_INSTALL_RPATH_ORIGIN for non-standard install locations
- Missing
INSTALL_RPATH_DIRS for non-standard lib directories
- Stale RPATH entries pointing to nonexistent directories
(back to my words)
The ctest after ninja install would just be the existing
|
- name: Test Packaging |
|
run: | |
|
ctest --test-dir ${BUILD_DIR} --output-on-failure |
Forking from #5108 (comment)
Original report (from Claude Code): https://github.com/ScottTodd/claude-rocm-workspace/blob/main/reviews/pr_TheRock_5108.md#unit-test-coverage-for-rpath-correctness
Current state
There is no automated validation of RPATH correctness. The existing
therock_test_validate_shared_lib/validate_shared_library.pyonly checksthat a
.socan be dlopen'd — it doesn't verify executable RPATH entries.Proposed: RPATH validation script
A post-build validation script could catch these issues at CI time rather than
waiting for runtime failures. Approach:
This could be wired up similar to
therock_test_validate_shared_lib:Alternative: CMake-time validation
A lighter approach: add validation in
therock_global_post_subproject.cmakethat compares the target's actual install destination (from
RUNTIME_OUTPUT_DIRECTORYor the
install()command) against the computed origin. This is tricky becauseCMake doesn't reliably expose the install destination as a target property at
configure time — it's set in the
install()command, which is a separatecode path.
Recommendation
The script approach is more practical. It could run as a CTest after
ninja installand would catch:THEROCK_INSTALL_RPATH_ORIGINfor non-standard install locationsINSTALL_RPATH_DIRSfor non-standard lib directories(back to my words)
The ctest after
ninja installwould just be the existingTheRock/.github/workflows/multi_arch_build_portable_linux_artifacts.yml
Lines 179 to 181 in 8d042a2