From 74ee081f06eae6b5329978666d62b748ee25c814 Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Tue, 16 Jun 2026 13:21:37 -0500 Subject: [PATCH 01/12] [rocprofiler-systems] - add suffix to libomptarget find_library This is in prepartion for compiler using LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON by default. This option will install libomptarget.so in a target specific directory one level down in lib. Then the path would be: INSTALL_PREFIX/lib/llvm/lib/x86_64-unknown-linux-gnu. This is required for https://github.com/ROCm/TheRock/pull/5758 --- .../examples/openmp/target/CMakeLists.txt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/projects/rocprofiler-systems/examples/openmp/target/CMakeLists.txt b/projects/rocprofiler-systems/examples/openmp/target/CMakeLists.txt index 4c9479e240c9..8cd5087b515c 100644 --- a/projects/rocprofiler-systems/examples/openmp/target/CMakeLists.txt +++ b/projects/rocprofiler-systems/examples/openmp/target/CMakeLists.txt @@ -70,8 +70,21 @@ set(_LLVM_LIB_HINTS "/opt/rocm/lib/llvm/lib" ) +# Determine LLVM host triple as libomptarget might be installed there. +execute_process( + COMMAND "${OMP_TARGET_COMPILER}" --print-target-triple + OUTPUT_VARIABLE LLVM_HOST_TRIPLE + OUTPUT_STRIP_TRAILING_WHITESPACE + COMMAND_ERROR_IS_FATAL ANY +) + # Find libomptarget -find_library(LIBOMPTARGET_SO NAMES omptarget HINTS ${_LLVM_LIB_HINTS}) +find_library( + LIBOMPTARGET_SO + NAMES omptarget + HINTS ${_LLVM_LIB_HINTS} + PATH_SUFFIXES ${LLVM_HOST_TRIPLE} +) if(NOT LIBOMPTARGET_SO) message(FATAL_ERROR "Could not find libomptarget in any of:\n ${_LLVM_LIB_HINTS}") From d71d284baa4c075e089fc57554f5e40b67c5c1ab Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Wed, 17 Jun 2026 10:56:52 -0500 Subject: [PATCH 02/12] [rocprofiler-systems] - Add llvm host triple to pytest config.py --- .../rocprofiler-systems/tests/pytest/rocprofsys/config.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/projects/rocprofiler-systems/tests/pytest/rocprofsys/config.py b/projects/rocprofiler-systems/tests/pytest/rocprofsys/config.py index 114c0a34adab..c509b07b24cc 100644 --- a/projects/rocprofiler-systems/tests/pytest/rocprofsys/config.py +++ b/projects/rocprofiler-systems/tests/pytest/rocprofsys/config.py @@ -84,11 +84,19 @@ def get_llvm_lib_paths(self) -> list[Path]: """ found_paths = [] if self.rocm_path: + # Determine host triple + clang_path = self.rocm_path / "lib" / "llvm" / "bin" / "amdclang" + if clang_path.exists(): + host_triple = subprocess.check_output( + [str(clang_path), "--print-target-triple"], text=True + ).strip() # Match discover_llvm_libdir_for_ompt() logic candidates = [ self.rocm_path / "llvm" / "lib", self.rocm_path / "lib" / "llvm" / "lib", ] + if host_triple: + candidates.append(self.rocm_path / "lib" / "llvm" / "lib" / host_triple) for candidate in candidates: if candidate.exists(): found_paths.append(candidate) From 9f72ebe95f5cd8043d1b60dd072f93c6deae7465 Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Wed, 17 Jun 2026 10:57:38 -0500 Subject: [PATCH 03/12] [rocprofiler-systems] - Add ROCPROFSYS_ROCM_LLVM_HOST_TRIPLE usage to common headers --- .../source/lib/common/CMakeLists.txt | 10 ++++++++++ .../rocprofiler-systems/source/lib/common/defines.h.in | 2 ++ .../source/lib/common/environment.hpp | 2 ++ 3 files changed, 14 insertions(+) diff --git a/projects/rocprofiler-systems/source/lib/common/CMakeLists.txt b/projects/rocprofiler-systems/source/lib/common/CMakeLists.txt index 14687e6d12c4..c1a5d97b9987 100644 --- a/projects/rocprofiler-systems/source/lib/common/CMakeLists.txt +++ b/projects/rocprofiler-systems/source/lib/common/CMakeLists.txt @@ -14,6 +14,16 @@ add_library( ALIAS rocprofiler-systems-common-library ) +# Query clang for host target triple for defines.h +# This is useful when LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON and +# the openmp libraries are installed one level deeper in lib/. +execute_process( + COMMAND "${ROCM_PATH}/lib/llvm/bin/amdclang" --print-target-triple + OUTPUT_VARIABLE LLVM_HOST_TRIPLE + OUTPUT_STRIP_TRAILING_WHITESPACE + COMMAND_ERROR_IS_FATAL ANY +) + configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/defines.h.in ${CMAKE_CURRENT_BINARY_DIR}/defines.h diff --git a/projects/rocprofiler-systems/source/lib/common/defines.h.in b/projects/rocprofiler-systems/source/lib/common/defines.h.in index 0c563dbf79bf..7080a611db88 100644 --- a/projects/rocprofiler-systems/source/lib/common/defines.h.in +++ b/projects/rocprofiler-systems/source/lib/common/defines.h.in @@ -47,6 +47,8 @@ #define ROCPROFSYS_ROCM_VERSION_MINOR @ROCPROFSYS_ROCM_VERSION_MINOR@ #define ROCPROFSYS_ROCM_VERSION_PATCH @ROCPROFSYS_ROCM_VERSION_PATCH@ +#define ROCPROFSYS_ROCM_LLVM_HOST_TRIPLE "@LLVM_HOST_TRIPLE@" + // these can be set via defining the variable in CMake, e.g.: // cmake -D ROCPROFSYS_CACHELINE_SIZE=N /path/to/source // if not defined when configuring cmake, these values fall back to diff --git a/projects/rocprofiler-systems/source/lib/common/environment.hpp b/projects/rocprofiler-systems/source/lib/common/environment.hpp index ceb15dc04f46..e7a28198581c 100644 --- a/projects/rocprofiler-systems/source/lib/common/environment.hpp +++ b/projects/rocprofiler-systems/source/lib/common/environment.hpp @@ -439,8 +439,10 @@ discover_llvm_libdir_for_ompt() } push_unique(rocm_dir + "/llvm/lib"); push_unique(rocm_dir + "/lib/llvm/lib"); + push_unique(rocm_dir + "/lib/llvm/lib/" + std::string{ROCPROFSYS_ROCM_LLVM_HOST_TRIPLE}); push_unique("/opt/rocm/llvm/lib"); push_unique("/opt/rocm/lib/llvm/lib"); + push_unique("/opt/rocm/lib/llvm/lib/" + std::string{ROCPROFSYS_ROCM_LLVM_HOST_TRIPLE}); auto has_libomptarget = [](const std::string& dir) { const std::string so = dir + "/libomptarget.so"; From fa4a7e284535a4fe228eedf564194e5aa3b34292 Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Wed, 17 Jun 2026 15:09:35 -0500 Subject: [PATCH 04/12] [rocprofiler-systems] - Format line break in environment.hpp --- .../rocprofiler-systems/source/lib/common/environment.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/projects/rocprofiler-systems/source/lib/common/environment.hpp b/projects/rocprofiler-systems/source/lib/common/environment.hpp index e7a28198581c..d519a29c3b60 100644 --- a/projects/rocprofiler-systems/source/lib/common/environment.hpp +++ b/projects/rocprofiler-systems/source/lib/common/environment.hpp @@ -439,10 +439,12 @@ discover_llvm_libdir_for_ompt() } push_unique(rocm_dir + "/llvm/lib"); push_unique(rocm_dir + "/lib/llvm/lib"); - push_unique(rocm_dir + "/lib/llvm/lib/" + std::string{ROCPROFSYS_ROCM_LLVM_HOST_TRIPLE}); + push_unique(rocm_dir + "/lib/llvm/lib/" + + std::string{ ROCPROFSYS_ROCM_LLVM_HOST_TRIPLE }); push_unique("/opt/rocm/llvm/lib"); push_unique("/opt/rocm/lib/llvm/lib"); - push_unique("/opt/rocm/lib/llvm/lib/" + std::string{ROCPROFSYS_ROCM_LLVM_HOST_TRIPLE}); + push_unique("/opt/rocm/lib/llvm/lib/" + + std::string{ ROCPROFSYS_ROCM_LLVM_HOST_TRIPLE }); auto has_libomptarget = [](const std::string& dir) { const std::string so = dir + "/libomptarget.so"; From ade19df43246a1222f971b19ebccbf18237e3ee8 Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Mon, 22 Jun 2026 11:56:26 -0500 Subject: [PATCH 05/12] [rocprofiler-systems] - Address PR comments - Move host_triple inside of clang path check. - Use find_program to locate amdclang. If LLVM_HOST_TRIPLE is empty a warning is reurned. --- .../source/lib/common/CMakeLists.txt | 39 ++++++++++++++++--- .../tests/pytest/rocprofsys/config.py | 14 +++---- 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/projects/rocprofiler-systems/source/lib/common/CMakeLists.txt b/projects/rocprofiler-systems/source/lib/common/CMakeLists.txt index c1a5d97b9987..3712f1caf6c0 100644 --- a/projects/rocprofiler-systems/source/lib/common/CMakeLists.txt +++ b/projects/rocprofiler-systems/source/lib/common/CMakeLists.txt @@ -17,12 +17,41 @@ add_library( # Query clang for host target triple for defines.h # This is useful when LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON and # the openmp libraries are installed one level deeper in lib/. -execute_process( - COMMAND "${ROCM_PATH}/lib/llvm/bin/amdclang" --print-target-triple - OUTPUT_VARIABLE LLVM_HOST_TRIPLE - OUTPUT_STRIP_TRAILING_WHITESPACE - COMMAND_ERROR_IS_FATAL ANY +find_program( + amdclang_EXECUTABLE + NAMES amdclang + HINTS ${ROCmVersion_DIR} ${ROCM_PATH} + ENV ROCM_PATH + /opt/rocm + PATHS ${ROCmVersion_DIR} ${ROCM_PATH} + ENV ROCM_PATH + /opt/rocm + PATH_SUFFIXES bin llvm/bin lib/llvm/bin ) +mark_as_advanced(amdclang_EXECUTABLE) +set(LLVM_HOST_TRIPLE "") +if(amdclang_EXECUTABLE) + execute_process( + COMMAND "${amdclang_EXECUTABLE}" --print-target-triple + OUTPUT_VARIABLE LLVM_HOST_TRIPLE + OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE _llvm_host_triple_result + ) + if(NOT _llvm_host_triple_result EQUAL 0) + set(LLVM_HOST_TRIPLE "") + rocprofiler_systems_message( + FATAL + "Failed to query LLVM host triple from ${amdclang_EXECUTABLE}; " + "libomptarget discovery for LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON may not work." + ) + endif() +else() + rocprofiler_systems_message( + WARNING + "Could not find amdclang to determine the LLVM host triple; " + "libomptarget discovery for LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON may not work." + ) +endif() configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/defines.h.in diff --git a/projects/rocprofiler-systems/tests/pytest/rocprofsys/config.py b/projects/rocprofiler-systems/tests/pytest/rocprofsys/config.py index c509b07b24cc..55a5e6defecc 100644 --- a/projects/rocprofiler-systems/tests/pytest/rocprofsys/config.py +++ b/projects/rocprofiler-systems/tests/pytest/rocprofsys/config.py @@ -84,19 +84,19 @@ def get_llvm_lib_paths(self) -> list[Path]: """ found_paths = [] if self.rocm_path: + # Match discover_llvm_libdir_for_ompt() logic + candidates = [ + self.rocm_path / "llvm" / "lib", + self.rocm_path / "lib" / "llvm" / "lib", + ] # Determine host triple clang_path = self.rocm_path / "lib" / "llvm" / "bin" / "amdclang" if clang_path.exists(): host_triple = subprocess.check_output( [str(clang_path), "--print-target-triple"], text=True ).strip() - # Match discover_llvm_libdir_for_ompt() logic - candidates = [ - self.rocm_path / "llvm" / "lib", - self.rocm_path / "lib" / "llvm" / "lib", - ] - if host_triple: - candidates.append(self.rocm_path / "lib" / "llvm" / "lib" / host_triple) + if host_triple: + candidates.append(self.rocm_path / "lib" / "llvm" / "lib" / host_triple) for candidate in candidates: if candidate.exists(): found_paths.append(candidate) From bf126de6c02d3e760161d1c51f2bc9e392da55fc Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Tue, 23 Jun 2026 17:52:21 -0500 Subject: [PATCH 06/12] [rocprofiler-systems] - guard llvm_host_triple path usage in environment.hpp If triple is empty do not push the path to the candidates. Increase candidates reserve to 8 (includes 2 new host triple paths). --- .../source/lib/common/environment.hpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/projects/rocprofiler-systems/source/lib/common/environment.hpp b/projects/rocprofiler-systems/source/lib/common/environment.hpp index d519a29c3b60..104245d0188e 100644 --- a/projects/rocprofiler-systems/source/lib/common/environment.hpp +++ b/projects/rocprofiler-systems/source/lib/common/environment.hpp @@ -419,7 +419,7 @@ discover_llvm_libdir_for_ompt() const auto rocm_dir = strip(get_env("ROCM_PATH", "/opt/rocm")); const auto rocmv_dir = strip(get_env("ROCmVersion_DIR", "")); - const constexpr auto number_of_candidates = 6; + const constexpr auto number_of_candidates = 8; std::vector candidates; candidates.reserve(number_of_candidates); @@ -439,12 +439,16 @@ discover_llvm_libdir_for_ompt() } push_unique(rocm_dir + "/llvm/lib"); push_unique(rocm_dir + "/lib/llvm/lib"); - push_unique(rocm_dir + "/lib/llvm/lib/" + - std::string{ ROCPROFSYS_ROCM_LLVM_HOST_TRIPLE }); + + const auto llvm_host_triple = strip(std::string{ ROCPROFSYS_ROCM_LLVM_HOST_TRIPLE }); + if(!llvm_host_triple.empty()) + { + push_unique(rocm_dir + "/lib/llvm/lib/" + llvm_host_triple); + push_unique("/opt/rocm/lib/llvm/lib/" + llvm_host_triple); + } + push_unique("/opt/rocm/llvm/lib"); push_unique("/opt/rocm/lib/llvm/lib"); - push_unique("/opt/rocm/lib/llvm/lib/" + - std::string{ ROCPROFSYS_ROCM_LLVM_HOST_TRIPLE }); auto has_libomptarget = [](const std::string& dir) { const std::string so = dir + "/libomptarget.so"; From d21d2ba1dbba1bbc12e3572b7607e0a96c04ad8d Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Tue, 23 Jun 2026 18:08:23 -0500 Subject: [PATCH 07/12] [rocprofiler-systems] - python formatting in config.py --- .../rocprofiler-systems/tests/pytest/rocprofsys/config.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/projects/rocprofiler-systems/tests/pytest/rocprofsys/config.py b/projects/rocprofiler-systems/tests/pytest/rocprofsys/config.py index 55a5e6defecc..f76f55fcf1b3 100644 --- a/projects/rocprofiler-systems/tests/pytest/rocprofsys/config.py +++ b/projects/rocprofiler-systems/tests/pytest/rocprofsys/config.py @@ -96,7 +96,9 @@ def get_llvm_lib_paths(self) -> list[Path]: [str(clang_path), "--print-target-triple"], text=True ).strip() if host_triple: - candidates.append(self.rocm_path / "lib" / "llvm" / "lib" / host_triple) + candidates.append( + self.rocm_path / "lib" / "llvm" / "lib" / host_triple + ) for candidate in candidates: if candidate.exists(): found_paths.append(candidate) From b39cf5f68da9cb69bc75f7473acae175dc774074 Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Wed, 24 Jun 2026 08:39:48 -0500 Subject: [PATCH 08/12] [rocprofiler-systems] - format spaces in in environment.hpp --- .../rocprofiler-systems/source/lib/common/environment.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/rocprofiler-systems/source/lib/common/environment.hpp b/projects/rocprofiler-systems/source/lib/common/environment.hpp index 104245d0188e..0268bf42ecd5 100644 --- a/projects/rocprofiler-systems/source/lib/common/environment.hpp +++ b/projects/rocprofiler-systems/source/lib/common/environment.hpp @@ -443,8 +443,8 @@ discover_llvm_libdir_for_ompt() const auto llvm_host_triple = strip(std::string{ ROCPROFSYS_ROCM_LLVM_HOST_TRIPLE }); if(!llvm_host_triple.empty()) { - push_unique(rocm_dir + "/lib/llvm/lib/" + llvm_host_triple); - push_unique("/opt/rocm/lib/llvm/lib/" + llvm_host_triple); + push_unique(rocm_dir + "/lib/llvm/lib/" + llvm_host_triple); + push_unique("/opt/rocm/lib/llvm/lib/" + llvm_host_triple); } push_unique("/opt/rocm/llvm/lib"); From a120d983a7bde3da69eff992e89f7cc9d6e369ce Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Fri, 26 Jun 2026 16:38:22 -0500 Subject: [PATCH 09/12] [rocprofiler-systems] - Add result variable to --print-target-triple Keep error quiet and set LLVM_HOST_TRIPLE to empty. --- .../examples/openmp/target/CMakeLists.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/projects/rocprofiler-systems/examples/openmp/target/CMakeLists.txt b/projects/rocprofiler-systems/examples/openmp/target/CMakeLists.txt index 8cd5087b515c..9cd04b1579b1 100644 --- a/projects/rocprofiler-systems/examples/openmp/target/CMakeLists.txt +++ b/projects/rocprofiler-systems/examples/openmp/target/CMakeLists.txt @@ -75,9 +75,19 @@ execute_process( COMMAND "${OMP_TARGET_COMPILER}" --print-target-triple OUTPUT_VARIABLE LLVM_HOST_TRIPLE OUTPUT_STRIP_TRAILING_WHITESPACE - COMMAND_ERROR_IS_FATAL ANY + ERROR_QUIET + RESULT_VARIABLE _llvm_host_triple_rc ) +if(NOT _llvm_host_triple_rc EQUAL 0) + set(LLVM_HOST_TRIPLE "") + rocprofiler_systems_message( + FATAL + "Failed to query LLVM host triple from ${amdclang_EXECUTABLE}; " + "libomptarget discovery for LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON may not work." + ) +endif() + # Find libomptarget find_library( LIBOMPTARGET_SO From 013ced7c1e54c3b066bd4e0b3d4c31b6488ffd7d Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Tue, 30 Jun 2026 10:41:42 -0500 Subject: [PATCH 10/12] [rocprofiler-systems] - Address comments in PR - Ensured if the clang target triple query fails that cmake throws a fatal error. - Added try/execpt for target triple querey in config.py. - Removed duplicate paths in find_program(amdclang) --- .../examples/openmp/target/CMakeLists.txt | 6 ++-- .../source/lib/common/CMakeLists.txt | 9 ++---- .../tests/pytest/rocprofsys/config.py | 32 +++++++++++++++---- 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/projects/rocprofiler-systems/examples/openmp/target/CMakeLists.txt b/projects/rocprofiler-systems/examples/openmp/target/CMakeLists.txt index 9cd04b1579b1..833be351f788 100644 --- a/projects/rocprofiler-systems/examples/openmp/target/CMakeLists.txt +++ b/projects/rocprofiler-systems/examples/openmp/target/CMakeLists.txt @@ -82,9 +82,9 @@ execute_process( if(NOT _llvm_host_triple_rc EQUAL 0) set(LLVM_HOST_TRIPLE "") rocprofiler_systems_message( - FATAL - "Failed to query LLVM host triple from ${amdclang_EXECUTABLE}; " - "libomptarget discovery for LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON may not work." + FATAL_ERROR + "'${OMP_TARGET_COMPILER} --print-target-triple' failed (exit code ${_llvm_host_triple_rc})" + "This toolchain may be broken." ) endif() diff --git a/projects/rocprofiler-systems/source/lib/common/CMakeLists.txt b/projects/rocprofiler-systems/source/lib/common/CMakeLists.txt index 3712f1caf6c0..96a4eb56ab24 100644 --- a/projects/rocprofiler-systems/source/lib/common/CMakeLists.txt +++ b/projects/rocprofiler-systems/source/lib/common/CMakeLists.txt @@ -23,9 +23,6 @@ find_program( HINTS ${ROCmVersion_DIR} ${ROCM_PATH} ENV ROCM_PATH /opt/rocm - PATHS ${ROCmVersion_DIR} ${ROCM_PATH} - ENV ROCM_PATH - /opt/rocm PATH_SUFFIXES bin llvm/bin lib/llvm/bin ) mark_as_advanced(amdclang_EXECUTABLE) @@ -40,9 +37,9 @@ if(amdclang_EXECUTABLE) if(NOT _llvm_host_triple_result EQUAL 0) set(LLVM_HOST_TRIPLE "") rocprofiler_systems_message( - FATAL - "Failed to query LLVM host triple from ${amdclang_EXECUTABLE}; " - "libomptarget discovery for LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON may not work." + FATAL_ERROR + "'${amdclang_EXECUTABLE} --print-target-triple' failed (exit code ${_llvm_host_triple_rc})" + "This toolchain may be broken." ) endif() else() diff --git a/projects/rocprofiler-systems/tests/pytest/rocprofsys/config.py b/projects/rocprofiler-systems/tests/pytest/rocprofsys/config.py index f76f55fcf1b3..583c2dad4edc 100644 --- a/projects/rocprofiler-systems/tests/pytest/rocprofsys/config.py +++ b/projects/rocprofiler-systems/tests/pytest/rocprofsys/config.py @@ -89,12 +89,32 @@ def get_llvm_lib_paths(self) -> list[Path]: self.rocm_path / "llvm" / "lib", self.rocm_path / "lib" / "llvm" / "lib", ] - # Determine host triple - clang_path = self.rocm_path / "lib" / "llvm" / "bin" / "amdclang" - if clang_path.exists(): - host_triple = subprocess.check_output( - [str(clang_path), "--print-target-triple"], text=True - ).strip() + # Determine the per-target runtime subdir used when + # LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON + clang_candidates = [ + self.rocm_path / "bin" / "amdclang", + self.rocm_path / "llvm" / "bin" / "amdclang", + self.rocm_path / "lib" / "llvm" / "bin" / "amdclang", + ] + clang_path = next((c for c in clang_candidates if c.exists()), None) + if clang_path is None: + which_clang = shutil.which("amdclang") + if which_clang: + clang_path = Path(which_clang) + if clang_path is not None: + try: + host_triple = subprocess.run( + [str(clang_path), "--print-target-triple"], + capture_output=True, + text=True, + timeout=10, + check=True, + ).stdout.strip() + except (subprocess.SubprocessError, OSError) as exc: + raise RuntimeError( + f"'{clang_path} --print-target-triple' failed; " + "this suggests a broken toolchain." + ) from exc if host_triple: candidates.append( self.rocm_path / "lib" / "llvm" / "lib" / host_triple From 68819c9ca48420d964d78081a46288730b2e1a46 Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Wed, 1 Jul 2026 08:39:28 -0500 Subject: [PATCH 11/12] [rocprofiler-tests] - Update get_llvm_lib_paths to cached_property - Renamed get_llvm_lib_paths to llvm_lib_paths - The triple returned from clang will be static and set at build time. - Moving the clang binary to a new system will not change the value. --- .../rocprofiler-systems/tests/pytest/rocprofsys/config.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/projects/rocprofiler-systems/tests/pytest/rocprofsys/config.py b/projects/rocprofiler-systems/tests/pytest/rocprofsys/config.py index 583c2dad4edc..4ab80c4187aa 100644 --- a/projects/rocprofiler-systems/tests/pytest/rocprofsys/config.py +++ b/projects/rocprofiler-systems/tests/pytest/rocprofsys/config.py @@ -3,6 +3,7 @@ from __future__ import annotations from dataclasses import dataclass, field +from functools import cached_property import getpass import os from pathlib import Path @@ -76,7 +77,8 @@ def capabilities(self) -> SystemCapabilities: self._capabilities = SystemCapabilities.from_config(self) return self._capabilities - def get_llvm_lib_paths(self) -> list[Path]: + @cached_property + def llvm_lib_paths(self) -> list[Path]: """Get list of found ROCm LLVM lib paths. Returns: @@ -143,7 +145,7 @@ def get_library_path(self) -> str: paths.append(existing) # Add ROCm LLVM lib as fallback - for llvm_path in self.get_llvm_lib_paths(): + for llvm_path in self.llvm_lib_paths: paths.append(str(llvm_path)) return ":".join(paths) From 0f2770b2865044bd278ae6af778afb838c90c401 Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Tue, 7 Jul 2026 23:51:10 -0500 Subject: [PATCH 12/12] [rocprofiler-systems] - fix exit code variable for llvm host triple --- projects/rocprofiler-systems/source/lib/common/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/rocprofiler-systems/source/lib/common/CMakeLists.txt b/projects/rocprofiler-systems/source/lib/common/CMakeLists.txt index 96a4eb56ab24..41e6d8562e99 100644 --- a/projects/rocprofiler-systems/source/lib/common/CMakeLists.txt +++ b/projects/rocprofiler-systems/source/lib/common/CMakeLists.txt @@ -38,7 +38,7 @@ if(amdclang_EXECUTABLE) set(LLVM_HOST_TRIPLE "") rocprofiler_systems_message( FATAL_ERROR - "'${amdclang_EXECUTABLE} --print-target-triple' failed (exit code ${_llvm_host_triple_rc})" + "'${amdclang_EXECUTABLE} --print-target-triple' failed (exit code ${_llvm_host_triple_result})" "This toolchain may be broken." ) endif()