Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4fa2fd8
Adding TBB to third-party/sysdeps
ajanicijamd Apr 8, 2026
adba60e
Removed dependency of therock-third-party on therock-tbb
ajanicijamd Apr 8, 2026
eee4bd7
Disabled AMDGPU targets for TBB
ajanicijamd Apr 8, 2026
ee80348
Set THEROCK_BUNDLED_TBB; added copyright notice
ajanicijamd Apr 8, 2026
4cdc8f9
Set target property to disable AMDGPU for TBB
ajanicijamd Apr 8, 2026
9ceddfc
Added USE_DIST_AMDGPU_TARGETS to therock-tbb subproject declaration
ajanicijamd Apr 8, 2026
22251bd
Removed ARG_DISABLE_AMDGPU_TARGETS property
ajanicijamd Apr 8, 2026
ebb1ffc
Addressed review comments
ajanicijamd Apr 9, 2026
850e8a1
Updated therock-tbb CMake configuration to specify binary directory, …
dgaliffiAMD Apr 21, 2026
a1d0575
libtbb libraries were not being installed properly.
dgaliffiAMD Apr 21, 2026
4d50a6a
Update INSTALL_RPATH_DIRS
dgaliffiAMD Apr 22, 2026
eced8ff
Create a post hook to correct set RPATH of internal libraries
dgaliffiAMD Apr 22, 2026
eae2085
Merge branch 'main' into users/ajanicijamd/therock-add-tbb-to-sysdeps-2
dgaliffiAMD Apr 28, 2026
8b77ea9
Refactor TBB sysdep to optional pattern, matching fa6c993
dgaliffiAMD Apr 28, 2026
471a66e
Add patch scripts for tbb
dgaliffiAMD Apr 29, 2026
b683b4f
update comments
dgaliffiAMD Apr 29, 2026
7dead6d
Remove unused version.lds from tbb sysdep
dgaliffiAMD Apr 29, 2026
4227d42
Remove unused Python3_EXECUTABLE from tbb subproject args
dgaliffiAMD Apr 29, 2026
3182f89
Enable nullglob in patch_install.sh for robustness
dgaliffiAMD Apr 29, 2026
35bae17
Add post-sed verification to patch_source.sh
dgaliffiAMD Apr 29, 2026
fa96228
Update comments
dgaliffiAMD Apr 29, 2026
3dbc0a0
Fetch sysdeps-tbb artifact for rocprofiler-systems tests
dgaliffiAMD Apr 29, 2026
e2f205f
Merged from main
ajanicijamd May 6, 2026
d45ae68
Removed unnecessary setting, modified requirements-test.txt
ajanicijamd May 6, 2026
51bb808
Reverted change
ajanicijamd May 6, 2026
9fe8d69
Merge from main
ajanicijamd May 8, 2026
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
9 changes: 8 additions & 1 deletion BUILD_TOPOLOGY.toml
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,13 @@ artifact_deps = []
feature_group = "CORE"
disable_platforms = ["windows"]

[artifacts.sysdeps-tbb]
artifact_group = "third-party-sysdeps"
type = "target-neutral"
artifact_deps = []
feature_group = "CORE"
disable_platforms = ["windows"]

[artifacts.sysdeps-hwloc]
artifact_group = "third-party-sysdeps"
type = "target-neutral"
Expand Down Expand Up @@ -728,7 +735,7 @@ disable_platforms = ["windows"]
[artifacts.rocprofiler-systems]
artifact_group = "profiler-apps"
type = "target-neutral"
artifact_deps = ["amd-llvm", "core-hip", "rocprofiler-sdk", "core-amdsmi", "spdlog", "openmpi"]
artifact_deps = ["amd-llvm", "core-hip", "rocprofiler-sdk", "core-amdsmi", "spdlog", "openmpi", "sysdeps-tbb"]
feature_name = "ROCPROFSYS"
feature_group = "PROFILER"
disable_platforms = ["windows"]
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ set(THEROCK_BUNDLED_MPFR)
set(THEROCK_BUNDLED_NCURSES)
set(THEROCK_BUNDLED_NUMACTL)
set(THEROCK_BUNDLED_SQLITE3)
set(THEROCK_BUNDLED_TBB)
set(THEROCK_BUNDLED_ZLIB)
set(THEROCK_BUNDLED_ZSTD)
set(THEROCK_BUNDLED_AMDMESA)
Expand Down Expand Up @@ -432,6 +433,9 @@ if(THEROCK_BUNDLE_SYSDEPS)
if(THEROCK_ENABLE_SYSDEPS_NCURSES)
set(THEROCK_BUNDLED_NCURSES therock-ncurses)
endif()
if(THEROCK_ENABLE_SYSDEPS_TBB)
set(THEROCK_BUNDLED_TBB therock-tbb)
endif()
if(THEROCK_ENABLE_SYSDEPS_AMD_MESA)
set(THEROCK_BUNDLED_AMDMESA therock-amd-mesa)
endif()
Expand Down
2 changes: 2 additions & 0 deletions build_tools/install_rocm_from_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,8 @@ def retrieve_artifacts_by_run_id(args):
extra_artifacts.append("rocprofiler-systems")
# Contains executables (rocprof-sys-run, rocprof-sys-instrument, etc.)
argv.append("rocprofiler-systems_run")
# rocprofiler-systems depends on sysdeps-tbb (Dyninst links against it)
extra_artifacts.append("sysdeps-tbb")
if args.rocrtst:
extra_artifacts.append("rocrtst")
# rocrtst depends on sysdeps-hwloc (which depends on sysdeps-libpciaccess)
Expand Down
12 changes: 12 additions & 0 deletions docs/development/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ project wide:
- `THEROCK_BUNDLED_LIBNL`
- `THEROCK_BUNDLED_NUMACTL`
- `THEROCK_BUNDLED_SQLITE3`
- `THEROCK_BUNDLED_TBB`
- `THEROCK_BUNDLED_ZLIB`
- `THEROCK_BUNDLED_ZSTD`
- Sub-projects must arrange for any libraries that depend on these to add the
Expand Down Expand Up @@ -201,6 +202,17 @@ SIMDe (SIMD Everywhere) is a header-only portability library for SIMD intrinsics
- Import library: `SQLite::SQLite3`
- Alternatives: none

## TBB

oneAPI Threading Building Blocks. Optional sysdep; only bundled when
`THEROCK_ENABLE_SYSDEPS_TBB=ON`.

Supported sub-libraries: `tbb`, `tbbmalloc`, `tbbmalloc_proxy`.

- Canonical method: `find_package(TBB CONFIG)`
- Import libraries: `TBB::tbb`, `TBB::tbbmalloc`, `TBB::tbbmalloc_proxy`
- Alternatives: `pkg_check_modules(TBB tbb)`

## zlib

- Canonical method: `find_package(ZLIB)`
Expand Down
2 changes: 1 addition & 1 deletion profiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ if (THEROCK_ENABLE_ROCPROFSYS AND THEROCK_SANITIZER STREQUAL "")
BACKGROUND_BUILD
CMAKE_ARGS
-DHIP_PLATFORM=amd
-DROCPROFSYS_BUILD_TBB=ON
-DROCPROFSYS_BUILD_LIBIBERTY=ON
-DROCPROFSYS_BUILD_BOOST=ON
-DROCPROFSYS_BUILD_DYNINST=ON
Expand Down Expand Up @@ -342,6 +341,7 @@ if (THEROCK_ENABLE_ROCPROFSYS AND THEROCK_SANITIZER STREQUAL "")
${THEROCK_BUNDLED_ELFUTILS}
${THEROCK_BUNDLED_LIBDRM}
${THEROCK_BUNDLED_SQLITE3}
${THEROCK_BUNDLED_TBB}
${_openmpi_optional_dep}
)
therock_cmake_subproject_glob_c_sources(rocprofiler-systems
Expand Down
29 changes: 29 additions & 0 deletions profiler/post_hook_rocprofiler-systems.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

# Dyninst and rocprofiler-systems internal libraries live in lib/rocprofiler-systems.
# Set the RPATH origin per-target so that (for example) lib/rocm_sysdeps/lib resolves as
# $ORIGIN/../rocm_sysdeps/lib rather than $ORIGIN/rocm_sysdeps/lib.
set(_rocprofsys_lib_targets
common
dynElf
dynDwarf
dyninstAPI
dyninstAPI_RT
dynC_API
instructionAPI
parseAPI
patchAPI
pcontrol
stackwalk
symtabAPI
gotcha
)

foreach(_target ${_rocprofsys_lib_targets})
if(TARGET "${_target}")
set_target_properties("${_target}" PROPERTIES
THEROCK_INSTALL_RPATH_ORIGIN lib/rocprofiler-systems
)
endif()
endforeach()
14 changes: 14 additions & 0 deletions third-party/sysdeps/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,20 @@ if(THEROCK_ENABLE_SYSDEPS_LIBPCIACCESS)
)
endif()

# Optional sysdep: TBB (Threading Building Blocks)
if(THEROCK_ENABLE_SYSDEPS_TBB)
add_subdirectory(tbb)
therock_provide_artifact(sysdeps-tbb
TARGET_NEUTRAL
DESCRIPTOR artifact-tbb.toml
COMPONENTS
dev
lib
SUBPROJECT_DEPS
therock-tbb
)
endif()

# Optional sysdep: hwloc (depends on numactl and libpciaccess)
if(THEROCK_ENABLE_SYSDEPS_HWLOC)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../common/hwloc" "${CMAKE_CURRENT_BINARY_DIR}/hwloc")
Expand Down
3 changes: 3 additions & 0 deletions third-party/sysdeps/linux/artifact-tbb.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# tbb
[components.lib."third-party/sysdeps/linux/tbb/build/stage"]
[components.dev."third-party/sysdeps/linux/tbb/build/stage"]
93 changes: 93 additions & 0 deletions third-party/sysdeps/linux/tbb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Copyright Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
# Super-project block: download sources and declare the sub-project.
set(_source_dir "${CMAKE_CURRENT_BINARY_DIR}/source")
set(_download_stamp "${_source_dir}/download.stamp")

therock_subproject_fetch(therock-tbb-sources
SOURCE_DIR "${_source_dir}"
# Originally mirrored from: https://github.com/uxlfoundation/oneTBB/archive/refs/tags/v2022.3.0.tar.gz
URL https://rocm-third-party-deps.s3.us-east-2.amazonaws.com/oneTBB-2022.3.0.tar.gz
URL_HASH SHA256=01598a46c1162c27253a0de0236f520fd8ee8166e9ebb84a4243574f88e6e50a
TOUCH "${_download_stamp}"
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)

therock_cmake_subproject_declare(therock-tbb
USE_DIST_AMDGPU_TARGETS
BACKGROUND_BUILD
EXCLUDE_FROM_ALL
NO_MERGE_COMPILE_COMMANDS
OUTPUT_ON_FAILURE
EXTERNAL_SOURCE_DIR .
FPRINT_SOURCE_DIR "${_source_dir}"
FPRINT_FILE_GLOBS "${CMAKE_CURRENT_LIST_DIR}/*"
BINARY_DIR build
CMAKE_ARGS
"-DSOURCE_DIR=${_source_dir}"
"-DPATCHELF=${PATCHELF}"
INSTALL_DESTINATION
lib/rocm_sysdeps
INTERFACE_LINK_DIRS
lib/rocm_sysdeps/lib
INTERFACE_INSTALL_RPATH_DIRS
lib/rocm_sysdeps/lib
INTERFACE_PKG_CONFIG_DIRS
lib/rocm_sysdeps/lib/pkgconfig
EXTRA_DEPENDS
"${_download_stamp}"
)

therock_cmake_subproject_provide_package(therock-tbb TBB lib/rocm_sysdeps/lib/cmake/TBB)
therock_cmake_subproject_activate(therock-tbb)

therock_test_validate_shared_lib(
PATH build/dist/lib/rocm_sysdeps/lib
LIB_NAMES librocm_sysdeps_tbb.so
)

return()
endif()

# Sub-project block: invoked by TheRock's cmake sub-project machinery.
cmake_minimum_required(VERSION 3.25)
project(TBB_BUILD)

if(NOT PATCHELF)
message(FATAL_ERROR "Missing PATCHELF from super-project")
endif()

add_custom_target(build ALL
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
# Clean any previous install and create a fresh working copy of the source.
COMMAND
"${CMAKE_COMMAND}" -E rm -rf -- "${CMAKE_INSTALL_PREFIX}" "${CMAKE_CURRENT_BINARY_DIR}/s"
COMMAND
"${CMAKE_COMMAND}" -E copy_directory "${SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/s"
# Patch source: rename library output names to rocm_sysdeps_ prefix.
COMMAND
bash "${CMAKE_CURRENT_SOURCE_DIR}/patch_source.sh" "${CMAKE_CURRENT_BINARY_DIR}/s"
# Configure oneTBB.
COMMAND
"${CMAKE_COMMAND}"
-S "${CMAKE_CURRENT_BINARY_DIR}/s"
-B "${CMAKE_CURRENT_BINARY_DIR}/tbb-build"
-G Ninja
"-DCMAKE_BUILD_TYPE=Release"
"-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}"
"-DCMAKE_INSTALL_LIBDIR=lib"
"-DTBB_TEST=OFF"
# Build.
COMMAND
"${CMAKE_COMMAND}" --build "${CMAKE_CURRENT_BINARY_DIR}/tbb-build" --verbose
# Install.
COMMAND
"${CMAKE_COMMAND}" --install "${CMAKE_CURRENT_BINARY_DIR}/tbb-build"
# Patch install: fix RPATH, relocate .pc, remove upstream cmake config.
COMMAND
"${CMAKE_COMMAND}" -E env
"PATCHELF=${PATCHELF}" --
bash "${CMAKE_CURRENT_SOURCE_DIR}/patch_install.sh" "${CMAKE_INSTALL_PREFIX}"
)
50 changes: 50 additions & 0 deletions third-party/sysdeps/linux/tbb/patch_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/bash
# Copyright Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

# Patches installed TBB libraries for portable sysdeps distribution:
# - Sets RPATH to $ORIGIN on all real (non-symlink) shared libraries.
# - Makes tbb.pc relocatable by replacing the absolute prefix.
# - Removes the upstream cmake config (TheRock provides its own wrapper).
#
# Args: install_dir
# Env: PATCHELF

set -e

PREFIX="${1:?Expected install prefix argument}"
PATCHELF="${PATCHELF:?PATCHELF env var required}"

LIB_DIR="$PREFIX/lib"

echo "Patching TBB install..."

shopt -s nullglob

# Set RPATH and create unprefixed symlinks (e.g. libtbb.so -> librocm_sysdeps_tbb.so.12).
for lib in "$LIB_DIR"/librocm_sysdeps_tbb*.so.*; do
[ -L "$lib" ] && continue
"$PATCHELF" --set-rpath '$ORIGIN' "$lib"
base=$(basename "$lib") # librocm_sysdeps_tbb.so.12.17
soname="${base%.*}" # librocm_sysdeps_tbb.so.12
unprefixed="${soname/rocm_sysdeps_/}" # libtbb.so.12
symlink="${unprefixed%.so.*}.so" # libtbb.so
ln -sf "$soname" "$LIB_DIR/$symlink"
done

# Make tbb.pc relocatable: replace the absolute build-time prefix with
# a pcfiledir-relative path. .pc files live at $PREFIX/lib/pkgconfig,
# so ${pcfiledir}/../.. resolves back to $PREFIX at runtime.
PC="$LIB_DIR/pkgconfig/tbb.pc"
if [ -f "$PC" ]; then
abs_prefix=$(grep '^prefix=' "$PC" | cut -d= -f2-)
sed -i "s|prefix=${abs_prefix}|prefix=\${pcfiledir}/../..|" "$PC"
sed -i "s|${abs_prefix}/|\${prefix}/|g" "$PC"
fi

# Remove the upstream cmake config. It references the original (unprefixed)
# library names and would conflict with TheRock's wrapper config provided via
# therock_cmake_subproject_provide_package.
rm -rf "$PREFIX/lib/cmake/TBB"

echo "Done patching TBB install."
44 changes: 44 additions & 0 deletions third-party/sysdeps/linux/tbb/patch_source.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/bash
# Copyright Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

# Patches TBB CMakeLists files to rename library output names with the
# rocm_sysdeps_ prefix, so that installed libraries do not conflict with
# system-installed TBB. Must be run before the cmake configure step.
#
# The sed patterns below are pinned to oneTBB 2022.3.0 and must be
# revalidated when bumping the version.
#
# Args: source_dir

set -e

SOURCE_DIR="${1:?Source directory must be given}"

verify_patch() {
local file="$1" name="$2"
if ! grep -q "OUTPUT_NAME.*rocm_sysdeps_${name}" "$file"; then
echo "ERROR: OUTPUT_NAME patch for ${name} did not apply to ${file}" >&2
echo "The sed patterns may need updating for this oneTBB version." >&2
exit 1
fi
}

echo "Patching TBB sources..."

# tbb: insert OUTPUT_NAME after the SOVERSION line in set_target_properties.
sed -i 's/ SOVERSION \${TBB_BINARY_VERSION}$/ SOVERSION ${TBB_BINARY_VERSION}\n OUTPUT_NAME "rocm_sysdeps_tbb"/' \
"$SOURCE_DIR/src/tbb/CMakeLists.txt"
verify_patch "$SOURCE_DIR/src/tbb/CMakeLists.txt" "tbb"

# tbbmalloc: same.
sed -i 's/ SOVERSION \${TBBMALLOC_BINARY_VERSION}$/ SOVERSION ${TBBMALLOC_BINARY_VERSION}\n OUTPUT_NAME "rocm_sysdeps_tbbmalloc"/' \
"$SOURCE_DIR/src/tbbmalloc/CMakeLists.txt"
verify_patch "$SOURCE_DIR/src/tbbmalloc/CMakeLists.txt" "tbbmalloc"

# tbbmalloc_proxy: SOVERSION is followed by a closing paren on the same line.
sed -i 's/ SOVERSION \${TBBMALLOC_BINARY_VERSION})$/ SOVERSION ${TBBMALLOC_BINARY_VERSION}\n OUTPUT_NAME "rocm_sysdeps_tbbmalloc_proxy")/' \
"$SOURCE_DIR/src/tbbmalloc_proxy/CMakeLists.txt"
verify_patch "$SOURCE_DIR/src/tbbmalloc_proxy/CMakeLists.txt" "tbbmalloc_proxy"

echo "Done patching TBB sources."
Loading