Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
easyblock = 'Bundle'

name = 'ROCm-LLVM'
_llvm_version = '19.0.0'
version = _llvm_version
_rocm_version = '6.4.1'
versionsuffix = f'-ROCm-{_rocm_version}'

homepage = 'https://github.com/ROCm/llvm-project'
description = """ROCm-LLVM is an open source Clang/LLVM based compiler.
It is an AMD Fork of The LLVM Compiler Infrastructure, and aims to contain all of upstream LLVM.
It also includes several AMD-specific additions in the llvm-project/amd directory."""
docurls = ['https://rocmdocs.amd.com']

toolchain = {'name': 'GCCcore', 'version': '14.2.0'}

builddependencies = [
('CMake', '3.31.3'),
('Perl', '5.40.0'),
('Python', '3.13.1'),
('pkgconf', '2.3.0'),
('xxd', '9.1.1457'), # required for ROCr-Runtime
]

dependencies = [
('binutils', '2.42'),
('elfutils', '0.193'),
('zlib', '1.3.1'),
('hwloc', '2.11.2'),
('GMP', '6.3.0'),
('libxml2', '2.13.4'),
('ncurses', '6.5'),
('libffi', '3.4.5'),
('libdrm', '2.4.125'),
('numactl', '2.0.19'),
('Z3', '4.13.4'),
]

local_rocm_llvm_source = 'llvm-project-rocm-%s.tar.gz' % _rocm_version
local_common_cmake_configopts = ' '.join([
'-DCMAKE_C_COMPILER=%(installdir)s/bin/clang',
'-DCMAKE_CXX_COMPILER=%(installdir)s/bin/clang++',
'-DLLVM_INSTALL_PREFIX=%(installdir)s',
'-DLLVM_DIR=%(installdir)s/lib/cmake/llvm',
])

checksums = [{
'llvm-project-rocm-6.4.1.tar.gz':
'460ad28677092b9eb86ffdc49bcb4d01035e32b4f05161d85f90c9fa80239f50',
'ROCR-Runtime-rocm-6.4.1.tar.gz':
'f72d100a46a2dd9f4c870cef156604777f1bdb1841df039d14bf37b19814b9da',
'aomp-extras-rocm-6.4.1.tar.gz':
'cf20b02b1f99f506c198866ef03f2265dc355627760f82cda3878d5bc6486afc',
'ROCm-LLVM-6.4.1_llvm-project-19.0.0_fix-offload-build.patch':
'2ce1454aa3d2f50795bbc331c239f44be07f8ec836978cad130406af4340e30d',
}]

default_easyblock = 'CMakeMake'

default_component_specs = {
'source_urls': ['https://github.com/ROCm/%(name)s/archive/'],
'sources': [{
'download_filename': '%(version)s.tar.gz',
'filename': '%(name)s-%(version)s.tar.gz',
}],
'srcdir': '%(name)s-%(version)s',
}

components = [
('llvm-project', '%s-rocm-%s' % (_llvm_version, _rocm_version), {
'easyblock': 'EB_ROCm_minus_LLVM',
'sources': [{
'download_filename': 'rocm-%s.tar.gz' % _rocm_version,
'filename': local_rocm_llvm_source,
# rename the extracted directory to the one that the LLVM easyblock expects
'extract_cmd': 'tar xfz %%s && mv %%(name)s-rocm-%s %%(name)s-%%(version)s.src' % _rocm_version,
}],
'start_dir': f'llvm-project-{_llvm_version}-rocm-{_rocm_version}.src',
'bootstrap': True,
'build_lld': True,
'build_clang_extras': True,
'build_openmp_offload': False,
'build_openmp_tools': True,
'build_runtimes': True,
'full_llvm': False,
'skip_all_tests': True,
}),
('ROCm-comgr', 'rocm-%s' % _rocm_version, {
# sources are located in amd/comgr subdir of llvm-project component
'sources': [{'filename': local_rocm_llvm_source, 'extract_cmd': 'echo %s'}],
'srcdir': 'llvm-project-%s-%%(version)s.src/amd/comgr' % _llvm_version,
'prebuildopts': 'export ROCM_PATH=%(installdir)s && ',
'configopts': local_common_cmake_configopts + ' -DROCM_DIR=%(installdir)s/share/rocm/cmake'
}),
('ROCR-Runtime', 'rocm-%s' % _rocm_version, {
'srcdir': '%(name)s-%(version)s',
'configopts': local_common_cmake_configopts + ' -DBUILD_SHARED_LIBS=ON',
}),
('llvm-project-openmp', '%s-rocm-%s' % (_llvm_version, _rocm_version), {
'easyblock': 'EB_ROCm_minus_LLVM',
'sources': [{
'download_filename': 'rocm-%s.tar.gz' % _rocm_version,
'filename': local_rocm_llvm_source,
# rename the extracted directory to the one that the LLVM easyblock expects
# we need to extract the sources again so that potential source changes done by easyblocks
# do not cause unintended behaviour in the second build
'extract_cmd': 'tar xfz %%s && mv llvm-project-rocm-%s %%(name)s-%%(version)s.src' % _rocm_version,
}],
'patches': [
'ROCm-LLVM-6.4.1_llvm-project-19.0.0_fix-offload-build.patch',
],
'start_dir': f'llvm-project-openmp-{_llvm_version}-rocm-{_rocm_version}.src',
'bootstrap': True,
'build_lld': True,
'build_clang_extras': True,
'build_openmp_offload': True,
'build_openmp_tools': True,
'build_runtimes': True,
'full_llvm': False,
'skip_all_tests': True,
}),
('aomp-extras', 'rocm-%s' % _rocm_version, {
'configopts':
local_common_cmake_configopts +
' -DAOMP_STANDALONE_BUILD=0 '
'-DAOMP_VERSION_STRING=%s ' % _rocm_version
}),

]

sanity_check_components = ['llvm-project']

modextravars = {
'HIP_DEVICE_LIB_PATH': '%(installdir)s/amdgcn/bitcode',
}

moduleclass = 'tools'
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
This patch contains two parts:
1. Update how the ROCm .bc libraries are found. Older ROCm versions are very sensetive when it comes
to LIBRARY_PATH being set, easily causing errors because the .bc files weren't found.
The changes implemented in e3ea278 [a] improve the situation, by allowing searching in additional paths.
Expanded the patch to ensure that this detection also works when .bc files are within its own target directory.
2. Fix missing braces in OmptTracing, which could cause compilation failures due to the macro expanded being
longer than a single line.

[a] https://github.com/ROCm/llvm-project/commit/e3ea27822c6bf53554a93ac777de4fb430227f29

Author: Jan Andre Reuter ([email protected])

diff --color -Naur llvm-project-rocm-6.4.1.orig/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp llvm-project-rocm-6.4.1/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
--- llvm-project-rocm-6.4.1.orig/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp 2025-05-08 21:07:38.000000000 +0200
+++ llvm-project-rocm-6.4.1/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp 2025-06-30 19:59:40.693751999 +0200
@@ -232,12 +232,6 @@
LibSuffix.append("/asan");
}

- // If device debugging turned on, add specially built bc files
- StringRef libpath = Args.MakeArgString(C.getDriver().Dir + "/../" + LibSuffix);
- std::string lib_debug_perf_path = FindDebugPerfInLibraryPath(LibSuffix);
- if (!lib_debug_perf_path.empty())
- libpath = lib_debug_perf_path;
-
llvm::SmallVector<std::string, 12> BCLibs;

std::string AsanRTL;
@@ -260,27 +254,33 @@
// not the installed compiler.
std::string LibDeviceName = "/libomptarget-amdgpu-" + GPUArch.str() + ".bc";

- SmallString<128> Path(Args.MakeArgString(libpath + LibDeviceName));
- if (LibSuffix != "lib" || llvm::sys::fs::exists(Path)) {
- BCLibs.push_back(Args.MakeArgString(Path));
- } else {
- // Check if the device library can be found in
- // one of the LIBRARY_PATH directories.
- bool EnvOmpLibDeviceFound = false;
- for (auto &EnvLibraryPath : EnvironmentLibraryPaths) {
- std::string EnvOmpLibDevice = EnvLibraryPath + LibDeviceName;
- if (llvm::sys::fs::exists(EnvOmpLibDevice)) {
- EnvOmpLibDeviceFound = true;
- BCLibs.push_back(EnvOmpLibDevice);
- break;
- }
- }
- // If LIBRARY_PATH doesn't point to the device library,
- // then use the default one.
- if (!EnvOmpLibDeviceFound) {
- std::string RtDir = "/../runtimes/runtimes-bins/offload";
- BCLibs.push_back(Args.MakeArgString(libpath + RtDir + LibDeviceName));
- }
+ // Check if libomptarget device bitcode can be found in a LIBRARY_PATH dir
+ bool EnvOmpLibDeviceFound = false;
+ for (auto &EnvLibraryPath : EnvironmentLibraryPaths) {
+ std::string EnvOmpLibDevice = EnvLibraryPath + LibDeviceName;
+ if (llvm::sys::fs::exists(EnvOmpLibDevice)) {
+ EnvOmpLibDeviceFound = true;
+ BCLibs.push_back(EnvOmpLibDevice);
+ break;
+ }
+ }
+
+ // If not found in LIBRARY_PATH, use default for the correct LibSuffix.
+ if (!EnvOmpLibDeviceFound) {
+ StringRef bc_file_suf = Args.MakeArgString(C.getDriver().Dir + "/../" +
+ LibSuffix + LibDeviceName);
+ StringRef bc_file_lib =
+ Args.MakeArgString(C.getDriver().Dir + "/../lib" + LibDeviceName);
+ StringRef bc_file_target_suf =
+ Args.MakeArgString(C.getDriver().Dir + "/../lib/" +
+ LLVM_DEFAULT_TARGET_TRIPLE + "/" + LibDeviceName);
+ if (llvm::sys::fs::exists(bc_file_suf))
+ BCLibs.push_back(Args.MakeArgString(bc_file_suf));
+ else if (llvm::sys::fs::exists(bc_file_lib))
+ // In case a LibSuffix version not found, use suffix "lib"
+ BCLibs.push_back(Args.MakeArgString(bc_file_lib));
+ else if (llvm::sys::fs::exists(bc_file_target_suf))
+ BCLibs.push_back(Args.MakeArgString(bc_file_target_suf));
}

if (!AsanRTL.empty()) {
diff --color -Naur llvm-project-rocm-6.4.1.orig/clang/lib/Driver/ToolChains/CommonArgs.cpp llvm-project-rocm-6.4.1/clang/lib/Driver/ToolChains/CommonArgs.cpp
--- llvm-project-rocm-6.4.1.orig/clang/lib/Driver/ToolChains/CommonArgs.cpp 2025-05-08 21:07:38.000000000 +0200
+++ llvm-project-rocm-6.4.1/clang/lib/Driver/ToolChains/CommonArgs.cpp 2025-06-30 20:17:20.183880125 +0200
@@ -1162,29 +1162,6 @@
}
}

-std::string tools::FindDebugPerfInLibraryPath(const std::string &RLib) {
- const char *DirList = ::getenv("LIBRARY_PATH");
- if (!DirList)
- return "";
- StringRef Dirs(DirList);
- if (Dirs.empty()) // Empty string should not add '.'.
- return "";
-
- StringRef::size_type Delim;
- while ((Delim = Dirs.find(llvm::sys::EnvPathSeparator)) != StringRef::npos) {
- if (Delim != 0) { // Leading colon.
- if (Dirs.substr(0, Delim).ends_with(RLib))
- return Dirs.substr(0, Delim).str();
- }
- Dirs = Dirs.substr(Delim + 1);
- }
- if (!Dirs.empty()) {
- if (Dirs.ends_with(RLib))
- return Dirs.str();
- }
- return "";
-}
-
void tools::addOpenMPRuntimeSpecificRPath(const ToolChain &TC,
const ArgList &Args,
ArgStringList &CmdArgs) {
@@ -1200,9 +1177,16 @@
if (TC.getSanitizerArgs(Args).needsAsanRt())
LibSuffix.append("/asan");
}
- std::string CandidateRPath = FindDebugPerfInLibraryPath(LibSuffix);
- if (CandidateRPath.empty())
- CandidateRPath = D.Dir + "/../" + LibSuffix;
+ // Check if the device library cna be found in
+ // one of the LIBRARY_PATH directories.
+ ArgStringList EnvLibraryPaths;
+ addDirectoryList(Args, EnvLibraryPaths, "", "LIBRARY_PATH");
+ for (auto &EnvLibraryPath : EnvLibraryPaths) {
+ if(llvm::sys::fs::exists(EnvLibraryPath)) {
+ CmdArgs.push_back("-rpath");
+ CmdArgs.push_back(Args.MakeArgString(EnvLibraryPath));
+ }
+ }

if (Args.hasFlag(options::OPT_fopenmp_implicit_rpath,
options::OPT_fno_openmp_implicit_rpath, true)) {
@@ -1215,8 +1199,41 @@
CmdArgs.push_back("-rpath");
CmdArgs.push_back(Args.MakeArgString(TC.getCompilerRTPath()));
}
+
+ // In case LibSuffix was not built, try lib
+ std::string CandidateRPath_suf = D.Dir + "/../" + LibSuffix;
CmdArgs.push_back("-rpath");
- CmdArgs.push_back(Args.MakeArgString(CandidateRPath.c_str()));
+ CmdArgs.push_back(Args.MakeArgString(CandidateRPath_suf.c_str()));
+
+ // Add lib directory in case LibSuffix does not exist
+ std::string CandidateRPath_lib = D.Dir + "/../lib";
+ if ((!llvm::sys::fs::exists(CandidateRPath_suf)) &&
+ (llvm::sys::fs::exists(CandidateRPath_lib))) {
+ CmdArgs.push_back("-rpath");
+ CmdArgs.push_back(Args.MakeArgString(CandidateRPath_lib.c_str()));
+ }
+
+ std::string rocmPath =
+ Args.getLastArgValue(clang::driver::options::OPT_rocm_path_EQ).str();
+ if(rocmPath.size() != 0) {
+ std::string rocmPath_lib = rocmPath + "/lib";
+ std::string rocmPath_suf = rocmPath + "/" + LibSuffix;
+ std::string rocmPath_target_lib =
+ rocmPath + "/lib/" + LLVM_DEFAULT_TARGET_TRIPLE;
+ if(llvm::sys::fs::exists(rocmPath_suf)) {
+ CmdArgs.push_back("-rpath");
+ CmdArgs.push_back(Args.MakeArgString(rocmPath_suf.c_str()));
+ }
+ if(llvm::sys::fs::exists(rocmPath_lib)) {
+ CmdArgs.push_back("-rpath");
+ CmdArgs.push_back(Args.MakeArgString(rocmPath_lib.c_str()));
+ }
+ if(llvm::sys::fs::exists(rocmPath_target_lib)) {
+ CmdArgs.push_back("-rpath");
+ CmdArgs.push_back(Args.MakeArgString(rocmPath_target_lib.c_str()));
+ }
+ }
+
if (llvm::find_if(CmdArgs, [](StringRef str) {
return !str.compare("--enable-new-dtags");
}) == CmdArgs.end())
diff --color -Naur llvm-project-rocm-6.4.1.orig/clang/lib/Driver/ToolChains/CommonArgs.h llvm-project-rocm-6.4.1/clang/lib/Driver/ToolChains/CommonArgs.h
--- llvm-project-rocm-6.4.1.orig/clang/lib/Driver/ToolChains/CommonArgs.h 2025-05-08 21:07:38.000000000 +0200
+++ llvm-project-rocm-6.4.1/clang/lib/Driver/ToolChains/CommonArgs.h 2025-06-30 19:52:52.947564571 +0200
@@ -119,8 +119,6 @@
const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs);

-std::string FindDebugPerfInLibraryPath(const std::string &RLib);
-
void addOpenMPRuntimeSpecificRPath(const ToolChain &TC,
const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs);
diff --color -Naur llvm-project-rocm-6.4.1.orig/offload/plugins-nextgen/common/OMPT/OmptTracing.cpp llvm-project-rocm-6.4.1/offload/plugins-nextgen/common/OMPT/OmptTracing.cpp
--- llvm-project-rocm-6.4.1.orig/offload/plugins-nextgen/common/OMPT/OmptTracing.cpp 2025-05-08 21:07:38.000000000 +0200
+++ llvm-project-rocm-6.4.1/offload/plugins-nextgen/common/OMPT/OmptTracing.cpp 2025-06-28 00:28:33.718073512 +0200
@@ -95,11 +95,12 @@
auto DeviceIterator = Devices.find(Device);
if (DeviceIterator != Devices.end()) {
auto CurrentDeviceId = DeviceIterator->second;
- if (DeviceId == CurrentDeviceId)
+ if (DeviceId == CurrentDeviceId) {
REPORT("Tried to duplicate OMPT Device=%p (ID=%d)\n", Device, DeviceId);
- else
+ } else {
REPORT("Tried to overwrite OMPT Device=%p (ID=%d with new ID=%d)\n",
Device, CurrentDeviceId, DeviceId);
+ }
return;
}
Devices.emplace(Device, DeviceId);
Loading