Repository navigation
Conversation
The LLVM installation may be configured with per-target runtime directoreies. This means that core LLVM libraries are in `lib/` while language level runtimes (libomp) are in `lib/<triple>`. This PR looks up the LLVM host triple from the build compiler's printing option and simply appends it as an additional, optional search path in cases where we reference it.
|
Thanks @jhuber6 for the fix. |
|
Seems that when it chooses the lib from the triple, It is only seen in that workflow as the other either don't have a GPU or don't explicitly enable |
| import platform | ||
|
|
||
| host_triple = os.environ.get( | ||
| "LLVM_HOST_TRIPLE", f"{platform.machine()}-unknown-linux-gnu" |
There was a problem hiding this comment.
Should we have a helper to calculate compiler --print-target-triple instead??
| }(); | ||
|
|
||
| auto push_with_triple = [&](const std::string& base) { | ||
| push_unique(base); |
There was a problem hiding this comment.
Is it preferred to try the triple path first before the flat one?
I am not an expert about this but in the examples cmake we search the triple path first.
sputhala-amd
left a comment
There was a problem hiding this comment.
Please also add unit tests for this at: https://github.com/ROCm/rocm-systems/blob/develop/projects/rocprofiler-systems/source/lib/common/tests/test_discover_llvm_libdir.cpp
There was a problem hiding this comment.
Pull request overview
This PR extends LLVM/ROCm library search behavior to support installations that place language/runtime components under per-target directories (e.g., lib/<triple>), by discovering the host target triple and adding triple-qualified lib directories to candidate search paths.
Changes:
- Add host-triple-aware candidate paths for locating
libomptarget/LLVM runtime libraries in C++ environment discovery and pytest test configuration. - Introduce a configured build-time triple macro (
ROCPROFSYS_LLVM_HOST_TRIPLE) and populateLLVM_HOST_TRIPLEvia compiler introspection in CMake. - Update the OpenMP target example and compiler-launch wrapper script to prefer/append triple-specific lib directories when present.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| projects/rocprofiler-systems/tests/pytest/rocprofsys/config.py | Adds lib/<triple> candidates for ROCm LLVM lib discovery used by pytest environment setup. |
| projects/rocprofiler-systems/source/lib/common/environment.hpp | Extends OMPT LLVM libdir discovery to consider triple-qualified subdirectories. |
| projects/rocprofiler-systems/source/lib/common/defines.h.in | Adds a configured macro to embed the detected LLVM host triple at build time. |
| projects/rocprofiler-systems/scripts/rocprof-sys-launch-compiler | Prepends ${LLVM_LIB_DIR}/${triple} to LIBRARY_PATH when available for amdclang/amdllvm. |
| projects/rocprofiler-systems/examples/openmp/target/CMakeLists.txt | Adds triple-aware hints/rpath entries when locating libomptarget. |
| projects/rocprofiler-systems/CMakeLists.txt | Detects LLVM_HOST_TRIPLE via the configured C++ compiler and exposes it for configuration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import os | ||
| import platform | ||
|
|
||
| host_triple = os.environ.get( | ||
| "LLVM_HOST_TRIPLE", f"{platform.machine()}-unknown-linux-gnu" | ||
| ) |
| if(NOT DEFINED LLVM_HOST_TRIPLE) | ||
| execute_process( | ||
| COMMAND ${CMAKE_CXX_COMPILER} --print-target-triple | ||
| OUTPUT_VARIABLE LLVM_HOST_TRIPLE | ||
| OUTPUT_STRIP_TRAILING_WHITESPACE | ||
| ERROR_QUIET | ||
| ) |
| if(NOT DEFINED LLVM_HOST_TRIPLE) | ||
| execute_process( | ||
| COMMAND ${OMP_TARGET_COMPILER} --print-target-triple | ||
| OUTPUT_VARIABLE LLVM_HOST_TRIPLE | ||
| OUTPUT_STRIP_TRAILING_WHITESPACE | ||
| ERROR_QUIET | ||
| ) | ||
| endif() |
| auto host_triple = []() -> std::string { | ||
| if(auto* env = std::getenv("LLVM_HOST_TRIPLE"); env && *env) return env; | ||
| constexpr auto builtin = std::string_view{ ROCPROFSYS_LLVM_HOST_TRIPLE }; | ||
| if(!builtin.empty()) return std::string{ builtin }; | ||
| return {}; | ||
| }(); |
The LLVM installation may be configured with per-target runtime
directoreies. This means that core LLVM libraries are in
lib/whilelanguage level runtimes (libomp) are in
lib/<triple>. This PR looks upthe LLVM host triple from the build compiler's printing option and
simply appends it as an additional, optional search path in cases where
we reference it.