[rocprofiler-compute] Fix RPATH for rocprofiler-compute test binary in non-default install location#5108
Conversation
…location test-rocprofiler-compute-tool installs to libexec/rocprofiler-compute/tests/ instead of the default bin/, so TheRock's RPATH machinery (which assumes executables live in bin/) computes relative paths from the wrong origin and the loader cannot find librocprofiler-compute-tool.so at runtime. Add INSTALL_RPATH_DIRS for the project's lib subdir, plus a post hook that sets THEROCK_INSTALL_RPATH_ORIGIN on the test binary so the relative path is computed correctly. Mirrors the pattern in the adjacent post_hook_rocprofiler-sdk.cmake. Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
|
FYI @svolkov-amd and @feizheng10 for future native collector changes |
There was a problem hiding this comment.
Pull request overview
This PR fixes runtime linking for the installed test-rocprofiler-compute-tool CTest binary when rocprofiler-compute is installed into TheRock’s non-default layout (binary under libexec/... and its dependent .so under lib/...). It does so by ensuring TheRock’s global post-subproject RPATH computation includes the rocprofiler-compute library subdirectory and computes relative RPATH entries from the test binary’s actual install location.
Changes:
- Add
INSTALL_RPATH_DIRS "lib/rocprofiler-compute"to the rocprofiler-compute subproject declaration so TheRock includes that directory when generating install RPATHs. - Add a new rocprofiler-compute post-hook that sets
THEROCK_INSTALL_RPATH_ORIGINfortest-rocprofiler-compute-tooltolibexec/rocprofiler-compute/tests, so relative RPATHs are computed from the correct origin.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| profiler/post_hook_rocprofiler-compute.cmake | Sets THEROCK_INSTALL_RPATH_ORIGIN for the installed rocprofiler-compute test executable to ensure correct origin-relative RPATH computation. |
| profiler/CMakeLists.txt | Adds rocprofiler-compute’s lib/rocprofiler-compute directory to TheRock-managed install RPATH dirs for that subproject. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ScottTodd
left a comment
There was a problem hiding this comment.
Thanks, this looks correct based on existing patterns. Are there tests that would run on this PR itself that would confirm the fix, or just the separate PR in rocm-systems that will start using this?
| # test-rocprofiler-compute-tool installs to libexec/rocprofiler-compute/tests/ | ||
| # instead of the default bin/. Tell TheRock the actual origin so it can compute | ||
| # correct relative RPATH entries. | ||
| if(TARGET test-rocprofiler-compute-tool) | ||
| set_target_properties(test-rocprofiler-compute-tool PROPERTIES | ||
| THEROCK_INSTALL_RPATH_ORIGIN libexec/rocprofiler-compute/tests | ||
| ) | ||
| endif() |
There was a problem hiding this comment.
FYI I ran an audit across the project for other targets that might need similar treatment: https://github.com/ScottTodd/claude-rocm-workspace/blob/main/reviews/pr_TheRock_5108.md#broader-analysis-other-targets-that-may-be-affected
potentially missing:
- roctracer
codeobj_testand test executables - aqlprofile test executables
- rocprofiler (v1), though we don't build it in TheRock and probably don't plan to in the future?
I also checked if we could validate RPATH correctness through unit tests to ensure we don't regress here. See https://github.com/ScottTodd/claude-rocm-workspace/blob/main/reviews/pr_TheRock_5108.md#unit-test-coverage-for-rpath-correctness for a ideas there
There was a problem hiding this comment.
Filed #5114 to follow up so we don't regress and other subprojects getting onboarded can have more confidence that the packaging will work
The test-rocprofiler-compute-tool PR merge into rocm-systems is blocked by this. |
|
If the builds and tests you expect to pass do pass then yes, safe to merge. |

Motivation
The C++ unit test binary
test-rocprofiler-compute-tool(registered with CTest viaTEST_FROM_INSTALL=ON) fails on TheRock builds with:The library is installed to
lib/rocprofiler-compute/and the binary tolibexec/rocprofiler-compute/tests/. The per-targetINSTALL_RPATHset upstream resolves correctly in standalone CMake builds, but TheRock's global post-subproject hook overwrites it with paths computed relative to the default executable origin (bin/), producing an RPATH that does not reachlib/rocprofiler-compute/.This unblocks the upstream rocprofiler-compute PR ROCm/rocm-systems#5721, which adds CTest registration of the native tool test and surfaces the failure on TheRock CI.
Technical Details
Two changes:
profiler/CMakeLists.txt: addINSTALL_RPATH_DIRS "lib/rocprofiler-compute"to the rocprofiler-compute subproject declaration so the project's own lib subdir is part of the RPATH set TheRock plumbs into every binary in the subproject.profiler/post_hook_rocprofiler-compute.cmake(new): annotatetest-rocprofiler-compute-toolwithTHEROCK_INSTALL_RPATH_ORIGIN libexec/rocprofiler-compute/testsso TheRock computes RPATH relative to the actual install location. Auto-discovered via thepost_hook_<name>.cmakenaming convention. Mirrors the pattern in the adjacentprofiler/post_hook_rocprofiler-sdk.cmake. Guarded withif(TARGET ...)so it is a no-op whenTHEROCK_BUILD_TESTING=OFF.No upstream changes required. The existing
INSTALL_RPATHin the rocprofiler-compute project continues to handle standalone builds.Test Plan
THEROCK_BUILD_TESTING=ON: confirmreadelf -don the installedtest-rocprofiler-compute-toolshows RUNPATH containing a relative path that resolves tolib/rocprofiler-compute/fromlibexec/rocprofiler-compute/tests/.test-rocprofiler-compute-toolend-to-end without settingLD_LIBRARY_PATH.THEROCK_BUILD_TESTING=OFF: build still configures cleanly (post-hook guard prevents touching the missing target).Submission Checklist