Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ if(BUILD_RELOCATABLE_PACKAGE)
# DEB
set(CPACK_DEBIAN_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "numactl, libnuma1, hsa-rocr")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "numactl, libnuma1")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_PACKAGE_CONTACT}")
if(NOT "${_tb_pkg_release}" STREQUAL "")
set(CPACK_DEBIAN_PACKAGE_RELEASE "${_tb_pkg_release}")
Expand All @@ -373,7 +373,7 @@ if(BUILD_RELOCATABLE_PACKAGE)
# RPM
set(CPACK_RPM_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
set(CPACK_RPM_PACKAGE_REQUIRES "numactl, hsa-rocr")
set(CPACK_RPM_PACKAGE_REQUIRES "numactl")
set(CPACK_RPM_PACKAGE_VENDOR "${CPACK_PACKAGE_VENDOR}")
if(NOT "${_tb_pkg_release}" STREQUAL "")
set(CPACK_RPM_PACKAGE_RELEASE "${_tb_pkg_release}")
Expand All @@ -394,6 +394,17 @@ if(BUILD_RELOCATABLE_PACKAGE)
"${_rpm_exclude_prefix}"
"${_rpm_exclude_prefix}/bin")

# Advisory install-time check for libhsa-runtime64.so.1. The package declares
# no hard ROCm dep so it can install on TheRock-tarball systems where no ROCm
# component is tracked by apt/dpkg; the postinst warns (never fails) when the
# HSA runtime is not discoverable, so a missing runtime surfaces at install
# time instead of as a dynamic-linker error on first invocation.
set(_tb_postinst_src "${CMAKE_CURRENT_SOURCE_DIR}/packaging/postinst-check-hsa.sh")
set(_tb_postinst_deb "${CMAKE_BINARY_DIR}/packaging/postinst")
configure_file("${_tb_postinst_src}" "${_tb_postinst_deb}" COPYONLY)
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${_tb_postinst_deb}")
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${_tb_postinst_src}")

# TGZ — embed release tag so successive runs do not collide on the same key.
# CMake 3.13+ honors CPACK_ARCHIVE_FILE_NAME for archive generators, but
# CMake 3.22 (Ubuntu 22.04) falls back to CPACK_PACKAGE_FILE_NAME for TGZ.
Expand All @@ -414,7 +425,7 @@ else()
rocm_setup_version(VERSION ${VERSION_STRING})

# Package specific CPACK vars
rocm_package_add_dependencies(DEPENDS "numactl" "hsa-rocr")
rocm_package_add_dependencies(DEPENDS "numactl")

set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md")
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
Expand Down
50 changes: 50 additions & 0 deletions packaging/postinst-check-hsa.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/sh
# Advisory check used as both the DEB postinst and the RPM %post scriptlet.
# TransferBench links against libhsa-runtime64.so.1; without it the binary
# fails at first run with a dynamic-linker error. The relocatable package
# declares no hard dep on hsa-rocr (or any ROCm component) because it is
# expected to install on TheRock-tarball systems where no ROCm package is
# tracked by apt/dpkg. Warn here so the user diagnoses a missing runtime
# at install time, not at TransferBench launch.
#
# Always exits 0 — this is advisory, never fatal.

set -e

found=0

if command -v ldconfig >/dev/null 2>&1; then
if ldconfig -p 2>/dev/null | grep -q 'libhsa-runtime64\.so\.1'; then
found=1
fi
fi

if [ "$found" -eq 0 ]; then
for d in /opt/rocm/lib /opt/rocm/lib64 /opt/rocm-*/lib /opt/rocm/extras-*/lib /opt/rocm/core-*/lib; do
if [ -e "$d/libhsa-runtime64.so.1" ]; then
found=1
break
fi
done
fi

if [ "$found" -eq 0 ]; then
cat >&2 <<'EOF'
====================================================================
TransferBench: WARNING

libhsa-runtime64.so.1 was not found on the dynamic loader path or
under any of /opt/rocm/lib, /opt/rocm-*/lib, or /opt/rocm/extras-*/lib.

TransferBench requires the ROCm HSA runtime at run time. Install a
ROCm 7.x stack (system packages or TheRock SDK) before invoking
TransferBench, or set LD_LIBRARY_PATH to a directory containing
libhsa-runtime64.so.1.

Without it, TransferBench will fail at startup with:
error while loading shared libraries: libhsa-runtime64.so.1
====================================================================
EOF
fi

exit 0
Loading