Сравнение nvidia-drivers-390.157 с nvidia-drivers-470.199.02

/usr/portage/x11-drivers/nvidia-drivers/nvidia-drivers-470.199.02.ebuild 2023-10-09 14:52:35.912368512 +0300
7 7
inherit desktop flag-o-matic linux-mod-r1 multilib readme.gentoo-r1
8 8
inherit systemd toolchain-funcs unpacker user-info
9 9

  
10
MODULES_KERNEL_MAX=6.1
10
MODULES_KERNEL_MAX=6.4
11 11
NV_URI="https://download.nvidia.com/XFree86/"
12 12

  
13 13
DESCRIPTION="NVIDIA Accelerated Graphics Driver"
14 14
HOMEPAGE="https://www.nvidia.com/download/index.aspx"
15 15
SRC_URI="
16
	amd64? ( ${NV_URI}Linux-x86_64/${PV}/NVIDIA-Linux-x86_64-${PV}.run )
17
	x86? ( ${NV_URI}Linux-x86/${PV}/NVIDIA-Linux-x86-${PV}.run )
16
	${NV_URI}Linux-x86_64/${PV}/NVIDIA-Linux-x86_64-${PV}.run
18 17
	$(printf "${NV_URI}%s/%s-${PV}.tar.bz2 " \
19 18
		nvidia-{installer,modprobe,persistenced,settings,xconfig}{,})"
20 19
# nvidia-installer is unused but here for GPL-2's "distribute sources"
21 20
S="${WORKDIR}"
22 21

  
23
LICENSE="NVIDIA-r2 BSD BSD-2 GPL-2 MIT"
22
LICENSE="NVIDIA-r2 BSD BSD-2 GPL-2 MIT ZLIB curl openssl"
24 23
SLOT="0/${PV%%.*}"
25
KEYWORDS="-* amd64 x86"
26
IUSE="+X abi_x86_32 abi_x86_64 persistenced +static-libs +tools"
24
KEYWORDS="-* amd64"
25
IUSE="+X abi_x86_32 abi_x86_64 persistenced +static-libs +tools wayland"
27 26

  
28 27
COMMON_DEPEND="
29 28
	acct-group/video
......
51 50
		media-libs/libglvnd[X,abi_x86_32(-)?]
52 51
		x11-libs/libX11[abi_x86_32(-)?]
53 52
		x11-libs/libXext[abi_x86_32(-)?]
53
	)
54
	wayland? (
55
		~gui-libs/egl-wayland-1.1.7
56
		media-libs/libglvnd
54 57
	)"
55 58
DEPEND="
56 59
	${COMMON_DEPEND}
......
70 73
	sys-devel/m4
71 74
	virtual/pkgconfig"
72 75

  
73
QA_PREBUILT="opt/bin/* usr/lib*"
76
QA_PREBUILT="lib/firmware/* opt/bin/* usr/lib*"
74 77

  
75 78
PATCHES=(
76
	# note: no plans to add patches for newer kernels here, when the last
77
	# working 6.1.x LTS is EOL then 390 will simply be removed from the tree
79
	"${FILESDIR}"/nvidia-drivers-470.141.03-clang15.patch
78 80
	"${FILESDIR}"/nvidia-modprobe-390.141-uvm-perms.patch
79
	"${FILESDIR}"/nvidia-settings-390.141-fno-common.patch
80 81
	"${FILESDIR}"/nvidia-settings-390.144-desktop.patch
81 82
	"${FILESDIR}"/nvidia-settings-390.144-no-gtk2.patch
82 83
	"${FILESDIR}"/nvidia-settings-390.144-raw-ldflags.patch
......
91 92
		~SYSVIPC
92 93
		~!AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT
93 94
		~!LOCKDEP
95
		~!SLUB_DEBUG_ON
94 96
		~!X86_KERNEL_IBT
95 97
		!DEBUG_MUTEXES"
96 98

  
97 99
	local ERROR_DRM_KMS_HELPER="CONFIG_DRM_KMS_HELPER: is not set but needed for Xorg auto-detection
98
	of drivers (no custom config), and optional nvidia-drm.modeset=1.
99
	With 390.xx drivers, also used by a GLX workaround needed for OpenGL.
100
	of drivers (no custom config), and for wayland / nvidia-drm.modeset=1.
100 101
	Cannot be directly selected in the kernel's menuconfig, and may need
101 102
	selection of a DRM device even if unused, e.g. CONFIG_DRM_AMDGPU=m or
102 103
	DRM_I915=y, DRM_NOUVEAU=m also acceptable if a module and not built-in."
103 104

  
104 105
	local ERROR_X86_KERNEL_IBT="CONFIG_X86_KERNEL_IBT: is set and, if the CPU supports the feature,
105
	this will likely lead to modules load failure with ENDBR errors.
106
	Please ignore if not having issues, but otherwise try to unset or
107
	pass ibt=off to the kernel's command line." #911142
106
	this *could* lead to modules load failure with ENDBR errors, or to
107
	broken CUDA/NVENC. Please ignore if not having issues, but otherwise
108
	try to unset or pass ibt=off to the kernel's command line." #911142
108 109

  
109
	kernel_is -ge 5 8 && CONFIG_CHECK+=" X86_PAT" #817764
110
	use amd64 && kernel_is -ge 5 8 && CONFIG_CHECK+=" X86_PAT" #817764
110 111

  
111 112
	linux-mod-r1_pkg_setup
112 113
}
......
118 119
	rm nvidia-settings && mv nvidia-settings{-${PV},} || die
119 120
	rm nvidia-xconfig && mv nvidia-xconfig{-${PV},} || die
120 121

  
121
	eapply "${FILESDIR}"/nvidia-drivers-390.154-clang15$(usev {,-}x86).patch
122

  
123 122
	default
124 123

  
125 124
	# prevent detection of incomplete kernel DRM support (bug #603818)
......
131 130
		> "${T}"/nvidia-persistenced.service || die
132 131

  
133 132
	# use alternative vulkan icd option if USE=-X (bug #909181)
134
	sed "s/__NV_VK_ICD__/lib$(usex X GLX EGL)_nvidia.so.0/" \
135
		nvidia_icd.json.template > nvidia_icd.json || die
133
	use X || sed -i 's/"libGLX/"libEGL/' nvidia_{layers,icd}.json || die
136 134

  
137
	# 390 has legacy glx needing a modified .conf (bug #713546)
138
	# directory is not quite right, but kept for any existing custom xorg.conf
139
	sed "s|@LIBDIR@|${EPREFIX}/usr/$(get_libdir)|" \
140
		"${FILESDIR}"/nvidia-drm-outputclass-390.conf > nvidia-drm-outputclass.conf || die
135
	# enable nvidia-drm.modeset=1 by default with USE=wayland
136
	cp "${FILESDIR}"/nvidia-470.conf "${T}"/nvidia.conf || die
137
	use !wayland || sed -i '/^#.*modeset=1$/s/^#//' "${T}"/nvidia.conf || die
141 138
}
142 139

  
143 140
src_compile() {
144 141
	tc-export AR CC CXX LD OBJCOPY OBJDUMP
145 142
	local -x RAW_LDFLAGS="$(get_abi_LDFLAGS) $(raw-ldflags)" # raw-ldflags.patch
146 143

  
144
	local xnvflags=-fPIC #840389
145
	# lto static libraries tend to cause problems without fat objects
146
	is-flagq '-flto@(|=*)' && xnvflags+=" $(test-flags-CC -ffat-lto-objects)"
147

  
147 148
	NV_ARGS=(
148 149
		PREFIX="${EPREFIX}"/usr
149 150
		HOST_CC="$(tc-getBUILD_CC)"
150 151
		HOST_LD="$(tc-getBUILD_LD)"
151 152
		NV_USE_BUNDLED_LIBJANSSON=0
152 153
		NV_VERBOSE=1 DO_STRIP= MANPAGE_GZIP= OUTPUTDIR=out
154
		XNVCTRL_CFLAGS="${xnvflags}"
153 155
	)
154 156

  
155
	local modlist=( nvidia{,-drm,-modeset}=video:kernel )
156
	use x86 || modlist+=( nvidia-uvm=video:kernel )
157
	local modlist=( nvidia{,-drm,-modeset,-peermem,-uvm}=video:kernel )
157 158
	local modargs=(
158 159
		IGNORE_CC_MISMATCH=yes NV_VERBOSE=1
159 160
		SYSOUT="${KV_OUT_DIR}" SYSSRC="${KV_DIR}"
......
164 165
		CPP="${KERNEL_CC} -E" tc-is-clang && addpredict "${KV_OUT_DIR}"
165 166

  
166 167
	linux-mod-r1_src_compile
167

  
168
	if use persistenced; then
169
		# 390.xx persistenced does not auto-detect libtirpc
170
		LIBS=$($(tc-getPKG_CONFIG) --libs libtirpc || die) \
171
			common_cflags=$($(tc-getPKG_CONFIG) --cflags libtirpc || die) \
172
			emake "${NV_ARGS[@]}" -C nvidia-persistenced
173
	fi
174

  
175 168
	emake "${NV_ARGS[@]}" -C nvidia-modprobe
169
	use persistenced && emake "${NV_ARGS[@]}" -C nvidia-persistenced
176 170
	use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig
177 171

  
178 172
	if use tools; then
......
180 174
		CFLAGS="-Wno-deprecated-declarations ${CFLAGS}" \
181 175
			emake "${NV_ARGS[@]}" -C nvidia-settings
182 176
	elif use static-libs; then
183
		emake "${NV_ARGS[@]}" -C nvidia-settings/src build-xnvctrl
177
		emake "${NV_ARGS[@]}" -C nvidia-settings/src out/libXNVCtrl.a
184 178
	fi
185 179
}
186 180

  
......
193 187
		[APPLICATION_PROFILE]=/usr/share/nvidia
194 188
		[CUDA_ICD]=/etc/OpenCL/vendors
195 189
		[EGL_EXTERNAL_PLATFORM_JSON]=/usr/share/egl/egl_external_platform.d
190
		[FIRMWARE]=/lib/firmware/nvidia/${PV}
196 191
		[GLVND_EGL_ICD_JSON]=/usr/share/glvnd/egl_vendor.d
197
		[VULKAN_ICD_JSON]=/usr/share/vulkan/icd.d
192
		[VULKAN_ICD_JSON]=/usr/share/vulkan
193
		[WINE_LIB]=/usr/${libdir}/nvidia/wine
198 194
		[XORG_OUTPUTCLASS_CONFIG]=/usr/share/X11/xorg.conf.d
199 195

  
200 196
		[GLX_MODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules/extensions
201
		[GLX_MODULE_SYMLINK]=/usr/${libdir}/extensions/nvidia
197
		[GLX_MODULE_SYMLINK]=/usr/${libdir}/xorg/modules
202 198
		[XMODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules
203
		[XMODULE_SYMLINK]=/usr/${libdir}/xorg/modules
204 199
	)
205 200

  
206 201
	local skip_files=(
207
		$(usev !X "libGLX_nvidia libglx libnvidia-ifr")
202
		$(usev !X "libGLX_nvidia libglxserver_nvidia libnvidia-ifr")
203
		$(usev !wayland libnvidia-vulkan-producer)
208 204
		libGLX_indirect # non-glvnd unused fallback
209 205
		libnvidia-gtk nvidia-{settings,xconfig} # built from source
210 206
		libnvidia-egl-wayland 10_nvidia_wayland # gui-libs/egl-wayland
211 207
	)
212 208
	local skip_modules=(
213 209
		$(usev !X "nvfbc vdpau xdriver")
210
		$(usev !modules gsp)
214 211
		installer nvpd # handled separately / built from source
215 212
	)
216 213
	local skip_types=(
217 214
		GLVND_LIB GLVND_SYMLINK EGL_CLIENT.\* GLX_CLIENT.\* # media-libs/libglvnd
218 215
		OPENCL_WRAPPER.\* # virtual/opencl
219
		DOCUMENTATION DOT_DESKTOP # handled separately
220
		XMODULE_NEWSYM # use xorg's libwfb.so, nvidia also keeps it if it exists
221
		.\*_SRC DKMS_CONF LIBGL_LA OPENGL_HEADER # unused
216
		DOCUMENTATION DOT_DESKTOP .\*_SRC DKMS_CONF # handled separately / unused
222 217
	)
223 218

  
224 219
	local DOCS=(
225
		README.txt NVIDIA_Changelog
220
		README.txt NVIDIA_Changelog supported-gpus/supported-gpus.json
226 221
		nvidia-settings/doc/{FRAMELOCK,NV-CONTROL-API}.txt
227 222
	)
228 223
	local HTML_DOCS=( html/. )
......
250 245
$(use amd64 && usev !abi_x86_32 "
251 246

  
252 247
Note that without USE=abi_x86_32 on ${PN}, 32bit applications
253
(typically using wine / steam) will not be able to use GPU acceleration.")\
254
$(usev X "
255

  
256
390.xx libglvnd support is partial and requires different Xorg modules
257
for working OpenGL/GLX. If using the default Xorg configuration these
258
should be used automatically, otherwise manually add the ModulePath
259
from: '${EPREFIX}/${paths[XORG_OUTPUTCLASS_CONFIG]#/}/nvidia-drm-outputclass.conf'")\
260
$(usev x86 "
261

  
262
Note that NVIDIA is no longer offering support for the unified memory
263
module (nvidia-uvm) on x86 (32bit), as such the module is missing.
264
This means OpenCL/CUDA (and related, like nvenc) cannot be used.
265
Other functions, like OpenGL, will continue to work.")
266

  
267
Support from NVIDIA for 390.xx will end in December 2022, how long
268
Gentoo will be able to reasonably support it beyond that is unknown.
269
If wish to continue using this hardware, should consider switching
270
to the Nouveau open source driver.
271
https://nvidia.custhelp.com/app/answers/detail/a_id/3142/
248
(typically using wine / steam) will not be able to use GPU acceleration.")
272 249

  
273 250
For additional information or for troubleshooting issues, please see
274 251
https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers and NVIDIA's own
......
279 256
		linux-mod-r1_src_install
280 257

  
281 258
		insinto /etc/modprobe.d
282
		newins "${FILESDIR}"/nvidia-390.conf nvidia.conf
259
		doins "${T}"/nvidia.conf
260

  
261
		# used for gpu verification with binpkgs (not kept, see pkg_preinst)
262
		insinto /usr/share/nvidia
263
		doins supported-gpus/supported-gpus.json
283 264
	fi
284 265

  
285 266
	emake "${NV_ARGS[@]}" -C nvidia-modprobe install
......
304 285
	fi
305 286

  
306 287
	if use static-libs; then
307
		dolib.a nvidia-settings/src/libXNVCtrl/libXNVCtrl.a
288
		dolib.a nvidia-settings/src/out/libXNVCtrl.a
308 289

  
309 290
		insinto /usr/include/NVCtrl
310 291
		doins nvidia-settings/src/libXNVCtrl/NVCtrl{Lib,}.h
......
326 307
				gzip -dc ${m[0]} | newman - ${m[0]%.gz}; assert
327 308
				continue
328 309
			;;
329
			GLX_MODULE_SYMLINK|XMODULE_NEWSYM)
330
				# messy symlinks for non-glvnd xorg modules overrides put
331
				# in a different directory to avoid collisions (390-only)
332
				m[4]=../../xorg/modules/${m[3]#/}${m[4]}
333
				m[3]=/
334
			;;
335
			TLS_LIB) [[ ${m[4]} == CLASSIC ]] && continue;; # segfaults (bug #785289)
336 310
			VDPAU_SYMLINK) m[4]=vdpau/; m[5]=${m[5]#vdpau/};; # .so to vdpau/
337
			VULKAN_ICD_JSON) m[0]=${m[0]%.template};;
338 311
		esac
339 312

  
340 313
		if [[ -v 'paths[${m[2]}]' ]]; then
......
352 325
		[[ ${m[3]: -2} == ?/ ]] && into+=/${m[3]%/}
353 326
		[[ ${m[4]: -2} == ?/ ]] && into+=/${m[4]%/}
354 327

  
355
		if [[ ${m[2]} =~ _SYMLINK$|_NEWSYM$ ]]; then
328
		if [[ ${m[2]} =~ _SYMLINK$ ]]; then
356 329
			[[ ${m[4]: -1} == / ]] && m[4]=${m[5]}
357 330
			dosym ${m[4]} ${into}/${m[0]}
358 331
			continue
359 332
		fi
333
		[[ ${m[0]} =~ ^libnvidia-ngx.so ]] &&
334
			dosym ${m[0]} ${into}/${m[0]%.so*}.so.1 # soname not in .manifest
360 335

  
361 336
		printf -v m[1] %o $((m[1] | 0200)) # 444->644
362 337
		insopts -m${m[1]}
......
366 341
	insopts -m0644 # reset
367 342

  
368 343
	# MODULE:installer non-skipped extras
369
	dolib.so libnvidia-cfg.so.${PV}
370
	dosym libnvidia-cfg.so.${PV} /usr/${libdir}/libnvidia-cfg.so.1
371
	dosym libnvidia-cfg.so.${PV} /usr/${libdir}/libnvidia-cfg.so
344
	: "$(systemd_get_sleepdir)"
345
	exeinto "${_#"${EPREFIX}"}"
346
	doexe systemd/system-sleep/nvidia
347
	dobin systemd/nvidia-sleep.sh
348
	systemd_dounit systemd/system/nvidia-{hibernate,resume,suspend}.service
372 349

  
373 350
	dobin nvidia-bug-report.sh
374 351

  
......
376 353
	dosym nvidia-application-profiles-${PV}-key-documentation \
377 354
		${paths[APPLICATION_PROFILE]}/nvidia-application-profiles-key-documentation
378 355

  
379
	# sandbox issues with /dev/nvidiactl are widespread and sometime
380
	# affect revdeps of packages built with USE=opencl/cuda making it
381
	# hard to manage in ebuilds (minimal set, ebuilds should handle
382
	# manually if need others or addwrite)
356
	# don't attempt to strip firmware files (silences errors)
357
	dostrip -x ${paths[FIRMWARE]}
358

  
359
	# sandbox issues with /dev/nvidiactl (and /dev/char wrt bug #904292)
360
	# are widespread and sometime affect revdeps of packages built with
361
	# USE=opencl/cuda making it hard to manage in ebuilds (minimal set,
362
	# ebuilds should handle manually if need others or addwrite)
383 363
	insinto /etc/sandbox.d
384
	newins - 20nvidia <<<'SANDBOX_PREDICT="/dev/nvidiactl"'
364
	newins - 20nvidia <<<'SANDBOX_PREDICT="/dev/nvidiactl:/dev/char"'
385 365
}
386 366

  
387 367
pkg_preinst() {
368
	has_version "${CATEGORY}/${PN}[wayland]" && NV_HAD_WAYLAND=
369

  
388 370
	use modules || return
389 371

  
390 372
	# set video group id based on live system (bug #491414)
391 373
	local g=$(egetent group video | cut -d: -f3)
392 374
	[[ ${g} =~ ^[0-9]+$ ]] || die "Failed to determine video group id (got '${g}')"
393 375
	sed -i "s/@VIDEOGID@/${g}/" "${ED}"/etc/modprobe.d/nvidia.conf || die
376

  
377
	# try to find driver mismatches using temporary supported-gpus.json
378
	for g in $(grep -l 0x10de /sys/bus/pci/devices/*/vendor 2>/dev/null); do
379
		g=$(grep -io "\"devid\":\"$(<${g%vendor}device)\"[^}]*branch\":\"[0-9]*" \
380
			"${ED}"/usr/share/nvidia/supported-gpus.json 2>/dev/null)
381
		if [[ ${g} ]]; then
382
			g=$((${g##*\"}+1))
383
			if ver_test -ge ${g}; then
384
				NV_LEGACY_MASK=">=${CATEGORY}/${PN}-${g}"
385
				break
386
			fi
387
		fi
388
	done
389
	rm "${ED}"/usr/share/nvidia/supported-gpus.json || die
394 390
}
395 391

  
396 392
pkg_postinst() {
......
410 406
		fi
411 407
	fi
412 408

  
413
	ewarn
414
	ewarn "Be warned/reminded that the 390.xx branch reached end-of-life and"
415
	ewarn "NVIDIA is no longer fixing issues (including security). Free to keep"
416
	ewarn "using (for now) but it is recommended to either switch to nouveau or"
417
	ewarn "replace hardware. Will be kept in-tree while possible, but expect it"
418
	ewarn "to be removed likely in early 2027 or earlier if major issues arise."
409
	if [[ $(</proc/cmdline) == *slub_debug=[!-]* ]]; then
410
		ewarn "Detected that the current kernel command line is using 'slub_debug=',"
411
		ewarn "this may lead to system instability/freezes with this version of"
412
		ewarn "${PN}. Bug: https://bugs.gentoo.org/796329"
413
	fi
414

  
415
	if [[ -v NV_LEGACY_MASK ]]; then
416
		ewarn
417
		ewarn "***WARNING***"
418
		ewarn
419
		ewarn "You are installing a version of ${PN} known not to work"
420
		ewarn "with a GPU of the current system. If unwanted, add the mask:"
421
		if [[ -d ${EROOT}/etc/portage/package.mask ]]; then
422
			ewarn "  echo '${NV_LEGACY_MASK}' > ${EROOT}/etc/portage/package.mask/${PN}"
423
		else
424
			ewarn "  echo '${NV_LEGACY_MASK}' >> ${EROOT}/etc/portage/package.mask"
425
		fi
426
		ewarn "...then downgrade to a legacy[1] branch if possible (not all old versions"
427
		ewarn "are available or fully functional, may need to consider nouveau[2])."
428
		ewarn "[1] https://www.nvidia.com/object/IO_32667.html"
429
		ewarn "[2] https://wiki.gentoo.org/wiki/Nouveau"
430
	fi
431

  
432
	if use wayland && use modules && [[ ! -v NV_HAD_WAYLAND ]]; then
433
		elog
434
		elog "With USE=wayland, this version of ${PN} sets nvidia-drm.modeset=1"
435
		elog "in '${EROOT}/etc/modprobe.d/nvidia.conf'. This feature is considered"
436
		elog "experimental but is required for wayland."
437
		elog
438
		elog "If you experience issues, either disable wayland or edit nvidia.conf."
439
		elog "Of note, may possibly cause issues with SLI and Reverse PRIME."
440
		elog
441
		elog "This version of ${PN} only supports EGLStream which is only"
442
		elog "supported by a few wayland compositors (e.g. kwin / mutter, not sway),"
443
		elog "and is barely tested (X11 is recommended for this legacy branch)."
444
	fi
419 445
}
Спасибо!