Line 0
Link Here
|
0 |
- |
1 |
# Copyright 1999-2019 Gentoo Authors |
|
|
2 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
|
4 |
EAPI=7 |
5 |
|
6 |
inherit check-reqs cuda toolchain-funcs unpacker |
7 |
|
8 |
MYD=$(ver_cut 1-2 ${PV}) |
9 |
DRIVER_PV="418.67" |
10 |
|
11 |
DESCRIPTION="NVIDIA CUDA Toolkit (compiler and friends)" |
12 |
HOMEPAGE="https://developer.nvidia.com/cuda-zone" |
13 |
SRC_URI="https://developer.nvidia.com/compute/cuda/${MYD}/Prod/local_installers/cuda_${PV}_${DRIVER_PV}_linux.run -> cuda_${PV}_${DRIVER_PV}_linux.run" |
14 |
|
15 |
LICENSE="NVIDIA-CUDA" |
16 |
SLOT="0/${PV}" |
17 |
KEYWORDS="-* ~amd64 ~amd64-linux" |
18 |
IUSE="debugger doc eclipse profiler" |
19 |
|
20 |
DEPEND="" |
21 |
RDEPEND="${DEPEND} |
22 |
<sys-devel/gcc-9[cxx] |
23 |
>=x11-drivers/nvidia-drivers-396.24[X,uvm] |
24 |
debugger? ( |
25 |
sys-libs/libtermcap-compat |
26 |
sys-libs/ncurses:5/5[tinfo] |
27 |
) |
28 |
eclipse? ( >=virtual/jre-1.6 ) |
29 |
profiler? ( >=virtual/jre-1.6 )" |
30 |
|
31 |
S="${WORKDIR}" |
32 |
|
33 |
QA_PREBUILT="opt/cuda/*" |
34 |
|
35 |
CHECKREQS_DISK_BUILD="6100M" |
36 |
|
37 |
pkg_setup() { |
38 |
# We don't like to run cuda_pkg_setup as it depends on us |
39 |
check-reqs_pkg_setup |
40 |
} |
41 |
|
42 |
src_prepare() { |
43 |
local cuda_supported_gcc |
44 |
|
45 |
cuda_supported_gcc="4.7 4.8 4.9 5.3 5.4 6.3 6.4 7.2 7.3 8.2 8.3" |
46 |
|
47 |
sed \ |
48 |
-e "s:CUDA_SUPPORTED_GCC:${cuda_supported_gcc}:g" \ |
49 |
"${FILESDIR}"/cuda-config.in > "${T}"/cuda-config || die |
50 |
|
51 |
default |
52 |
} |
53 |
|
54 |
src_install() { |
55 |
local i remove=( doc jre run_files install-linux.pl cuda-installer.pl ) |
56 |
local cudadir=/opt/cuda |
57 |
local ecudadir="${EPREFIX}${cudadir}" |
58 |
|
59 |
cd builds/cuda-toolkit |
60 |
if use doc; then |
61 |
DOCS+=( doc/pdf/. ) |
62 |
HTML_DOCS+=( doc/html/. ) |
63 |
fi |
64 |
einstalldocs |
65 |
|
66 |
mv doc/man/man3/{,cuda-}deprecated.3 || die |
67 |
doman doc/man/man*/* |
68 |
|
69 |
use debugger || remove+=( bin/cuda-gdb bin/cuda-gdbserver extras/Debugger share/gdb extras/cuda-gdb-${PV}.src.tar.gz ) |
70 |
|
71 |
if use profiler; then |
72 |
# hack found in install-linux.pl |
73 |
for i in nvvp nsight; do |
74 |
cat > bin/${i} <<- EOF || die |
75 |
#!/usr/bin/env sh |
76 |
LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:${ecudadir}/lib:${ecudadir}/lib64 \ |
77 |
UBUNTU_MENUPROXY=0 LIBOVERLAY_SCROLLBAR=0 \ |
78 |
${ecudadir}/lib${i}/${i} -vm ${EPREFIX}/usr/bin/java \$@ |
79 |
EOF |
80 |
chmod a+x bin/${i} || die |
81 |
done |
82 |
else |
83 |
use eclipse || remove+=( libnvvp libnsight nsightee_plugins NsightCompute-2019.1 NsightSystems-2018.3 bin/nsight bin/nsight_ee_plugins_manage.sh bin/nvvp bin/computeprof ) |
84 |
remove+=( extras/CUPTI bin/nvprof ) |
85 |
fi |
86 |
|
87 |
for i in "${remove[@]}"; do |
88 |
ebegin "Cleaning ${i}..." |
89 |
rm -rf "${i}" || die |
90 |
eend |
91 |
done |
92 |
|
93 |
dodir ${cudadir} |
94 |
into ${cudadir} |
95 |
|
96 |
# Install binaries separately to make sure the X permission is set |
97 |
local bindirs=( bin nvvm/bin extras/demo_suite ) |
98 |
for i in $(find "${bindirs[@]}" -maxdepth 1 -type f) \ |
99 |
libnsight/nsight \ |
100 |
libnvvp/nvvp \ |
101 |
NsightCompute-2019.3/target/linux-desktop-glibc_2_11_3-x86/TreeLauncherTargetLdPreloadHelper \ |
102 |
NsightCompute-2019.3/target/linux-desktop-glibc_2_11_3-x64/TreeLauncherSubreaper \ |
103 |
NsightCompute-2019.3/target/linux-desktop-glibc_2_11_3-x64/TreeLauncherTargetLdPreloadHelper \ |
104 |
NsightCompute-2019.3/target/linux-desktop-glibc_2_11_3-x64/nv-nsight-cu-cli \ |
105 |
NsightCompute-2019.3/host/linux-desktop-glibc_2_11_3-x64/libexec/QtWebEngineProcess \ |
106 |
NsightCompute-2019.3/host/linux-desktop-glibc_2_11_3-x64/nv-nsight-cu.bin \ |
107 |
NsightCompute-2019.3/host/linux-desktop-glibc_2_11_3-x64/CrashReporter \ |
108 |
NsightCompute-2019.3/host/linux-desktop-glibc_2_11_3-x64/nv-nsight-cu \ |
109 |
NsightCompute-2019.3/nv-nsight-cu-cli \ |
110 |
NsightCompute-2019.3/nv-nsight-cu \ |
111 |
NsightSystems-2019.3/Target-x86_64/x86_64/nsys \ |
112 |
NsightSystems-2019.3/Target-x86_64/x86_64/launcher \ |
113 |
NsightSystems-2019.3/Target-x86_64/x86_64/quadd_d \ |
114 |
NsightSystems-2019.3/Host-x86_64/ImportNvtxt \ |
115 |
NsightSystems-2019.3/Host-x86_64/QdstrmImporter \ |
116 |
NsightSystems-2019.3/Host-x86_64/CrashReporter \ |
117 |
NsightSystems-2019.3/Host-x86_64/ResolveSymbols \ |
118 |
NsightSystems-2019.3/Host-x86_64/nsight-sys.bin \ |
119 |
NsightSystems-2019.3/Host-x86_64/nsys-exporter \ |
120 |
NsightSystems-2019.3/Host-x86_64/nsight-sys \ |
121 |
; do |
122 |
exeinto ${cudadir}/${i%/*} |
123 |
doexe ${i} |
124 |
rm ${i} || die |
125 |
done |
126 |
|
127 |
# Install the rest |
128 |
insinto ${cudadir} |
129 |
doins -r * |
130 |
|
131 |
cat > "${T}"/99cuda <<- EOF || die |
132 |
PATH=${ecudadir}/bin$(usex profiler ":${ecudadir}/libnvvp" "") |
133 |
ROOTPATH=${ecudadir}/bin |
134 |
LDPATH=${ecudadir}/lib64:${ecudadir}/lib:${ecudadir}/nvvm/lib64 |
135 |
EOF |
136 |
doenvd "${T}"/99cuda |
137 |
|
138 |
# use profiler && \ |
139 |
# make_wrapper nvprof "${ecudadir}/bin/nvprof" "." "${ecudadir}/lib64:${ecudadir}/lib" |
140 |
|
141 |
dobin "${T}"/cuda-config |
142 |
} |
143 |
|
144 |
pkg_postinst_check() { |
145 |
local a b |
146 |
a="$(${EROOT%/}/opt/cuda/bin/cuda-config -s)" |
147 |
b="0.0" |
148 |
for v in $a; do |
149 |
if ver_test "${v}" -gt "${b}"; then |
150 |
b="${v}" |
151 |
fi |
152 |
done |
153 |
|
154 |
# if gcc and if not gcc-version is at least greatest supported |
155 |
if tc-is-gcc && \ |
156 |
ver_test $(gcc-version) -gt ${b}; then |
157 |
ewarn "" |
158 |
ewarn "gcc >= ${b} will not work with CUDA" |
159 |
ewarn "Make sure you set an earlier version of gcc with gcc-config" |
160 |
ewarn "or append --compiler-bindir= pointing to a gcc bindir like" |
161 |
ewarn "--compiler-bindir=${EPREFIX}/usr/*pc-linux-gnu/gcc-bin/gcc${b}" |
162 |
ewarn "to the nvcc compiler flags" |
163 |
ewarn "" |
164 |
fi |
165 |
} |
166 |
|
167 |
pkg_postinst() { |
168 |
if [[ ${MERGE_TYPE} != binary ]]; then |
169 |
pkg_postinst_check |
170 |
fi |
171 |
} |