From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 000071580B9 for ; Thu, 26 Aug 2021 12:39:35 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4032DE08CD; Thu, 26 Aug 2021 12:39:35 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 1C45AE08CD for ; Thu, 26 Aug 2021 12:39:35 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 63AEC342BB4 for ; Thu, 26 Aug 2021 12:39:33 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 7B08A7B4 for ; Thu, 26 Aug 2021 12:39:31 +0000 (UTC) From: "Benda XU" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Benda XU" Message-ID: <1629981538.e78aa10a00b855cc9ab96fb36d1cebec991530ac.heroxbd@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: sys-devel/llvm-roc/files/, sys-devel/llvm-roc/ X-VCS-Repository: repo/gentoo X-VCS-Files: sys-devel/llvm-roc/files/llvm-roc-4.3.0-hip-location.patch sys-devel/llvm-roc/llvm-roc-4.3.0-r1.ebuild sys-devel/llvm-roc/llvm-roc-4.3.0.ebuild X-VCS-Directories: sys-devel/llvm-roc/files/ sys-devel/llvm-roc/ X-VCS-Committer: heroxbd X-VCS-Committer-Name: Benda XU X-VCS-Revision: e78aa10a00b855cc9ab96fb36d1cebec991530ac X-VCS-Branch: master Date: Thu, 26 Aug 2021 12:39:31 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 005c6f4e-800e-4d8d-8fd4-a92255748e55 X-Archives-Hash: d4ec6996b1627cf52e69094a4df5422d commit: e78aa10a00b855cc9ab96fb36d1cebec991530ac Author: YiyangWu gmail com> AuthorDate: Sat Aug 21 11:00:55 2021 +0000 Commit: Benda XU gentoo org> CommitDate: Thu Aug 26 12:38:58 2021 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e78aa10a sys-devel/llvm-roc: add hip-location.patch back Clang from llvm-roc-4.3.0 throws error during compilation of rocm packages for GPU devices (e.g. rocBLAS). The missing of $ROCM_PATH and deprecation of hip-location.patch together causes in this situation. This commit update the hip-location.patch so it can be used again. Closes: https://bugs.gentoo.org/809392 Closes: https://github.com/gentoo/gentoo/pull/22060 Package-Manager: Portage-3.0.20, Repoman-3.0.3 Signed-off-by: Yiyang Wu gmail.com> Signed-off-by: Benda Xu gentoo.org> .../files/llvm-roc-4.3.0-hip-location.patch | 189 +++++++++++++++++++++ ...m-roc-4.3.0.ebuild => llvm-roc-4.3.0-r1.ebuild} | 1 + 2 files changed, 190 insertions(+) diff --git a/sys-devel/llvm-roc/files/llvm-roc-4.3.0-hip-location.patch b/sys-devel/llvm-roc/files/llvm-roc-4.3.0-hip-location.patch new file mode 100644 index 00000000000..1fe93a33db3 --- /dev/null +++ b/sys-devel/llvm-roc/files/llvm-roc-4.3.0-hip-location.patch @@ -0,0 +1,189 @@ +replace hardcoded hip finder with Gentoo paths. + +It is not necessary to check HIP runtime each time. + +Author: Benda Xu +Author: Yiyang Wu + +--- orig/clang/lib/Driver/ToolChains/AMDGPU.cpp ++++ llvm-project-rocm-4.3.0/clang/lib/Driver/ToolChains/AMDGPU.cpp +@@ -165,133 +165,8 @@ bool RocmInstallationDetector::parseHIPV + /// cached and populated only once. + const SmallVectorImpl & + 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 +- // /llvm-amdgpu--/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); +- +- 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(); +- return ROCmSearchDirs; ++ ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", /*StrictChecking=*/true); ++ return ROCmSearchDirs; + } + + RocmInstallationDetector::RocmInstallationDetector( +@@ -423,42 +298,7 @@ void RocmInstallationDetector::detectDev + } + + void RocmInstallationDetector::detectHIPRuntime() { +- SmallVector 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 +- // /hip-- 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> 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.3.0.ebuild b/sys-devel/llvm-roc/llvm-roc-4.3.0-r1.ebuild similarity index 97% rename from sys-devel/llvm-roc/llvm-roc-4.3.0.ebuild rename to sys-devel/llvm-roc/llvm-roc-4.3.0-r1.ebuild index f055da5b939..34567ada192 100644 --- a/sys-devel/llvm-roc/llvm-roc-4.3.0.ebuild +++ b/sys-devel/llvm-roc/llvm-roc-4.3.0-r1.ebuild @@ -33,6 +33,7 @@ src_prepare() { cd "${WORKDIR}/llvm-project-rocm-${PV}" || die eapply "${FILESDIR}/${PN}-3.0.0-add_libraries.patch" eapply "${FILESDIR}/${PN}-4.0.0-remove-isystem-usr-include.patch" + eapply "${FILESDIR}/${PN}-4.3.0-hip-location.patch" eapply "${FILESDIR}/${PN}-4.2.0-cyclades.patch" if [[ -n ${EPREFIX} ]]; then