Skip to content

Respect per-target LLVM directory in search paths - #6647

Closed
jhuber6 wants to merge 1 commit into
ROCm:developfrom
jhuber6:PerTargetDir
Closed

jhuber6 wants to merge 1 commit into
ROCm:developfrom
jhuber6:PerTargetDir

Conversation

@jhuber6

@jhuber6 jhuber6 commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

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.

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.
@sputhala-amd

Copy link
Copy Markdown
Contributor

Thanks @jhuber6 for the fix.
Can you provide more details about the problem/issue, like which rocm version and what distribution the issue with target-triple layout is encountered?

@kcossett-amd

Copy link
Copy Markdown
Contributor

Seems that when it chooses the lib from the triple, dyninst hangs within processCreate: https://github.com/ROCm/rocm-systems/actions/runs/26764571807/job/78909667095?pr=6647 as seen by the openmp-offload-fortran-runtime-instrument test.

It is only seen in that workflow as the other either don't have a GPU or don't explicitly enable openmp-offload-fortran-runtime-instrument test.

import platform

host_triple = os.environ.get(
"LLVM_HOST_TRIPLE", f"{platform.machine()}-unknown-linux-gnu"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have a helper to calculate compiler --print-target-triple instead??

}();

auto push_with_triple = [&](const std::string& base) {
push_unique(base);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 sputhala-amd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 populate LLVM_HOST_TRIPLE via 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.

Comment on lines +85 to +90
import os
import platform

host_triple = os.environ.get(
"LLVM_HOST_TRIPLE", f"{platform.machine()}-unknown-linux-gnu"
)
Comment on lines +139 to +145
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
)
Comment on lines +70 to +77
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()
Comment on lines +210 to +215
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 {};
}();
@sputhala-amd

Copy link
Copy Markdown
Contributor

Is this a duplicate of #7334. If so this PR can be closed. @jhuber6

@jhuber6 jhuber6 closed this Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants