diff options
Diffstat (limited to 'sys-devel/llvm-roc')
-rw-r--r-- | sys-devel/llvm-roc/Manifest | 5 | ||||
-rw-r--r-- | sys-devel/llvm-roc/files/llvm-roc-5.0.0-add_GNU-stack.patch | 14 | ||||
-rw-r--r-- | sys-devel/llvm-roc/files/llvm-roc-5.0.0-hip-location.patch | 206 | ||||
-rw-r--r-- | sys-devel/llvm-roc/files/llvm-roc-5.0.0-linkdl.patch | 11 | ||||
-rw-r--r-- | sys-devel/llvm-roc/llvm-roc-5.0.2.ebuild | 97 |
5 files changed, 333 insertions, 0 deletions
diff --git a/sys-devel/llvm-roc/Manifest b/sys-devel/llvm-roc/Manifest index 6721cb6518e1..2dfe677e0e31 100644 --- a/sys-devel/llvm-roc/Manifest +++ b/sys-devel/llvm-roc/Manifest @@ -10,6 +10,9 @@ AUX llvm-roc-4.2.0-cyclades.patch 3703 BLAKE2B 3250b2da548ffe759155fb673f0f81cfb AUX llvm-roc-4.3.0-hip-location.patch 7128 BLAKE2B 6756bcad1c0bdef0729d3e7f2c6ea3468777623fb1493209956f436e9f234a1728e052c31ff064f8125c72d2a8cf68f425f76fb21cecf02680e999a6d5e7e41b SHA512 09f42ce7a37e072aa813036b78efd38cdaee54a1155fb347bf22f3f9f87441a6af83014fbc798f4d6d11966f40cf9c9fe6d3a8662b58be7859ab5b167eee37c2 AUX llvm-roc-4.5.2-add_libraries.patch 342 BLAKE2B 74e4bd50143d8e369cd3cc805f2d15fbad94667adcb8b001faaa7ae038bd69b8b2a2f4a02572a7711dbdbb356b45c653371e1e90a6a3abbaf3261952d87fc2cb SHA512 24d5a6a3e3b710138c0795af5b93b222bcfe1739d650a13c9564e4d7452d77e6392229e2a1cc27005cf5d3a572d6533e25bb608b52e4d113449525cf766f0e25 AUX llvm-roc-4.5.2-hip-location.patch 7108 BLAKE2B 1db4e922a3ec7ef3868c5adb7c811ddef2edf8e5b7bc02523a20fd41c9acd00ed904944c909fb8911b165c461832e38ec5eceeed0971680dfd3e4219f217c667 SHA512 a9fac99758a1ae98d3790e0b9f95056e852c62f2b53109a432514da60c1165f41533d6b94f9e9d88982bf22ef460d3813ca0532f5ffb801f184ec62778b6f856 +AUX llvm-roc-5.0.0-add_GNU-stack.patch 543 BLAKE2B 448b1c932ba9eb5c808277d4aa3caf835c44c5ef2564e0903ef4aa94c20c33dc1e0d4832d1338d0947079a3341eca59b919f1970e93dd878ef24da67fef90118 SHA512 961fd8a13bb9e9661b92ed994024eaff3629429499c40fe74649b0d8533c8e06bc5ae6f7eb5587d6361f253f8beb688e7150e11994244cd79680ad6863829096 +AUX llvm-roc-5.0.0-hip-location.patch 8082 BLAKE2B 3c468dfdf6eac3b85fcaa97bc33091042614f83be926c62b1750026fc131a425ee2b30a4ac285752b74b7120897327120b8825fa16577ab49e4e6fced76272fb SHA512 f0f86a18a5b60b10dee9214ae7504c5cdc1e38e4fd53c7fd8cae68f9181a8622b28a5796203f785199a8fdfc013567df4c8e4d6db767c6f62cc9f444d42a1880 +AUX llvm-roc-5.0.0-linkdl.patch 476 BLAKE2B 4854e08cbd4109eed02fb1154ff9dcf47d78b4a6670fbf65b5ce2dbfa0161a0e7a638299735c4edef4cac5799f1f88d3b781edb9738905ed118fc90f071fe47e SHA512 89097d32d2b5b7ff23192b5750771d2272b8ab34f248aa48f9570e778f94db61baffb6e8d2c3ddf017b745ee31edb03cc2d62439ddba8249d35692f32a4170cb DIST llvm-rocm-ocl-3.10.0.tar.gz 123600166 BLAKE2B 9b69dab6c7d1a8dfe0d90c76b54446ec7f8ef6e59c74ad328208ac07dbf8836ae412dc5c32fdcbfc926a2488e81cd8afef71c3ebca6cd8ff745205028ab380d8 SHA512 3bb7dac13d89cadfb61a231564155f49021437b7c35eae8735b88ceae4a23b7950643f17e3bfebb0868621297202a04d41120d50ea52b6ad8980dabe9bc75509 DIST llvm-rocm-ocl-3.7.0.tar.gz 116973132 BLAKE2B c1cc8a3b95292d726626d3cb59ec1b96549682bfcbec16030e47cf1318c6ea01bc76f3349f012ce4f1e4d8b9fe192c51a025c2d08cf593622c61fe7c61969ba6 SHA512 0626075bedb3898c96c0bb0be7a2aba4662050a1c738115f661bedc03d744ace7a4581b55c6325060740c13a0e50e72e09272bb02c1186c2c4a40fc9b961dcbe DIST llvm-rocm-ocl-3.8.0.tar.gz 117004300 BLAKE2B 13c3213f0fb951fb9d574e8f6d76bb6c632fecadfe93dbe68a9720baa22e35aa3269deef8b533c5a5ff50a2c1ee3dd7a1ea0fae4b8ab8573ec5bfc5ca5d04f4f SHA512 4eca387a132c9d1237ebec7c80319e99c80088766209d05a697d09890f4a82c56ba5f48a5c8c8749bb051c177bb5eab67e00405b04d3191681d0ac7cf1ae868c @@ -21,6 +24,7 @@ DIST llvm-rocm-ocl-4.1.1.tar.gz 128914019 BLAKE2B 9806d1da497e9d9864fd015fc92f5e 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 +DIST llvm-rocm-ocl-5.0.2.tar.gz 150281451 BLAKE2B e4363266e05e13af761dd6f440dbfc30905f219e428fa3b2595800ba0c80c97cd7e2615d68acd9aea4fc66454ee8a3ff7a52a60d3aed4e93af5007050277e5fe SHA512 9be9f1a0ad1a0089aa27858174ce37c7a02902b6dedc338382f42ed0567823cc4bb11b68c130470590c16d4d92ab2735a06c27d248237ffa2d394253328f6705 EBUILD llvm-roc-3.10.0.ebuild 1504 BLAKE2B 45a36c92ddd29b3e8c811db5476172a25847dab08436d03e3680c770494462257f31f30147744dcf18ca6364c24378b8f7723af20ee7675fe16511029a0cb869 SHA512 629d3193ece5023b0eaa12a70da8f003900d90bcccea1b8363f7dace8b559f16680e618a6e90932e60013a620ce2e2b2a6b4419494d411260a21eb15845fd4e1 EBUILD llvm-roc-3.7.0-r1.ebuild 1365 BLAKE2B a958e69206d2a91c93668c236bcd3fea12a80fc1860a58b92268a2deb546a4602a1863cbbfa1187afd0158303898def84cba1561a5b3e6c9af0e74e49c15e686 SHA512 a584e3f0816108d378115685329aec5eda07d8c944d532ba48499225d9ceaf043e1c341ea7762f26d35e241143671dafc7b13f48127f9f5236a5e5c5f38793d0 EBUILD llvm-roc-3.8.0.ebuild 1460 BLAKE2B 6582c682c3e0d648bc948aeb6214ae0cc578e9a7ff78c393186a22ca2535288924770a2590fe4d32787f25489ab5c537548a2b39fc5235e8d8b61f5833f4c1d3 SHA512 81a7adc423792f0eb23195eab9747ae04426f73238d82e19d2d03d7fbbbf81df946478cf12e9a75019edd6871b441cae1aebfb085ced8624e64921fa5e760bdb @@ -33,4 +37,5 @@ EBUILD llvm-roc-4.1.1.ebuild 2392 BLAKE2B 6991a50a82746c051c1084f0e4794c31347fc7 EBUILD llvm-roc-4.2.0.ebuild 2366 BLAKE2B 91003a3a21fc407c8546b4984daf617414877b61b83bfa20ddad15f64582b3076e744d42040d896c3afec6ca9e9a06433035883775d72841914c48b6a60546b8 SHA512 c149083879e100e8db6125c9d5ce839e3cf15e932b49378be4351da1e5213369b18a428b681d7dd1fd53aa1e0c9ec24e6d8cc2c59a8fd748395764473b5bedd4 EBUILD llvm-roc-4.3.0-r1.ebuild 2447 BLAKE2B f8c8605942225d53517c373cc42e6f6ca73000a47415ad89fdf8a6095a05637715be1d7636b388a82f7040db5e256d9a2a0a206a6956de6ca4fa7b8884e9b637 SHA512 fe11f3b4a2ba24cdb068fc4ba8a0a0f0b8bb72a3d42fc0701d3d6fdf1cad9fb9f0d8f458da987a14601102a095eccb1ec7dac36a1863e19d58cdc2722325cc86 EBUILD llvm-roc-4.5.2.ebuild 2483 BLAKE2B 214d3e1ecd20566d458232f5af38de0f97b0afcbd0aa7c22a9ee3d2f283003f8bf661bbd8db372fc568f37b16bc936721a3f828eabd088efa74c79ad7a31d733 SHA512 51ed907721b60aeb61d5b8c407246d4f78d1b363ee55b55109c08a72085499dcfb2b29319cfc4d550465de064258385fe35d5257752c12eab0c43a1bb6f6d917 +EBUILD llvm-roc-5.0.2.ebuild 2455 BLAKE2B c2caa36ec4031e5dea3863838b4b16717c4a396561293aec6730ad688fb4496a33a968ccd853cd971e65550cc923c623ffed454b81fd7b3ed0d36ac70f853f2d SHA512 516a60a237019b48eb261279d7a18b4d66f7a5c11da659e5c139795f298073976796b1333ed0c6490d0c7c33c52e9bab386df55a70cbae4dd92e8052edea2017 MISC metadata.xml 470 BLAKE2B e3e508a8f3178c63fb93afc93d42ff41f8f6290d763762c1200ecdccef16ce2b2dcb3e810e950ba9c8db2ec37639ffafb47b38bb7e03f6dbbb0496ae96c16d3b SHA512 3764f794532fb58cb944d718e1e59f4abc42270f3fd80c2f8b8537dfefc46f6a495bc126e842a9b4e560cc207902548aef9e2f2641b1a11954db3c2f98246133 diff --git a/sys-devel/llvm-roc/files/llvm-roc-5.0.0-add_GNU-stack.patch b/sys-devel/llvm-roc/files/llvm-roc-5.0.0-add_GNU-stack.patch new file mode 100644 index 000000000000..f57989c8c8a3 --- /dev/null +++ b/sys-devel/llvm-roc/files/llvm-roc-5.0.0-add_GNU-stack.patch @@ -0,0 +1,14 @@ +Add .note.GNU-stack to mitigate QA notice according to +https://wiki.gentoo.org/wiki/Hardened/GNU_stack_quickstart +=================================================================== +--- llvm-project-rocm-5.0.0.orig/compiler-rt/lib/orc/elfnix_tls.x86-64.S ++++ llvm-project-rocm-5.0.0/compiler-rt/lib/orc/elfnix_tls.x86-64.S +@@ -61,4 +61,8 @@ ___orc_rt_elfnix_tls_get_addr: + popq %rbp + ret + ++#if defined(__linux__) && defined(__ELF__) ++ .section .note.GNU-stack,"",%progbits ++#endif ++ + #endif // defined(__x86_64__) diff --git a/sys-devel/llvm-roc/files/llvm-roc-5.0.0-hip-location.patch b/sys-devel/llvm-roc/files/llvm-roc-5.0.0-hip-location.patch new file mode 100644 index 000000000000..614a16d1e810 --- /dev/null +++ b/sys-devel/llvm-roc/files/llvm-roc-5.0.0-hip-location.patch @@ -0,0 +1,206 @@ +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> + +Index: llvm-project-rocm-5.0.1/clang/lib/Driver/ToolChains/AMDGPU.cpp +=================================================================== +--- llvm-project-rocm-5.0.1.orig/clang/lib/Driver/ToolChains/AMDGPU.cpp ++++ llvm-project-rocm-5.0.1/clang/lib/Driver/ToolChains/AMDGPU.cpp +@@ -169,139 +169,8 @@ bool RocmInstallationDetector::parseHIPV + /// 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 or resource directory. +- auto ClangRoot = llvm::sys::path::parent_path(InstallDir); +- auto RealClangRoot = llvm::sys::path::parent_path(ParentPath); +- ROCmSearchDirs.emplace_back(ClangRoot.str(), /*StrictChecking=*/true); +- if (RealClangRoot != ClangRoot) +- ROCmSearchDirs.emplace_back(RealClangRoot.str(), /*StrictChecking=*/true); +- 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( +@@ -410,7 +279,7 @@ void RocmInstallationDetector::detectDev + // - ${ROCM_ROOT}/lib/bitcode/* + // so try to detect these layouts. + static constexpr std::array<const char *, 2> SubDirsList[] = { +- {"amdgcn", "bitcode"}, ++ {"lib/amdgcn", "bitcode"}, + {"lib", ""}, + {"lib", "bitcode"}, + }; +@@ -433,42 +302,7 @@ void RocmInstallationDetector::detectDev + } + + 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/files/llvm-roc-5.0.0-linkdl.patch b/sys-devel/llvm-roc/files/llvm-roc-5.0.0-linkdl.patch new file mode 100644 index 000000000000..80598c6f990d --- /dev/null +++ b/sys-devel/llvm-roc/files/llvm-roc-5.0.0-linkdl.patch @@ -0,0 +1,11 @@ +LLVMOffloadArch should link libdl to fix undefined symbol 'dlsym' when linking +--- llvm.orig/lib/OffloadArch/offload-arch/CMakeLists.txt ++++ llvm/lib/OffloadArch/offload-arch/CMakeLists.txt +@@ -3,6 +3,7 @@ add_llvm_tool(offload-arch + ${CMAKE_CURRENT_SOURCE_DIR}/offload-arch.cpp + DEPENDS generated-table LLVMOffloadArch + ) ++target_link_libraries(LLVMOffloadArch PRIVATE ${CMAKE_DL_LIBS}) + target_link_libraries(offload-arch PRIVATE LLVMOffloadArch) + + if(CMAKE_HOST_UNIX) diff --git a/sys-devel/llvm-roc/llvm-roc-5.0.2.ebuild b/sys-devel/llvm-roc/llvm-roc-5.0.2.ebuild new file mode 100644 index 000000000000..6dc4f6a23e2c --- /dev/null +++ b/sys-devel/llvm-roc/llvm-roc-5.0.2.ebuild @@ -0,0 +1,97 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +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}-5.0.0-linkdl.patch" +) + +CMAKE_BUILD_TYPE=RelWithDebInfo + +src_prepare() { + pushd "${WORKDIR}/llvm-project-rocm-${PV}" || die + eapply "${FILESDIR}/${PN}-4.0.0-remove-isystem-usr-include.patch" + eapply "${FILESDIR}/${PN}-5.0.0-hip-location.patch" + eapply "${FILESDIR}/${PN}-5.0.0-add_GNU-stack.patch" + popd || die + + 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="${EPREFIX}/usr/lib/llvm/roc/lib" + EOF + doenvd "99${PN}" +} |