summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFco Javier Felix <ffelix@inode64.com>2022-02-11 18:09:22 +0200
committerJoonas Niilola <juippis@gentoo.org>2022-02-11 18:12:44 +0200
commitd2a17410775f2c569c1e091decfe41467680deef (patch)
tree34a23b608ca4b791659cd655f3d898ede8973183 /sys-devel/llvm-roc
parentdev-util/rocm-cmake: bump to 4.5.2 (diff)
downloadgentoo-d2a17410775f2c569c1e091decfe41467680deef.tar.gz
gentoo-d2a17410775f2c569c1e091decfe41467680deef.tar.bz2
gentoo-d2a17410775f2c569c1e091decfe41467680deef.zip
sys-devel/llvm-roc: bump to 4.5.2
Closes: https://bugs.gentoo.org/802924 Package-Manager: Portage-3.0.28-r1, Repoman-3.0.3-r1 Signed-off-by: Fco. Javier Felix <ffelix@inode64.com> Closes: https://github.com/gentoo/gentoo/pull/23343 Signed-off-by: Joonas Niilola <juippis@gentoo.org>
Diffstat (limited to 'sys-devel/llvm-roc')
-rw-r--r--sys-devel/llvm-roc/Manifest1
-rw-r--r--sys-devel/llvm-roc/files/llvm-roc-4.5.2-add_libraries.patch11
-rw-r--r--sys-devel/llvm-roc/files/llvm-roc-4.5.2-hip-location.patch188
-rw-r--r--sys-devel/llvm-roc/llvm-roc-4.5.2.ebuild97
4 files changed, 297 insertions, 0 deletions
diff --git a/sys-devel/llvm-roc/Manifest b/sys-devel/llvm-roc/Manifest
index 80142c713222..59e7a38b07c4 100644
--- a/sys-devel/llvm-roc/Manifest
+++ b/sys-devel/llvm-roc/Manifest
@@ -8,3 +8,4 @@ DIST llvm-rocm-ocl-4.1.0.tar.gz 128913932 BLAKE2B 15a041ec7b9fec91e409c8ab98ff88
DIST llvm-rocm-ocl-4.1.1.tar.gz 128914019 BLAKE2B 9806d1da497e9d9864fd015fc92f5e2d8a6077315d96538064357a38347bc9180948c65cdca9e29574b40f8df62c0660762731564822ac9e8b5364bebf016e43 SHA512 0e4c6b9b0c0330d58616f22d8ec6ebdd6c83aef9ce9968765ac56c022bcd76cba8af5a6cdfb47ed560b33cd67832ac5b026502357af6caec4ab699f1443163fd
DIST llvm-rocm-ocl-4.2.0.tar.gz 132337711 BLAKE2B f08781f881f2853cd551828ef9190c1253e33ca1bfb13aac790b6484838fe5481be9519609ea9cf4bc09a6c8631c54a567123dfe97c25498c51c464d215049de SHA512 694c37c707c84d18cddb92054d8d59e1eea82c9c9928d0111992cbae1421d6bb614a0889891993b444a821c35fa6e91c801ac8555761c2cd0803f89981475952
DIST llvm-rocm-ocl-4.3.0.tar.gz 134152148 BLAKE2B aaadb75f0b2f72d3c4dca4b375a38b2806491b854d45f6f95bc398c4b7685fccbc4e6df86869c200f08ced5ddb540344ace2402819cdd3c27c5167a71a78bb3b SHA512 4f85f06d5331770b8697bbe62776579ed02016d899ed9c5328d5953fc5992a0996f7934e7417d6062e77a317d242295803fbeab04b0428d5f257cecd4c25c0cd
+DIST llvm-rocm-ocl-4.5.2.tar.gz 137370130 BLAKE2B f91823b9f0a3b78062eb5e9aa564a31752ab377bebc613892938d4aa6f8e54eb2b00123d0e60e5e703cd41d380cedac07234f024e3812b8df71519d0c7c32625 SHA512 fa4147e73fd37db6735e29cb99c5a7da4edcd1f51af30574d35a359b483aba4b3d4bdefa0845d3991fc0d0758b3e403e7e252033712cc4a8c038d07d9539c18f
diff --git a/sys-devel/llvm-roc/files/llvm-roc-4.5.2-add_libraries.patch b/sys-devel/llvm-roc/files/llvm-roc-4.5.2-add_libraries.patch
new file mode 100644
index 000000000000..e2fe9282d837
--- /dev/null
+++ b/sys-devel/llvm-roc/files/llvm-roc-4.5.2-add_libraries.patch
@@ -0,0 +1,11 @@
+diff -Naur a/clang/lib/Basic/CMakeLists.txt b/clang/lib/Basic/CMakeLists.txt
+--- a/clang/lib/Basic/CMakeLists.txt 2019-12-28 07:42:49.119055933 +0100
++++ b/clang/lib/Basic/CMakeLists.txt 2019-12-28 07:42:13.265056070 +0100
+@@ -2,6 +2,7 @@
+ Core
+ MC
+ Support
++ Option
+ )
+
+ find_first_existing_vc_file("${LLVM_MAIN_SRC_DIR}" llvm_vc)
diff --git a/sys-devel/llvm-roc/files/llvm-roc-4.5.2-hip-location.patch b/sys-devel/llvm-roc/files/llvm-roc-4.5.2-hip-location.patch
new file mode 100644
index 000000000000..7b5714e610a7
--- /dev/null
+++ b/sys-devel/llvm-roc/files/llvm-roc-4.5.2-hip-location.patch
@@ -0,0 +1,188 @@
+replace hardcoded hip finder with Gentoo paths.
+
+It is not necessary to check HIP runtime each time.
+
+Author: Benda Xu <heroxbd@gentoo.org>
+Author: Yiyang Wu <xgreenlandforwyy@gmail.com>
+
+--- orig/clang/lib/Driver/ToolChains/AMDGPU.cpp
++++ llvm-project-rocm-4.3.0/clang/lib/Driver/ToolChains/AMDGPU.cpp
+@@ -165,133 +165,7 @@
+ /// cached and populated only once.
+ const SmallVectorImpl<RocmInstallationDetector::Candidate> &
+ RocmInstallationDetector::getInstallationPathCandidates() {
+-
+- // Return the cached candidate list if it has already been populated.
+- if (!ROCmSearchDirs.empty())
+- return ROCmSearchDirs;
+-
+- auto DoPrintROCmSearchDirs = [&]() {
+- if (PrintROCmSearchDirs)
+- for (auto Cand : ROCmSearchDirs) {
+- llvm::errs() << "ROCm installation search path";
+- if (Cand.isSPACK())
+- llvm::errs() << " (Spack " << Cand.SPACKReleaseStr << ")";
+- llvm::errs() << ": " << Cand.Path << '\n';
+- }
+- };
+-
+- // For candidate specified by --rocm-path we do not do strict check, i.e.,
+- // checking existence of HIP version file and device library files.
+- if (!RocmPathArg.empty()) {
+- ROCmSearchDirs.emplace_back(RocmPathArg.str());
+- DoPrintROCmSearchDirs();
+- return ROCmSearchDirs;
+- } else if (const char *RocmPathEnv = ::getenv("ROCM_PATH")) {
+- if (!StringRef(RocmPathEnv).empty()) {
+- ROCmSearchDirs.emplace_back(RocmPathEnv);
+- DoPrintROCmSearchDirs();
+- return ROCmSearchDirs;
+- }
+- }
+-
+- // Try to find relative to the compiler binary.
+- const char *InstallDir = D.getInstalledDir();
+-
+- // Check both a normal Unix prefix position of the clang binary, as well as
+- // the Windows-esque layout the ROCm packages use with the host architecture
+- // subdirectory of bin.
+- auto DeduceROCmPath = [](StringRef ClangPath) {
+- // Strip off directory (usually bin)
+- StringRef ParentDir = llvm::sys::path::parent_path(ClangPath);
+- StringRef ParentName = llvm::sys::path::filename(ParentDir);
+-
+- // Some builds use bin/{host arch}, so go up again.
+- if (ParentName == "bin") {
+- ParentDir = llvm::sys::path::parent_path(ParentDir);
+- ParentName = llvm::sys::path::filename(ParentDir);
+- }
+-
+- // Detect ROCm packages built with SPACK.
+- // clang is installed at
+- // <rocm_root>/llvm-amdgpu-<rocm_release_string>-<hash>/bin directory.
+- // We only consider the parent directory of llvm-amdgpu package as ROCm
+- // installation candidate for SPACK.
+- if (ParentName.startswith("llvm-amdgpu-")) {
+- auto SPACKPostfix =
+- ParentName.drop_front(strlen("llvm-amdgpu-")).split('-');
+- auto SPACKReleaseStr = SPACKPostfix.first;
+- if (!SPACKReleaseStr.empty()) {
+- ParentDir = llvm::sys::path::parent_path(ParentDir);
+- return Candidate(ParentDir.str(), /*StrictChecking=*/true,
+- SPACKReleaseStr);
+- }
+- }
+-
+- // Some versions of the rocm llvm package install to /opt/rocm/llvm/bin
+- // Some versions of the aomp package install to /opt/rocm/aomp/bin
+- if (ParentName == "llvm" || ParentName.startswith("aomp"))
+- ParentDir = llvm::sys::path::parent_path(ParentDir);
+- // Some versions of the aomp package install to /opt/rocm/aomp/bin
+- // and it seems ParentDir is already pointing to correct place.
+- return Candidate(ParentDir.str(), /*StrictChecking=*/true);
+- };
+-
+- // Deduce ROCm path by the path used to invoke clang. Do not resolve symbolic
+- // link of clang itself.
+- ROCmSearchDirs.emplace_back(DeduceROCmPath(InstallDir));
+-
+- // Deduce ROCm path by the real path of the invoked clang, resolving symbolic
+- // link of clang itself.
+- llvm::SmallString<256> RealClangPath;
+- llvm::sys::fs::real_path(D.getClangProgramPath(), RealClangPath);
+- auto ParentPath = llvm::sys::path::parent_path(RealClangPath);
+- if (ParentPath != InstallDir)
+- ROCmSearchDirs.emplace_back(DeduceROCmPath(ParentPath));
+-
+- // Device library may be installed in clang resource directory.
+- ROCmSearchDirs.emplace_back(D.ResourceDir,
+- /*StrictChecking=*/true);
+-
+- ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/rocm",
+- /*StrictChecking=*/true);
+-
+- // Find the latest /opt/rocm-{release} directory.
+- std::error_code EC;
+- std::string LatestROCm;
+- llvm::VersionTuple LatestVer;
+- // Get ROCm version from ROCm directory name.
+- auto GetROCmVersion = [](StringRef DirName) {
+- llvm::VersionTuple V;
+- std::string VerStr = DirName.drop_front(strlen("rocm-")).str();
+- // The ROCm directory name follows the format of
+- // rocm-{major}.{minor}.{subMinor}[-{build}]
+- std::replace(VerStr.begin(), VerStr.end(), '-', '.');
+- V.tryParse(VerStr);
+- return V;
+- };
+- for (llvm::vfs::directory_iterator
+- File = D.getVFS().dir_begin(D.SysRoot + "/opt", EC),
+- FileEnd;
+- File != FileEnd && !EC; File.increment(EC)) {
+- llvm::StringRef FileName = llvm::sys::path::filename(File->path());
+- if (!FileName.startswith("rocm-"))
+- continue;
+- if (LatestROCm.empty()) {
+- LatestROCm = FileName.str();
+- LatestVer = GetROCmVersion(LatestROCm);
+- continue;
+- }
+- auto Ver = GetROCmVersion(FileName);
+- if (LatestVer < Ver) {
+- LatestROCm = FileName.str();
+- LatestVer = Ver;
+- }
+- }
+- if (!LatestROCm.empty())
+- ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm,
+- /*StrictChecking=*/true);
+-
+- DoPrintROCmSearchDirs();
++ ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", /*StrictChecking=*/true);
+ return ROCmSearchDirs;
+ }
+
+@@ -424,42 +298,7 @@
+ }
+
+ void RocmInstallationDetector::detectHIPRuntime() {
+- SmallVector<Candidate, 4> HIPSearchDirs;
+- if (!HIPPathArg.empty())
+- HIPSearchDirs.emplace_back(HIPPathArg.str(), /*StrictChecking=*/true);
+- else
+- HIPSearchDirs.append(getInstallationPathCandidates());
+- auto &FS = D.getVFS();
+-
+- for (const auto &Candidate : HIPSearchDirs) {
+- InstallPath = Candidate.Path;
+- if (InstallPath.empty() || !FS.exists(InstallPath))
+- continue;
+- // HIP runtime built by SPACK is installed to
+- // <rocm_root>/hip-<rocm_release_string>-<hash> directory.
+- auto SPACKPath = findSPACKPackage(Candidate, "hip");
+- InstallPath = SPACKPath.empty() ? InstallPath : SPACKPath;
+-
+- BinPath = InstallPath;
+- llvm::sys::path::append(BinPath, "bin");
+- IncludePath = InstallPath;
+- llvm::sys::path::append(IncludePath, "include");
+- LibPath = InstallPath;
+- llvm::sys::path::append(LibPath, "lib");
+-
+- llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> VersionFile =
+- FS.getBufferForFile(BinPath + "/.hipVersion");
+- if (!VersionFile && Candidate.StrictChecking)
+- continue;
+-
+- if (HIPVersionArg.empty() && VersionFile)
+- if (parseHIPVersionFile((*VersionFile)->getBuffer()))
+- continue;
+-
+- HasHIPRuntime = true;
+- return;
+- }
+- HasHIPRuntime = false;
++ HasHIPRuntime = true;
+ }
+
+ void RocmInstallationDetector::print(raw_ostream &OS) const {
diff --git a/sys-devel/llvm-roc/llvm-roc-4.5.2.ebuild b/sys-devel/llvm-roc/llvm-roc-4.5.2.ebuild
new file mode 100644
index 000000000000..59ebbeed8b5b
--- /dev/null
+++ b/sys-devel/llvm-roc/llvm-roc-4.5.2.ebuild
@@ -0,0 +1,97 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit cmake
+
+DESCRIPTION="Radeon Open Compute llvm,lld,clang"
+HOMEPAGE="https://github.com/RadeonOpenCompute/ROCm/"
+SRC_URI="https://github.com/RadeonOpenCompute/llvm-project/archive/rocm-${PV}.tar.gz -> llvm-rocm-ocl-${PV}.tar.gz"
+
+LICENSE="UoI-NCSA rc BSD public-domain"
+SLOT="0"
+KEYWORDS="~amd64"
+IUSE="debug +runtime"
+
+RDEPEND="
+ dev-libs/libxml2
+ sys-libs/zlib
+ sys-libs/ncurses:="
+DEPEND="${RDEPEND}"
+
+S="${WORKDIR}/llvm-project-rocm-${PV}/llvm"
+
+PATCHES=(
+ "${FILESDIR}/${PN}-4.2.0-current_pos.patch"
+ "${FILESDIR}/${PN}-4.2.0-add_Object.patch"
+)
+
+CMAKE_BUILD_TYPE=Release
+
+src_prepare() {
+ cd "${WORKDIR}/llvm-project-rocm-${PV}" || die
+ eapply "${FILESDIR}/${PN}-4.5.2-add_libraries.patch"
+ eapply "${FILESDIR}/${PN}-4.0.0-remove-isystem-usr-include.patch"
+ eapply "${FILESDIR}/${PN}-4.5.2-hip-location.patch"
+ eapply "${FILESDIR}/${PN}-4.2.0-cyclades.patch"
+
+ if [[ -n ${EPREFIX} ]]; then
+ pushd "${S}"/../clang >/dev/null || die
+ sed -i -e "s@DEFAULT_SYSROOT \"\"@DEFAULT_SYSROOT \"${EPREFIX}\"@" CMakeLists.txt || die
+ eend $?
+ ebegin "Use "${EPREFIX}" as default sysroot"
+ cd lib/Driver/ToolChains >/dev/null || die
+ ebegin "Use dynamic linker from ${EPREFIX}"
+ sed -i -e "/LibDir.*Loader/s@return \"\/\"@return \"${EPREFIX}/\"@" Linux.cpp || die
+ eend $?
+
+ ebegin "Remove --sysroot call on ld for native toolchain"
+ sed -i -e "$(grep -n -B1 sysroot= Gnu.cpp | sed -ne '{1s/-.*//;1p}'),+1 d" Gnu.cpp || die
+ eend $?
+ popd >/dev/null || die
+ fi
+
+ # handled by sysroot, don't prefixify here.
+ sed -e 's:/opt/rocm:/usr/lib/hip:' \
+ -i "${S}"/../clang/lib/Driver/ToolChains/AMDGPU.cpp || die
+
+ eapply_user
+ cmake_src_prepare
+}
+
+src_configure() {
+ PROJECTS="clang;lld;llvm"
+
+ if usex runtime; then
+ PROJECTS+=";compiler-rt"
+ fi
+
+ local mycmakeargs=(
+ -Wno-dev
+ -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/roc"
+ -DCMAKE_DISABLE_FIND_PACKAGE_CUDA=ON
+ -DLLVM_ENABLE_PROJECTS="${PROJECTS}"
+ -DLLVM_TARGETS_TO_BUILD="AMDGPU;X86"
+ -DLLVM_BUILD_DOCS=NO
+ -DLLVM_ENABLE_BINDINGS=OFF
+ -DLLVM_ENABLE_OCAMLDOC=OFF
+ -DLLVM_ENABLE_SPHINX=NO
+ -DLLVM_ENABLE_DOXYGEN=OFF
+ -DLLVM_BUILD_UTILS=ON
+ -DLLVM_VERSION_SUFFIX=roc
+ -DOCAMLFIND=NO
+ )
+
+ use debug || local -x CPPFLAGS="${CPPFLAGS} -DNDEBUG"
+
+ cmake_src_configure
+}
+
+src_install() {
+ cmake_src_install
+ cat > "99${PN}" <<-EOF
+ LDPATH="${EROOT}/usr/lib/llvm/roc/lib"
+ EOF
+ doenvd "99${PN}"
+}