Added dev-util/nvidia-cuda-toolkit-13.0.0
This commit is contained in:
		
							
								
								
									
										7
									
								
								dev-util/nvidia-cuda-toolkit/Manifest
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								dev-util/nvidia-cuda-toolkit/Manifest
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | ||||
| AUX cuda-config.in 407 BLAKE2B 5f7a0d50d774db58c180b767f00bead7c7dbf5f6b3b4a2f960dfc3b8450f7abf5c2b67c6620c5318f1331646dd2003d61c70a4c31359efd16ff418ecc9d0b446 SHA512 363903b999c43a47a48c52e8898c6044fadcc66d259338ee22863e859c2bc9873a2f1392aa83c9182486d3aa4eaeb5f164cf8ccf29cc74fd8ad56245f76a039a | ||||
| AUX nvidia-cuda-toolkit-glibc-2.42.patch 1133 BLAKE2B 861f343e2f0921d5bfa17276de8cea2ab99e95e5e129e34f053a0feb29437adc2004bd8d25010ccf6c25e475b1549101c1970c0b5174559ab3676995b123282e SHA512 9a39a47d862f55f1e891227ce4d5b0e639f22f57cf3ab5ffee48e02de46a98f7e9c625556bf62eaba82c11d12ccf6b30d1eb91c085c2a0168681f712d4d50e87 | ||||
| AUX parse_manifest.py 8488 BLAKE2B 8ac93a39276eaf89b41a5b0baa168b5974423077b0fd4b22841451514513c914fb4188863d73591f89975cc833dcb88bde289b0676f218715d8735a2d5c0f159 SHA512 4b2d9de215858d25319254666a22a184e26510a3488fc97a939704fab1e81a9baa363fc1168129618ce076de84d7acbeb71d98b8be272017f47b54c237d9b9a4 | ||||
| DIST cuda_13.0.0_580.65.06_linux.run 4300799649 BLAKE2B 7eaed96412d7bd937304780882cd4e3fd7feeccd0ee32c7a780bfc76155cbb1f2aea9e2b114202cb797e93467c6f34f98120c4cd02a6f7722c418b62e8b62a67 SHA512 1d09fd6f966e009c5ec461f72839bc70305cda99850ed58c446e4abffb25d9b88e50c0f03a23af13e90245be4b633592a50404cc7dd92cca42e21b8f8d790984 | ||||
| DIST cuda_13.0.0_580.65.06_linux_sbsa.run 3983090672 BLAKE2B 8c1d3904c8a7fc40bceedf77a6602a7cfb114c8ad0ea2954d34d9d6d21af80be956a58d41387c24666f66f6f5cafe7305a981b3a5d25fe77cc91a639caa8cc08 SHA512 58acff4db5c62a640517b24006ced20da6bc4ea2c9c15eb0bf6f054bc7599b109ade45ee11bd9bf413f20a283631b669cabaa5cd8e98891f766c922a9eb9a182 | ||||
| EBUILD nvidia-cuda-toolkit-13.0.0.ebuild 10904 BLAKE2B 48c710566b045ecb587166524ad142f92f8fd2e0c545ef32a6fadd0c8cc639657f30682ad2576e473e2e23ccedab2dd599ce7829c3509c76e540eec102419835 SHA512 4500d13494536c47fbdab5f9528cd60d38fa177c38e386c02a1c5fbdd3cdb7004be766568e4445b5b53a4c5f27dc8213341c53e002769f273d4b48c8d156aaf3 | ||||
| MISC metadata.xml 843 BLAKE2B 5ed06252572415290175ff90b66c1e13b67d282085295586e046019cc7d28b6e11728fba310bcf4101caaf09f4d1383f8df3f1c97325fa9e979dfa06e4704571 SHA512 208c83e0d968796d526b7223c5221f0805401b31420807a21f078797cba8e3f141c654017331a89649af2aa29a40cc1ff28f9cfa3ba2e6bee85fa76957c01837 | ||||
							
								
								
									
										28
									
								
								dev-util/nvidia-cuda-toolkit/files/cuda-config.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								dev-util/nvidia-cuda-toolkit/files/cuda-config.in
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,28 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| SUPPORT_GCC_VERSIONS_BY_CUDA="CUDA_SUPPORTED_GCC" | ||||
|  | ||||
| _print_help() { | ||||
| 	cat <<- EOF | ||||
| 	Usage: | ||||
| 		$(basename $0) [options] | ||||
| 	 | ||||
| 		-s | --supported   Returns by current CUDA supported gcc versions | ||||
| 		-h | --help        Shows this help | ||||
| 	EOF | ||||
| } | ||||
|  | ||||
| case ${1} in | ||||
| 	-s|--supported) | ||||
| 		echo "${SUPPORT_GCC_VERSIONS_BY_CUDA}" | ||||
| 		exit 0 | ||||
| 		;; | ||||
| 	-h|--help) | ||||
| 		_print_help | ||||
| 		exit 255 | ||||
| 		;; | ||||
| 	*) | ||||
| 		_print_help | ||||
| 		exit 1 | ||||
| 		;; | ||||
| esac | ||||
| @@ -0,0 +1,27 @@ | ||||
| diff '--color=auto' -ur a/builds/cuda_crt/targets/x86_64-linux/include/crt/math_functions.h b/builds/cuda_crt/targets/x86_64-linux/include/crt/math_functions.h | ||||
| --- a/builds/cuda_crt/targets/x86_64-linux/include/crt/math_functions.h | ||||
| +++ b/builds/cuda_crt/targets/x86_64-linux/include/crt/math_functions.h | ||||
| @@ -626,7 +626,11 @@ | ||||
|   * | ||||
|   * \note_accuracy_double | ||||
|   */ | ||||
| +#if defined(__GLIBC__) && (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 42) | ||||
| +extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double                 rsqrt(double x) noexcept (true); | ||||
| +#else | ||||
|  extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double                 rsqrt(double x); | ||||
| +#endif | ||||
|   | ||||
|  /** | ||||
|   * \ingroup CUDA_MATH_SINGLE | ||||
| @@ -650,7 +654,11 @@ | ||||
|   * | ||||
|   * \note_accuracy_single | ||||
|   */ | ||||
| +#if defined(__GLIBC__) && (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 42) | ||||
| +extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float                  rsqrtf(float x) noexcept (true); | ||||
| +#else | ||||
|  extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float                  rsqrtf(float x); | ||||
| +#endif | ||||
|   | ||||
|  #if defined(__QNX__) && !defined(_LIBCPP_VERSION) | ||||
|  namespace std { | ||||
							
								
								
									
										223
									
								
								dev-util/nvidia-cuda-toolkit/files/parse_manifest.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										223
									
								
								dev-util/nvidia-cuda-toolkit/files/parse_manifest.py
									
									
									
									
									
										Normal file
									
								
							| @@ -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() | ||||
							
								
								
									
										17
									
								
								dev-util/nvidia-cuda-toolkit/metadata.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								dev-util/nvidia-cuda-toolkit/metadata.xml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd"> | ||||
| <pkgmetadata> | ||||
| 	<maintainer type="project"> | ||||
| 		<email>sci@gentoo.org</email> | ||||
| 		<name>Gentoo Science Project</name> | ||||
| 	</maintainer> | ||||
| 	<use> | ||||
| 		<flag name="clang">Depend on <pkg>llvm-core/clang</pkg> as host compiler</flag> | ||||
| 		<flag name="debugger">Install the CUDA debugger</flag> | ||||
| 		<flag name="nsight">Install profiling and optimizing tools (nsight-compute, nsight-systems)</flag> | ||||
| 		<flag name="profiler">Install the NVIDIA CUDA profiler (nvprof) and the related libraries</flag> | ||||
| 		<flag name="rdma">Enable infiniband support via <pkg>sys-cluster/rdma-core</pkg></flag> | ||||
| 		<flag name="sanitizer">Install compute-sanitizer tool</flag> | ||||
| 		<flag name="vis-profiler">Install the NVIDIA CUDA visual profiler (nvvp)</flag> | ||||
| 	</use> | ||||
| </pkgmetadata> | ||||
							
								
								
									
										386
									
								
								dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-13.0.0.ebuild
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										386
									
								
								dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-13.0.0.ebuild
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,386 @@ | ||||
| # Copyright 1999-2025 Gentoo Authors | ||||
| # Distributed under the terms of the GNU General Public License v2 | ||||
|  | ||||
| # shellcheck disable=SC2317 | ||||
|  | ||||
| EAPI=8 | ||||
|  | ||||
| PYTHON_COMPAT=( python3_{11..13} ) | ||||
| inherit check-reqs edo toolchain-funcs | ||||
| inherit python-r1 | ||||
|  | ||||
| DRIVER_PV="580.65.06" | ||||
| GCC_MAX_VER="15" | ||||
| CLANG_MAX_VER="20" | ||||
|  | ||||
| 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="clang debugger examples nsight 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=" | ||||
| 	!clang? ( | ||||
| 		<sys-devel/gcc-$(( GCC_MAX_VER + 1 ))_pre[cxx] | ||||
| 	) | ||||
| 	clang? ( | ||||
| 		<llvm-core/clang-$(( CLANG_MAX_VER + 1 ))_pre | ||||
| 	) | ||||
| 	sys-process/numactl | ||||
| 	debugger? ( | ||||
| 		${PYTHON_DEPS} | ||||
| 	) | ||||
| 	examples? ( | ||||
| 		media-libs/freeglut | ||||
| 		media-libs/glu | ||||
| 	) | ||||
| 	nsight? ( | ||||
| 		dev-util/nsight-compute | ||||
| 		dev-util/nsight-systems | ||||
| 	) | ||||
| 	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#/}/*" | ||||
|  | ||||
| python_check_deps() { | ||||
| 	python_has_version "dev-python/defusedxml[${PYTHON_USEDEP}]" | ||||
| } | ||||
|  | ||||
| cuda-toolkit_check_reqs() { | ||||
| 	if use amd64; then | ||||
| 		export CHECKREQS_DISK_BUILD="7228M" | ||||
| 	elif use arm64; then | ||||
| 		export CHECKREQS_DISK_BUILD="6998M" | ||||
| 	fi | ||||
|  | ||||
| 	"check-reqs_pkg_${EBUILD_PHASE}" | ||||
| } | ||||
|  | ||||
| cuda_verify() { | ||||
| 	# only works 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 | ||||
|  | ||||
| 	if [[ "${MERGE_TYPE}" == binary ]]; then | ||||
| 		return | ||||
| 	fi | ||||
|  | ||||
| 	# 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" | ||||
| 	) | ||||
|  | ||||
| 	edob -m "Extracting ${A}" \ | ||||
| 		bash "${DISTDIR}/${A}" --tar xf -X <(printf "%s\n" "${exclude[@]}") | ||||
| } | ||||
|  | ||||
| src_prepare() { | ||||
| 	eapply -p1 "${FILESDIR}/nvidia-cuda-toolkit-glibc-2.42.patch" | ||||
|  | ||||
| 	default | ||||
| } | ||||
|  | ||||
| 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}.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 | ||||
| 	mv "${D}${CUDA_PATH}/include/crt" "${D}${CUDA_PATH}/targets/${narch}-linux/include" | ||||
| 	rmdir "${D}${CUDA_PATH}/include" | ||||
| 	dosym -r "${CUDA_PATH}/targets/${narch}-linux/include" "${CUDA_PATH}/include" | ||||
| 	dosym -r "${CUDA_PATH}/targets/${narch}-linux/lib" "${CUDA_PATH}/$(get_libdir)" | ||||
|  | ||||
| 	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}/$(get_libdir):${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 14 "${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 -r "${CUDA_PATH}" "${CUDA_PATH%"-${PV}"}" | ||||
| 	# fi | ||||
|  | ||||
| 	fowners -R root:root "${CUDA_PATH}" | ||||
| } | ||||
|  | ||||
| pkg_postinst_check() { | ||||
| 	# Due to requiring specific compiler versions here, we check more then we have to, for the sake of clarity. | ||||
| 	# tc-getCC defaults to gcc, so clang-major-version is checked using gcc and fails on gcc-profiles. # 959420 | ||||
| 	# We therefore force gcc and clang for the check. | ||||
|  | ||||
| 	if tc-is-gcc || ! use clang; then | ||||
| 		if ver_test "$(CC=gcc 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 | ||||
| 	fi | ||||
|  | ||||
| 	if tc-is-clang || use clang; then | ||||
| 		if ver_test "$(CC=clang 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 | ||||
| 	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 | ||||
| } | ||||
							
								
								
									
										16
									
								
								metadata/md5-cache/dev-util/nvidia-cuda-toolkit-13.0.0
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								metadata/md5-cache/dev-util/nvidia-cuda-toolkit-13.0.0
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| BDEPEND=|| ( ( dev-lang/python:3.13 dev-python/defusedxml[python_targets_python3_13(-)] ) ( dev-lang/python:3.12 dev-python/defusedxml[python_targets_python3_12(-)] ) ( dev-lang/python:3.11 dev-python/defusedxml[python_targets_python3_11(-)] ) ) | ||||
| DEFINED_PHASES=compile configure install postinst prepare pretend setup unpack | ||||
| DESCRIPTION=NVIDIA CUDA Toolkit (compiler and friends) | ||||
| EAPI=8 | ||||
| HOMEPAGE=https://developer.nvidia.com/cuda-zone | ||||
| INHERIT=check-reqs edo toolchain-funcs python-r1 | ||||
| IUSE=clang debugger examples nsight profiler rdma sanitizer python_targets_python3_11 python_targets_python3_12 python_targets_python3_13 | ||||
| KEYWORDS=-* ~amd64 ~arm64 ~amd64-linux ~arm64-linux | ||||
| LICENSE=NVIDIA-CUDA | ||||
| RDEPEND=!clang? ( <sys-devel/gcc-16_pre[cxx] ) clang? ( <llvm-core/clang-21_pre ) sys-process/numactl debugger? ( python_targets_python3_11? ( dev-lang/python:3.11 ) python_targets_python3_12? ( dev-lang/python:3.12 ) python_targets_python3_13? ( dev-lang/python:3.13 ) ) examples? ( media-libs/freeglut media-libs/glu ) nsight? ( dev-util/nsight-compute dev-util/nsight-systems ) rdma? ( sys-cluster/rdma-core ) | ||||
| REQUIRED_USE=|| ( python_targets_python3_11 python_targets_python3_12 python_targets_python3_13 ) | ||||
| RESTRICT=bindist mirror strip test | ||||
| SLOT=0/13.0.0 | ||||
| SRC_URI=amd64? ( https://developer.download.nvidia.com/compute/cuda/13.0.0/local_installers/cuda_13.0.0_580.65.06_linux.run ) arm64? ( https://developer.download.nvidia.com/compute/cuda/13.0.0/local_installers/cuda_13.0.0_580.65.06_linux_sbsa.run ) | ||||
| _eclasses_=check-reqs	2a9731073c152554078a9a8df8fc0f1b	edo	a5e294016aa84979fcb2459749eb80b2	toolchain-funcs	a0b29008c671a362b505f96fa80ce9c0	out-of-source-utils	dbf9e34ee8964084651e25907fa8f52c	multibuild	4650a65187015567b4e041bb9bfdb364	multiprocessing	1e32df7deee68372153dca65f4a7c21f	python-utils-r1	8a006695bc0db22490452dd06914dda5	python-r1	0e15b2ab9cfc87d7474678201d6bca38 | ||||
| _md5_=b94382db6325ee343e23f6629e5fffc9 | ||||
		Reference in New Issue
	
	Block a user