diff options
author | V3n3RiX <venerix@koprulu.sector> | 2025-02-24 19:24:56 +0000 |
---|---|---|
committer | V3n3RiX <venerix@koprulu.sector> | 2025-02-24 19:24:56 +0000 |
commit | d4653056cc74d97f24bef0d56b4ebe11c53c8b76 (patch) | |
tree | 5d4be0715302fad2089468027fadaa0372afd1d1 /dev-util/nvidia-cuda-toolkit | |
parent | 575bcb9220287a6f0d2577db1fd9fe55d9d8b745 (diff) |
gentoo auto-resync : 24:02:2025 - 19:24:56
Diffstat (limited to 'dev-util/nvidia-cuda-toolkit')
-rw-r--r-- | dev-util/nvidia-cuda-toolkit/Manifest | 4 | ||||
-rw-r--r-- | dev-util/nvidia-cuda-toolkit/files/parse_manifest.py | 223 | ||||
-rw-r--r-- | dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-12.8.0-r1.ebuild | 372 |
3 files changed, 599 insertions, 0 deletions
diff --git a/dev-util/nvidia-cuda-toolkit/Manifest b/dev-util/nvidia-cuda-toolkit/Manifest index b23df22c4f69..2f16874475f2 100644 --- a/dev-util/nvidia-cuda-toolkit/Manifest +++ b/dev-util/nvidia-cuda-toolkit/Manifest @@ -1,5 +1,6 @@ AUX cuda-config.in 407 BLAKE2B 5f7a0d50d774db58c180b767f00bead7c7dbf5f6b3b4a2f960dfc3b8450f7abf5c2b67c6620c5318f1331646dd2003d61c70a4c31359efd16ff418ecc9d0b446 SHA512 363903b999c43a47a48c52e8898c6044fadcc66d259338ee22863e859c2bc9873a2f1392aa83c9182486d3aa4eaeb5f164cf8ccf29cc74fd8ad56245f76a039a AUX nvidia-cuda-toolkit-glibc-2.41.patch 3067 BLAKE2B 66482f56a1797116f9c8cb6014265c9dbc1fd4032ca2b68e59eca1a4ba45b3b86bc3aca8869752ee0d52392305196efa679258399a252b145ce5c53c9e35804b SHA512 58acf6c195fe85e4e25bb17af3b03acfe6c5dfe1111f5705f39a6a3ef3ff4621f59bece49d1dbbdd4f81948c1c2d707d2948ae9148e328c09e517f809fd503cb +AUX parse_manifest.py 8488 BLAKE2B fe4748e41727e717d99b3b7f294d7c8e67b44e3f352f27a76c386502870e6134217ead3d93714755f50b0393d514b9e317748aed89637c660e354d53354d1485 SHA512 ab90e614bfd729a0a90a7373d58fcf2f6e7ba3beb8a00841b87e8240c9386a678daf551f4fcc89040f10d46d159e316442978c60b1a8960070576cfb7a11d52c DIST cuda_11.8.0_520.61.05_linux.run 4336730777 BLAKE2B cfdb4a51c49ee504e56a4a95de4e477ef207b678527cbb633c1e83e667f1a62c0f67038befd0b10f7ae24cda9c8bc5c54293d06a05b2e45be6cf677e40f71f17 SHA512 e96e1389abed34b5093b3a1d4e6ae9f3d4f8406621b1475f378efae65868657efce22da03b5b4e0a548d9635e406b8690b18b17b186d03ecb3ca0703c5d5787a DIST cuda_12.3.2_545.23.08_linux.run 4368514070 BLAKE2B bfb6239b7669636e2ef424921f5a1dd99409a0351ea7d3453fcec3d484e714d87639e733cfae913b0f222d7af8acb7bebae340ea8af53fb7ab320805abb7b230 SHA512 dce569e42955fc351a6b52b2876948029d5183bb000754f0cdcba754673a280acfd4c9e4d8cf61d572ed045de006e0bbb0e8ff32012e6cc336be9c05fd529340 DIST cuda_12.4.0_550.54.14_linux.run 4454353277 BLAKE2B da339a44ac21799a88b4573e9afc0866f11649707594383414cb0c729b36dc63d55032e5ccbbbe46e84c1dc88fc76e466067be7ef2ae3d131a74190c548d76ba SHA512 329b81c63dcefa5c6713eeb2dc5ccc223f5b456f4b7558bd3723d166357d8bb4c79d12082ea396aaadae8b5593b20584f7bd0cf617bb3494e4423b58726255a1 @@ -8,6 +9,8 @@ DIST cuda_12.5.0_555.42.02_linux.run 4294677299 BLAKE2B ffefb576feb9f8e6ea8975bf DIST cuda_12.5.1_555.42.06_linux.run 4311634770 BLAKE2B 3546faeb24687dd11ad0a61a4f02cfbd97119d9e3cd3e24ea294b81ed488de7dfef03607c69d7b5a8087db10cf794205936add7cfa8ccda207e3aca315be48df SHA512 604843e09717c2af0873b2d5a2e242ff1b99122d515b6a7a29e70c55ab605524744359781f5b642059550b4def57877597111914965efe7d3a1a1387c9dbb1a0 DIST cuda_12.6.0_560.28.03_linux.run 4333105923 BLAKE2B 533e9080dbf087a661ab6e59548e48ca0d2b514f47c3e97ac89b628f79197875a7425ad69c4d271b5fa8243561c1ccba698e3bf322b194b29a5f7fa031ea8f06 SHA512 fe5710c168298d2283a3f636ad5e1e212970fe8d9554ab450aa61d786536f50efb9d9e9396b6ac59638bd4204faadb5a99ec8a8c02e2c57a18f479123aaff3c9 DIST cuda_12.6.1_560.35.03_linux.run 4345714567 BLAKE2B 147c7f03e0d9ade4c603d93920d0cd6bb1706efc268797ae870b5244feaa8159393015f96e920c6255e93d8040dd5b046075804cfa7c5da18a645800d65b8c3d SHA512 514ec89f847457c3ba78cd0dc22c25aebf2a19a6bbd5a8d071f31519d1007889cde6ba888a01596434216a8a88bfba21059cdc8e3fa9397133c93d2a9f0c015e +DIST cuda_12.8.0_570.86.10_linux.run 5412604598 BLAKE2B 21ea184fd428ea638934788847e023213c38c1079d489d04bbd1ca277d1c285d57a7ac9c02020cbd73970e703daeec9e806831cf54a427cff90fc036c4da7705 SHA512 7939552d38c39b184946df455233eb9ffe91051656b3091b0414b2acc2939bc35dd92724b584e507976c3b4cd51f489abee2e2d0da27bfebaf8999c3f2c2bb2e +DIST cuda_12.8.0_570.86.10_linux_sbsa.run 4636253689 BLAKE2B 53df0ee05a9563bf9db1b813a75d4a81c391cf67c24bc0b9fadf74809ebf1534cbf5762317e2f04e4e7482adf97612d8d3f16d78146abe715a9dc4b8654a1bbf SHA512 bcd91a914d09e72a2f2320d9912a3928a491c8d7062f65d027bc172630944bc0fc319ef2ded10e3c4ade564cf2a4f9a166698dca1d493632ee7ef7ff5d7f1ad5 EBUILD nvidia-cuda-toolkit-11.8.0-r4.ebuild 8044 BLAKE2B 54995f4f2a8a1998539a6798ff2a68bbfed1943c3e6da27eff58458853db006e105bb39e5bb1935b11971539dcc63fb552ce0b280860ba46ce04f04e98890568 SHA512 df7eb92e74e80302e0fd966ba1c2a97a38f97e3e6bba4bb0a1a389e1336c13d3c9a3603f7079a597d2ae723f7088e83ff708e8ef5d2ba503de0469bf25e1c1c8 EBUILD nvidia-cuda-toolkit-12.3.2.ebuild 9504 BLAKE2B 6abf260006cfd3471665526df049d3f80d956f6a849e8e73c0914aa32faf86ff68d659aa8fcc5a4e95eb6890bf271a2d40edec67aeadd5154444d66e8d337c5e SHA512 3660334d48205d952fd73e688742d700db4b9594920d42d289c581d10af34af516fd8920993650dafacb983492ae72d6b4f3b0ce51d3301d66d6450b34c0c7a9 EBUILD nvidia-cuda-toolkit-12.4.0.ebuild 9515 BLAKE2B 270c9952890a529d17355d5456d6d2422740f69eb9af1b88121e0c8b7a0a9632a39647fc69da4e3653cba4e4cd60f3afc20fce2095743ba128aae8a15f0676ab SHA512 949e4ad4b2d1758279bb620c5a2ba0ea90c93e852f862c448490c689d8d4f522891cb6a772a65894a4f9867be1c8dea1facf87616370bdd0f45987f9d437a3ab @@ -16,4 +19,5 @@ EBUILD nvidia-cuda-toolkit-12.5.0-r1.ebuild 9535 BLAKE2B b8b50bede8a66a8bce76f66 EBUILD nvidia-cuda-toolkit-12.5.1.ebuild 9535 BLAKE2B ea6b46070159a18d8f541af47d648a79b75f7f964d689418220e4eaf87c56fc000eb39fed84637c161aa5f18e5f7e03f0615cbec6670517fd2efefd83139a0a4 SHA512 47bca7b76aad3842f37d8da4fbbdf646a1ca2cc93bc7ae870d8e164a05f735974ca28d69a99a6d0ffcd331e5134025b3819360f27c65dc6c27338756bfc74ba8 EBUILD nvidia-cuda-toolkit-12.6.0.ebuild 9535 BLAKE2B 984ec77cc39675ba22703339ecbd5596452a5631c7303e4db492bad0b80496ea13151cb25f87a7c0e39d9d2a173be7ad9469a91acfd785abb83632caae230297 SHA512 efbf2fcc39f60ca1f35f15202e924146618b4441c090d26e07048e10dee6ddd79f10640b1c6d8d2e84a218edb6a1382f2398eaf182a503d5dd6dbce250844af3 EBUILD nvidia-cuda-toolkit-12.6.1-r1.ebuild 9685 BLAKE2B dbbfe46f57fc1a42a91d8a5b1e72651adb9d204abb05512945dd9af691872f4285c69918918a131adcfb749e7832c31bf8738321f8909a4656824c2727e899d2 SHA512 519dcf9c06f7a11a6405dac69b003e6b37d1d32007f3231038d3254c9901815a25cbdceb3401adfb783be77c683ce53acd76ea3722bb4b2c66d5e9265399967c +EBUILD nvidia-cuda-toolkit-12.8.0-r1.ebuild 10528 BLAKE2B b754068e51f8a7044ede690f57c347b8190869875356d3e3dcf3872e201b111a205337a472a703a37a947733cb00a44ab82757fe973d1a303eb9ab781ad4b8ae SHA512 25b93fc768aee3e56594bcb157f7f4390b21cac759cb31ed41fff60d824d188819b01e5b384cd54b5101afdbd96f68feebf5baec57b947dee4b1d256ce09987f MISC metadata.xml 761 BLAKE2B a6ae653c6206cbc05349297499b6dde91bce6d543e10bd5ea915cfe9729dfa6f1eb954ae09c2e4d3997f51315ae090b38606c21b5099e750596ea66fdd93e817 SHA512 9133517d805201d25b651e48abed90394c88ef33a2571ab20b3b19d365f85a90478486c7c087c9150d7d9f6e4026873c5236c64ed649fd3bfc8f9b81479dcc59 diff --git a/dev-util/nvidia-cuda-toolkit/files/parse_manifest.py b/dev-util/nvidia-cuda-toolkit/files/parse_manifest.py new file mode 100644 index 000000000000..57adad1ca975 --- /dev/null +++ b/dev-util/nvidia-cuda-toolkit/files/parse_manifest.py @@ -0,0 +1,223 @@ +#!/usr/bin/env python +# Copyright 2024-2025 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 +# +# +# Takes the manifests/*.xml file from the NVIDIA CUDA Toolkit as input. +# Those files contain a nested tree of package items. +# +# For each package node a if block is output that checks the package's +# name attribute against the environment provided array SKIP_COMPONENTS +# and skips that whole package if it's listed in it. +# +# Each item contains four nodes that reference things to install, +# `dir`, `file`, `desktopFile`, & `pcfile`, and metadata that further +# detail these. This script will output calls to do* calls that +# use the metadata. +# - dodir would create an empty file - we handle this in dofile +# - dofile copies a regex file glob +# - dodesktopFile creates a .desktop file +# - dopcfile creates a pkgconfig file +# +# The resulting bash code can be run inside src_install(). +# +# Usage: python parse_manifest.py <cuda_aarch64.xml|cuda_x86_64.xml> + + +import argparse +import xml.etree.ElementTree + +import defusedxml.ElementTree +from pathlib import Path + +ind = "\t" +indent = 1 + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('filename') # positional argument + + args = parser.parse_args() + + basedir = Path(args.filename).parents[1] + + et = defusedxml.ElementTree.parse(args.filename) + + # Find all packages under the package with the id main (i.e. under "CUDA Installer") + for e in et.findall("[@id='main']/package"): + def p_package(el: xml.etree.ElementTree.Element, level: int = 0): + + skip = { + "Documentation", # obsolete + "Driver", # unused + # "Kernel Objects", # split + # "Demo Suite", + # "Visual Tools", + # old eclipse + # "nsight", + # old java + # "nvvp", + # "cuda-gdb-src" + } + + name = el.get("name") + + # trim leading CUDA and trailing version + if name.startswith("CUDA"): + name2 = ' '.join(name.split(" ")[1:-1]) + else: + name2 = name + + if name2 in skip: + return + + # avoid having to deal with whitespaces in bash + name2 = name2.replace(" ", "_") + + path = "" + + print(f"{ind * (level + 0) * indent}if ! has {name2} \"${{SKIP_COMPONENTS[@]}}\"; then # \"{name}\"") + + # output attributes from unhandled tags + for child in el: + if child.tag == "package": + continue + if child.tag == "file": + continue + if child.tag == "desktopFile": + continue + if child.tag == "pcfile": + continue + for attrib in child.attrib: + print(f"{child.tag} {attrib}={child.attrib[attrib]}") + + # <name>CUDA Installer</name> + # only for CUDA Installer + # unused + for node in el.findall("./name"): + print(f"{ind * (level + 1) * indent}# {node.tag}: \"{node.text}\"") + + # <type>compiler</type> + # category. We use the package name instead. + # unused + # for node in el.findall("./type"): + # print(f"{ind * (level + 1) * indent}# {node.tag}: \"{node.text}\"") + + # <priority>1</priority> + # probably sorting for the tui installer + # unused + # for node in el.findall("./priority"): + # print(f"{ind * (level + 1) * indent}# {node.tag}: \"{node.text}\"") + + # <single-selection/> + # proably for tui installer + # unused + # for node in el.findall("./single-selection"): + # print(f"{ind * (level + 1) * indent}# {node.tag}: \"{node.text}\"") + + # <koversion>2.24.2</koversion> + # version of the installed kernel object (Kernel Objects only) + # unused + for node in el.findall("./koversion"): + print(f"{ind * (level + 1) * indent}# {node.tag}: \"{node.text}\"") + + # <installPath>/usr/local/cuda-12.8</installPath> + # overrides the install location + # unused + # for node in el.findall("./installPath"): + # print(f"{ind * (level + 1) * indent}# {node.tag}: \"{node.text}\"") + + # <buildPath>./builds/cuda_cccl/</buildPath> + # path where the package files are found + # we cd into it + for node in el.findall("./buildPath"): + path = node.text.removeprefix('./') + print(f"{ind * (level + 1) * indent}cd \"${{S}}/{path}\" || die \"cd ${{S}}/{path} failed\"") + print() + + # <dir>bin</dir> + # would install empty dirs + # unused + # for node in el.findall("./dir"): + # pass + + # <file dir="bin/">.*</file> + # <file>targets/x86_64-linux/lib/.*\.so</file> + # regex glob of files to install. + for node in el.findall("./file"): + # unescape '.*' -> '*' & '\.' -> '.' + file = (node.text + .replace(".*", "*") + .replace(r"\.", ".") + .replace("x86_64", "${narch}") + .replace("sbsa", "${narch}") + ) + + # optional dir offset, we merge it into path + dir = "" + if "dir" in node.attrib: + dir = f" \"{Path(node.attrib["dir"])}\"" + + filepath = basedir / path / file + + # ignore existing symlinks ( include, lib* ) and the uninstallers + if not filepath.is_symlink() and not file.endswith("-uninstaller"): + print(f"{ind * (level + 1) * indent}dofile \"{file}\"{dir}") + + # <pcfile description="CUDA Runtime Library">opencl-12.8.pc</pcfile> + # create a pkgconfig file for the given description and lib name/version + for node in el.findall("./pcfile"): + offset = node.text.rfind('-') + if offset == -1: + raise RuntimeError(f"failed to split pcfile {node.text}") + + lib_name = node.text[:offset] + + if not node.text.endswith('.pc'): + raise RuntimeError(f"pcfile does not end in '.pc' {node.text}") + lib_version = node.text[offset+1:-3] + + if "description" not in node.attrib: + raise RuntimeError(f"no description for {node.text}") + + subdir = "" + if "subdir" in node.attrib: + subdir = f" \"{node.attrib["subdir"]}\"" + + print(f"{ind * (level + 1) * indent}dopcfile " + f"\"{lib_name}\" " + f"\"{lib_version}\" " + f"\"{node.attrib["description"]}\"{subdir}") + + # <desktopFile + # filename="nsight" + # name="Nsight Eclipse Edition" + # categories="Development;IDE;Debugger;ParallelComputing" + # keywords="cuda;gpu;nvidia;debugger;" + # iconPath="libnsight/icon.xpm" + # execPath="bin/nsight" + # tryExecPath="bin/nsight" + # /> + # create a .desktop file + for node in el.findall("./desktopFile"): + print(f"{ind * (level + 1) * indent}dodesktopFile \\") + print(f"{ind * (level + 2) * indent}\"{node.attrib["filename"]}\" \\") + print(f"{ind * (level + 2) * indent}\"{node.attrib["name"]}\" \\") + print(f"{ind * (level + 2) * indent}\"{node.attrib["categories"]}\" \\") + print(f"{ind * (level + 2) * indent}\"{node.attrib["keywords"]}\" \\") + print(f"{ind * (level + 2) * indent}\"{node.attrib["iconPath"]}\" \\") + print(f"{ind * (level + 2) * indent}\"{node.attrib["execPath"]}\" \\") + print(f"{ind * (level + 2) * indent}\"{node.attrib["tryExecPath"]}\"") + + # iterator over all nested packages + for node in el.findall("./package"): + p_package(node, level + 1) + + print(f"{ind * (level + 0) * indent}fi") + + p_package(e) + + +if __name__ == "__main__": + main() diff --git a/dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-12.8.0-r1.ebuild b/dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-12.8.0-r1.ebuild new file mode 100644 index 000000000000..f4e593b9052d --- /dev/null +++ b/dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-12.8.0-r1.ebuild @@ -0,0 +1,372 @@ +# Copyright 1999-2025 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# shellcheck disable=SC2317 + +EAPI=8 + +PYTHON_COMPAT=( python3_{10..13} ) +inherit check-reqs toolchain-funcs +inherit python-r1 + +DRIVER_PV="570.86.10" +GCC_MAX_VER="14" +CLANG_MAX_VER="19" + +DESCRIPTION="NVIDIA CUDA Toolkit (compiler and friends)" +HOMEPAGE="https://developer.nvidia.com/cuda-zone" +SRC_URI=" + amd64? ( + https://developer.download.nvidia.com/compute/cuda/${PV}/local_installers/cuda_${PV}_${DRIVER_PV}_linux.run + ) + arm64? ( + https://developer.download.nvidia.com/compute/cuda/${PV}/local_installers/cuda_${PV}_${DRIVER_PV}_linux_sbsa.run + ) +" +S="${WORKDIR}" + +LICENSE="NVIDIA-CUDA" + +SLOT="0/${PV}" # UNSLOTTED +# SLOT="${PV}" # SLOTTED + +KEYWORDS="-* ~amd64 ~arm64 ~amd64-linux ~arm64-linux" +IUSE="debugger examples profiler rdma sanitizer" +RESTRICT="bindist mirror strip test" + +REQUIRED_USE="${PYTHON_REQUIRED_USE}" + +# since CUDA 11, the bundled toolkit driver (== ${DRIVER_PV}) and the +# actual required minimum driver version are different. +RDEPEND=" + || ( + <sys-devel/gcc-$(( GCC_MAX_VER + 1 ))_pre[cxx] + <llvm-core/clang-$(( CLANG_MAX_VER + 1 ))_pre + ) + sys-process/numactl + debugger? ( + ${PYTHON_DEPS} + ) + examples? ( + media-libs/freeglut + media-libs/glu + ) + rdma? ( sys-cluster/rdma-core ) +" +BDEPEND=" + $(python_gen_any_dep ' + dev-python/defusedxml[${PYTHON_USEDEP}] + ') +" + +# CUDA_PATH="/opt/cuda-${PV}" #950207 +CUDA_PATH="/opt/cuda" +QA_PREBUILT="${CUDA_PATH#/}/*" + +PATCHES=( + "${FILESDIR}/nvidia-cuda-toolkit-glibc-2.41.patch" +) + +python_check_deps() { + python_has_version "dev-python/defusedxml[${PYTHON_USEDEP}]" +} + +cuda-toolkit_check_reqs() { + if use amd64; then + export CHECKREQS_DISK_BUILD="6645M" + elif use arm64; then + export CHECKREQS_DISK_BUILD="6412M" + fi + + "check-reqs_pkg_${EBUILD_PHASE}" +} + +cuda_verify() { + if has_version "sys-apps/grep[pcre]"; then + local DRIVER_PV_info + DRIVER_PV_info="$(bash "${DISTDIR}/${A}" --info | grep -oP "cuda_${PV}.*run" | cut -d '_' -f 3)" + + if [[ "${DRIVER_PV}" != "${DRIVER_PV_info}" ]]; then + die "check DRIVER_PV is ${DRIVER_PV} and should be ${DRIVER_PV_info}" + fi + fi + + # rest only works in with unpacked sources + [[ "${EBUILD_PHASE}" != prepare ]] && return + + # run self checks + local compiler_versions GCC_HAS_VER CLANG_HAS_VER + compiler_versions="$( + grep -oP "unsupported (GNU|clang) version.*(gcc versions later than|clang version must be less than) [0-9]*" \ + "${S}"/builds/cuda_nvcc/targets/*/include/crt/host_config.h + )" + + GCC_HAS_VER="$( echo "${compiler_versions}" | grep gcc | grep -oP "(?<=than )[0-9]*")" + if [[ "${GCC_MAX_VER}" -ne "${GCC_HAS_VER}" ]]; then + eqawarn "check GCC_MAX_VER is ${GCC_MAX_VER} and should be ${GCC_HAS_VER}" + fi + + CLANG_HAS_VER="$(( $(echo "${compiler_versions}" | grep clang | grep -oP "(?<=than )[0-9]*") - 1 ))" + if [[ "${CLANG_MAX_VER}" -ne "${CLANG_HAS_VER}" ]]; then + eqawarn "check CLANG_MAX_VER is ${CLANG_MAX_VER} and should be ${CLANG_HAS_VER}" + fi +} + +pkg_pretend() { + cuda-toolkit_check_reqs +} + +pkg_setup() { + cuda-toolkit_check_reqs + + # we need python for manifest parsing and to determine the supported python versions for cuda-gdb + python_setup + + if use amd64; then + narch=x86_64 + elif use arm64; then + narch=sbsa + else + die "unknown arch ${ARCH}" + fi + + export narch +} + +src_unpack() { + cuda_verify + + local exclude=( + "cuda-installer" + "*-uninstaller" + "NVIDIA-Linux-${narch}-${DRIVER_PV}.run" + "builds/cuda_documentation" + "builds/cuda_nsight" + "builds/cuda_nvvp" + "builds/nsight_compute" + "builds/nsight_systems" + "builds/nvidia_fs" + ) + + bash "${DISTDIR}/${A}" --tar xf -X <(printf "%s\n" "${exclude[@]}") || die "failed to extract ${A}" +} + +src_configure() { + : +} + +src_compile() { + : +} + +src_install() { + local -x SKIP_COMPONENTS=( + "Kernel_Objects" + "Visual_Tools" + "Documentation" # obsolete + "cuda-gdb-src" # not used + ) + + ! use debugger && SKIP_COMPONENTS+=( "cuda-gdb" ) + ! use examples && SKIP_COMPONENTS+=( "Demo_Suite" ) + ! use profiler && SKIP_COMPONENTS+=( "cuda-cupti" "cuda-profiler-api" "nvprof" ) + ! use sanitizer && SKIP_COMPONENTS+=( "compute-sanitizer" ) + + dodir "${CUDA_PATH}" + into "${CUDA_PATH}" + + dofile() { + debug-print-function "${FUNCNAME[0]}" "$@" + + if [[ $# -ne 1 ]] && [[ $# -ne 2 ]]; then + die "${FUNCNAME[0]} must receive one or two arguments" + fi + + local _DESTDIR + _DESTDIR="$(dirname "${CUDA_PATH}/${1%/}")${2:+/${2%/}}" + mkdir -p "${ED}${_DESTDIR}" || die "mkdir ${_DESTDIR} failed" + + local dir + dir="$(dirname "${1}")" + + if test -z "$(find "${dir}" -maxdepth 1 -name "$(basename "$1")" -print -quit)"; then + if [[ -e "${ED}${_DESTDIR}/$(basename "${1}")" ]]; then + return + fi + if [[ "$1" == "targets/x86_64-linux/lib/stubs/libcusolverMg*" ]] || + [[ "$1" == "targets/x86_64-linux/lib/libcusparse.so.*" ]]; then + return + fi + return + fi + + if [[ -e "${ED}${_DESTDIR}/$(basename "${1}")" ]]; then + # skip noisy warnings + if [[ "$(basename "${1}")" == "include" ]] || + [[ "$(basename "${1}")" == "lib64" ]]; then + return + fi + eqawarn "${ED}${_DESTDIR}/$(basename "${1}") exists" + return + fi + + eval mv -i "${1}" "${ED}${_DESTDIR}" || die "mv failed ${PWD} / ${1} -> ${ED} ${_DESTDIR}" + } + + dopcfile() { + [[ $# -eq 0 ]] && return + + dodir "${CUDA_PATH}/pkgconfig" + cat > "${ED}${CUDA_PATH}/pkgconfig/${1}-${2}.pc" <<-EOF || die "dopcfile" + cudaroot=${EPREFIX}${CUDA_PATH} + libdir=\${cudaroot}/targets/${narch}-linux/lib${4} + includedir=\${cudaroot}/targets/${narch}-linux/include + + Name: ${1} + Description: ${3} + Version: ${2} + Libs: -L\${libdir} -l${1} + Cflags: -I\${includedir} + EOF + } + + pushd builds >/dev/null || die + fix_executable_bit=( + cuda_cupti/extras/CUPTI/samples/pc_sampling_utility/pc_sampling_utility_helper.h + cuda_cupti/extras/CUPTI/samples/pc_sampling_continuous/libpc_sampling_continuous.pl + + libcufile/gds/tools/run_gdsio.cfg + ) + + if use amd64; then + fix_executable_bit+=( + cuda_opencl/targets/*/include/CL/cl.hpp + + libcufile/targets/*/lib/libcufile_rdma_static.a + libcufile/targets/*/lib/libcufile_static.a + ) + fi + chmod -x "${fix_executable_bit[@]}" || die "failed chmod" + popd >/dev/null || die + + ebegin "parsing manifest" "${S}/manifests/cuda_"*.xml # {{{ + + "${EPYTHON}" "${FILESDIR}/parse_manifest.py" "${S}/manifests/cuda_"*".xml" &> "${T}/install.sh" \ + || die "failed to parse manifest" + # shellcheck disable=SC1091 + source "${T}/install.sh" || die "failed to source install script" + + eend $? # }}} + + if use debugger; then + if [[ -d "${ED}/${CUDA_PATH}/extras/Debugger/lib64" ]]; then + rmdir "${ED}/${CUDA_PATH}/extras/Debugger/lib64" || die "remove debugger lib64" + fi + + find "${ED}/${CUDA_PATH}/bin" -maxdepth 1 -name "cuda-gdb-*-tui" -print0 | while read -rd $'\0' tui_name; do + impl="$(basename "${tui_name}" | cut -d '-' -f 3 | tr '.' '_')" + + if ! has "${impl}" "${PYTHON_COMPAT[@]}" || ! use "python_targets_${impl}"; then + rm "${tui_name}" || die "tui-name rm ${tui_name}" + sed -e "/$(basename "${tui_name}")\"/d" -i "${ED}/${CUDA_PATH}/bin/cuda-gdb" || die "tui_name sed" + fi + done + fi + + # remove rdma libs (unless USE=rdma) + if ! use rdma; then + rm "${ED}/${CUDA_PATH}/targets/${narch}-linux/lib/libcufile_rdma"* || die "failed to remove rdma files" + fi + + # Add include and lib symlinks + dosym "targets/${narch}-linux/include" "${CUDA_PATH}/include" + dosym "targets/${narch}-linux/lib" "${CUDA_PATH}/lib64" + + find "${ED}/${CUDA_PATH}" -empty -delete || die + + local ldpathextradirs pathextradirs + + use debugger && ldpathextradirs+=":${EPREFIX}${CUDA_PATH}/extras/Debugger/lib64" + use profiler && ldpathextradirs+=":${EPREFIX}${CUDA_PATH}/extras/CUPTI/lib64" + + local revord=$(( 999999 - $(printf "%02d%02d%02d" "$(ver_cut 1)" "$(ver_cut 2)" "$(ver_cut 3)") )) + newenvd - "99cuda${revord}" <<-EOF + PATH=${EPREFIX}${CUDA_PATH}/bin${pathextradirs} + PKG_CONFIG_PATH=${EPREFIX}${CUDA_PATH}/pkgconfig + LDPATH=${EPREFIX}${CUDA_PATH}/lib64:${EPREFIX}${CUDA_PATH}/nvvm/lib64${ldpathextradirs} + EOF + + # CUDA prepackages libraries, don't revdep-build on them + insinto /etc/revdep-rebuild + newins - "80${PN}${revord}" <<-EOF + SEARCH_DIRS_MASK="${EPREFIX}${CUDA_PATH}" + EOF + + # https://bugs.gentoo.org/926116 + insinto /etc/sandbox.d + newins - "80${PN}" <<-EOF + SANDBOX_PREDICT="/proc/self/task" + EOF + + # TODO drop and replace with runtime detection similar to what python does {{{ + # ATTENTION: change requires revbump, see link below for supported GCC # versions + # https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#system-requirements + local cuda_supported_gcc=( 8.5 9.5 10 11 12 13 "${GCC_MAX_VER}" ) + + sed \ + -e "s:CUDA_SUPPORTED_GCC:${cuda_supported_gcc[*]}:g" \ + "${FILESDIR}"/cuda-config.in > "${ED}/${CUDA_PATH}/bin/cuda-config" || die + fperms +x "${CUDA_PATH}/bin/cuda-config" + # }}} + + # skip til cudnn has been changed #950207 + # if [[ "${SLOT}" != "${PV}" ]]; then + # dosym "${CUDA_PATH}" "${CUDA_PATH%"-${PV}"}" + # fi + + fowners -R root:root "${CUDA_PATH}" +} + +pkg_postinst_check() { + if tc-is-gcc && + ver_test "$(gcc-major-version)" -gt "${GCC_MAX_VER}"; then + ewarn + ewarn "gcc > ${GCC_MAX_VER} will not work with CUDA" + ewarn + ewarn "Append --ccbin= pointing to a gcc bindir to the nvcc compiler flags (NVCCFLAGS)" + ewarn "or set NVCC_CCBIN to the same bindir." + ewarn " NVCCFLAGS=\"--ccbin=$(eval echo "${EPREFIX}/usr/*-linux-gnu/gcc-bin/${GCC_MAX_VER}")\"" + ewarn " NVCC_CCBIN=$(eval echo "${EPREFIX}/usr/*-linux-gnu/gcc-bin/${GCC_MAX_VER}")" + ewarn + fi + + if tc-is-clang && + ver_test "$(clang-major-version)" -gt "${CLANG_MAX_VER}"; then + ewarn + ewarn "clang > ${CLANG_MAX_VER} will not work with CUDA" + ewarn + ewarn "Append --ccbin= pointing to a clang bindir to the nvcc compiler flags (NVCCFLAGS)" + ewarn "or set NVCC_CCBIN to the same bindir." + ewarn " NVCCFLAGS=\"--ccbin=$(eval echo "${EPREFIX}/usr/lib/llvm/*/bin${CLANG_MAX_VER}")\"" + ewarn " NVCC_CCBIN=$(eval echo "${EPREFIX}/usr/lib/llvm/*/bin${CLANG_MAX_VER}")" + ewarn + fi +} + +pkg_postinst() { + if [[ ${MERGE_TYPE} != binary ]]; then + pkg_postinst_check + fi + + if use profiler; then + einfo + einfo "nvidia-drivers restricts access to performance counters." + einfo "You'll need to run profiling tools (nvprof) " + einfo "using sudo (needs cap SYS_ADMIN) or add the following line to " + einfo "a modprobe configuration file " + einfo "(e.g. /etc/modprobe.d/nvidia-prof.conf): " + einfo + einfo "options nvidia NVreg_RestrictProfilingToAdminUsers=0" + einfo + fi +} |