4
4
EAPI=8
5
5
6
6
MODULES_OPTIONAL_IUSE=+modules
7
- inherit desktop dot-a eapi9-pipestatus flag-o-matic linux-mod-r1
7
+ inherit desktop dot-a eapi9-pipestatus flag-o-matic linux-mod-r1 multilib
8
8
inherit readme.gentoo-r1 systemd toolchain-funcs unpacker user-info
9
9
10
10
MODULES_KERNEL_MAX=6.15
@@ -24,10 +24,7 @@ S=${WORKDIR}
24
24
25
25
LICENSE=" NVIDIA-2023 Apache-2.0 BSD BSD-2 GPL-2 MIT ZLIB curl openssl"
26
26
SLOT=" 0/${PV%% .* } "
27
- KEYWORDS=" -* amd64 ~arm64"
28
- # TODO: enable kernel-open by default to match nvidia upstream, but should
29
- # first setup a supported-gpus.json "kernelopen" check to abort and avoid bad
30
- # surprises (should abort for legacy cards too, and have a bypass variable)
27
+ KEYWORDS=" -* ~amd64 ~arm64"
31
28
IUSE=" +X abi_x86_32 abi_x86_64 kernel-open persistenced powerd +static-libs +tools wayland"
32
29
REQUIRED_USE=" kernel-open? ( modules )"
33
30
@@ -63,9 +60,9 @@ RDEPEND="
63
60
)
64
61
powerd? ( sys-apps/dbus[abi_x86_32(-)?] )
65
62
wayland? (
66
- >= gui-libs/egl-gbm-1.1.1-r2[abi_x86_32(-)?]
67
- >=gui-libs/egl-wayland-1.1.13.1[abi_x86_32(-)?]
68
- X? ( gui -libs/egl-x11[abi_x86_32(-)?] )
63
+ gui-libs/egl-gbm
64
+ >=gui-libs/egl-wayland-1.1.10
65
+ media -libs/libglvnd
69
66
)
70
67
"
71
68
DEPEND="
@@ -76,7 +73,6 @@ DEPEND="
76
73
x11-libs/libXext
77
74
)
78
75
tools? (
79
- dev-util/vulkan-headers
80
76
media-libs/libglvnd
81
77
sys-apps/dbus
82
78
x11-base/xorg-proto
@@ -94,22 +90,18 @@ BDEPEND="
94
90
QA_PREBUILT=" lib/firmware/* usr/bin/* usr/lib*"
95
91
96
92
PATCHES=(
93
+ " ${FILESDIR} " /nvidia-kernel-module-source-515.86.01-raw-ldflags.patch
97
94
" ${FILESDIR} " /nvidia-modprobe-390.141-uvm-perms.patch
95
+ " ${FILESDIR} " /nvidia-settings-390.144-raw-ldflags.patch
98
96
" ${FILESDIR} " /nvidia-settings-530.30.02-desktop.patch
99
- " ${FILESDIR} " /nvidia-drivers-570.153.02-kernel-6.15.patch
100
97
)
101
98
102
99
pkg_setup () {
103
100
use modules && [[ ${MERGE_TYPE} != binary ]] || return
104
101
105
- # do early before linux-mod-r1 so can use chkconfig to setup CONFIG_CHECK
106
- get_version
107
- require_configured_kernel
108
-
109
102
local CONFIG_CHECK="
110
103
PROC_FS
111
104
~DRM_KMS_HELPER
112
- ~DRM_FBDEV_EMULATION
113
105
~SYSVIPC
114
106
~!LOCKDEP
115
107
~!PREEMPT_RT
@@ -118,29 +110,25 @@ pkg_setup() {
118
110
$( usev powerd ' ~CPU_FREQ' )
119
111
"
120
112
121
- kernel_is -ge 6 11 && linux_chkconfig_present DRM_FBDEV_EMULATION &&
122
- CONFIG_CHECK+=" DRM_TTM_HELPER"
113
+ local ERROR_DRM_KMS_HELPER=" CONFIG_DRM_KMS_HELPER: is not set but needed for Xorg auto-detection
114
+ of drivers (no custom config), and for wayland / nvidia-drm.modeset=1.
115
+ Cannot be directly selected in the kernel's menuconfig, and may need
116
+ selection of a DRM device even if unused, e.g. CONFIG_DRM_AMDGPU=m or
117
+ DRM_I915=y, DRM_NOUVEAU=m also acceptable if a module and not built-in."
118
+
119
+ local ERROR_X86_KERNEL_IBT=" CONFIG_X86_KERNEL_IBT: is set and, if the CPU supports the feature,
120
+ this *could* lead to modules load failure with ENDBR errors, or to
121
+ broken CUDA/NVENC. Please ignore if not having issues, but otherwise
122
+ try to unset or pass ibt=off to the kernel's command line." # 911142
123
+ use kernel-open || CONFIG_CHECK+=" ~!X86_KERNEL_IBT"
123
124
124
125
use amd64 && kernel_is -ge 5 8 && CONFIG_CHECK+=" X86_PAT" # 817764
125
126
126
127
use kernel-open && CONFIG_CHECK+=" MMU_NOTIFIER" # 843827
127
-
128
- local drm_helper_msg=" Cannot be directly selected in the kernel's config menus, and may need
129
- selection of a DRM device even if unused, e.g. CONFIG_DRM_QXL=m or
130
- DRM_AMDGPU=m (among others, consult the kernel config's help), can
131
- also use DRM_NOUVEAU=m as long as built as module *not* built-in."
132
- local ERROR_DRM_KMS_HELPER=" CONFIG_DRM_KMS_HELPER: is not set but needed for Xorg auto-detection
133
- of drivers (no custom config), and for wayland / nvidia-drm.modeset=1.
134
- ${drm_helper_msg} "
135
- local ERROR_DRM_TTM_HELPER=" CONFIG_DRM_TTM_HELPER: is not set but is needed to compile when using
136
- kernel version 6.11.x or newer while DRM_FBDEV_EMULATION is set.
137
- ${drm_helper_msg} "
138
- local ERROR_DRM_FBDEV_EMULATION=" CONFIG_DRM_FBDEV_EMULATION: is not set but is needed for
139
- nvidia-drm.fbdev=1 support, currently off-by-default and it could
140
- be ignored, but note that is due to change in the future."
141
128
local ERROR_MMU_NOTIFIER=" CONFIG_MMU_NOTIFIER: is not set but needed to build with USE=kernel-open.
142
129
Cannot be directly selected in the kernel's menuconfig, and may need
143
130
selection of another option that requires it such as CONFIG_KVM."
131
+
144
132
local ERROR_PREEMPT_RT=" CONFIG_PREEMPT_RT: is set but is unsupported by NVIDIA upstream and
145
133
will fail to build unless the env var IGNORE_PREEMPT_RT_PRESENCE=1 is
146
134
set. Please do not report issues if run into e.g. kernel panics while
@@ -171,16 +159,24 @@ src_prepare() {
171
159
use X || sed -i ' s/"libGLX/"libEGL/' nvidia_{layers,icd}.json || die
172
160
173
161
# enable nvidia-drm.modeset=1 by default with USE=wayland
174
- cp " ${FILESDIR} " /nvidia-570 .conf " ${T} " /nvidia.conf || die
162
+ cp " ${FILESDIR} " /nvidia-470 .conf " ${T} " /nvidia.conf || die
175
163
use ! wayland || sed -i ' /^#.*modeset=1$/s/^#//' " ${T} " /nvidia.conf || die
176
164
177
165
# makefile attempts to install wayland library even if not built
178
166
use wayland || sed -i ' s/ WAYLAND_LIB_install$//' \
179
167
nvidia-settings/src/Makefile || die
168
+
169
+ # temporary option, nvidia will remove in the future
170
+ use ! kernel-open ||
171
+ sed -i ' /blacklist/a\
172
+ \
173
+ # Enable using kernel-open with workstation GPUs (experimental)\
174
+ options nvidia NVreg_OpenRmEnableUnsupportedGpus=1' " ${T} " /nvidia.conf || die
180
175
}
181
176
182
177
src_compile () {
183
178
tc-export AR CC CXX LD OBJCOPY OBJDUMP PKG_CONFIG
179
+ local -x RAW_LDFLAGS=" $( get_abi_LDFLAGS) $( raw-ldflags) " # raw-ldflags.patch
184
180
185
181
# extra flags for the libXNVCtrl.a static library
186
182
local xnvflags=-fPIC # 840389
@@ -200,6 +196,11 @@ src_compile() {
200
196
if use modules; then
201
197
local o_cflags=${CFLAGS} o_cxxflags=${CXXFLAGS} o_ldflags=${LDFLAGS}
202
198
199
+ # conftest.sh is broken with c23 due to func() changing meaning,
200
+ # and then fails later due to ealier misdetections
201
+ # TODO: try without now and then + drop modargs' CC= (bug #944092)
202
+ KERNEL_CC+=" -std=gnu17"
203
+
203
204
local modlistargs=video:kernel
204
205
if use kernel-open; then
205
206
modlistargs+=-module-source:kernel-module-source/kernel-open
@@ -209,12 +210,11 @@ src_compile() {
209
210
filter-flags -fno-plt # 912949
210
211
filter-lto
211
212
CC=${KERNEL_CC} CXX=${KERNEL_CXX} strip-unsupported-flags
212
-
213
- LDFLAGS=$( raw-ldflags)
214
213
fi
215
214
216
215
local modlist=( nvidia{,-drm,-modeset,-peermem,-uvm}=${modlistargs} )
217
216
local modargs=(
217
+ CC=" ${KERNEL_CC} " # needed for above gnu17 workaround
218
218
IGNORE_CC_MISMATCH=yes NV_VERBOSE=1
219
219
SYSOUT=" ${KV_OUT_DIR} " SYSSRC=" ${KV_DIR} "
220
220
@@ -259,7 +259,6 @@ src_install() {
259
259
[GBM_BACKEND_LIB_SYMLINK]=/usr/${libdir} /gbm
260
260
[GLVND_EGL_ICD_JSON]=/usr/share/glvnd/egl_vendor.d
261
261
[OPENGL_DATA]=/usr/share/nvidia
262
- [VULKANSC_ICD_JSON]=/usr/share/vulkansc
263
262
[VULKAN_ICD_JSON]=/usr/share/vulkan
264
263
[WINE_LIB]=/usr/${libdir} /nvidia/wine
265
264
[XORG_OUTPUTCLASS_CONFIG]=/usr/share/X11/xorg.conf.d
@@ -271,12 +270,11 @@ src_install() {
271
270
272
271
local skip_files=(
273
272
$( usev ! X " libGLX_nvidia libglxserver_nvidia" )
273
+ $( usev ! wayland libnvidia-vulkan-producer)
274
274
libGLX_indirect # non-glvnd unused fallback
275
275
libnvidia-{gtk,wayland-client} nvidia-{settings,xconfig} # from source
276
276
libnvidia-egl-gbm 15_nvidia_gbm # gui-libs/egl-gbm
277
277
libnvidia-egl-wayland 10_nvidia_wayland # gui-libs/egl-wayland
278
- libnvidia-egl-xcb 20_nvidia_xcb.json # gui-libs/egl-x11
279
- libnvidia-egl-xlib 20_nvidia_xlib.json # gui-libs/egl-x11
280
278
libnvidia-pkcs11.so # using the openssl3 version instead
281
279
)
282
280
local skip_modules=(
@@ -322,12 +320,6 @@ $(use amd64 && usev !abi_x86_32 "
322
320
Note that without USE=abi_x86_32 on ${PN} , 32bit applications
323
321
(typically using wine / steam) will not be able to use GPU acceleration." )
324
322
325
- Be warned that USE=kernel-open may need to be either enabled or
326
- disabled for certain cards to function:
327
- - GTX 50xx (blackwell) and higher require it to be enabled
328
- - GTX 1650 and higher (pre-blackwell) should work either way
329
- - Older cards require it to be disabled
330
-
331
323
For additional information or for troubleshooting issues, please see
332
324
https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers and NVIDIA's own
333
325
documentation that is installed alongside this README."
@@ -416,9 +408,8 @@ documentation that is installed alongside this README."
416
408
dosym ${m[4]} ${into} /${m[0]}
417
409
continue
418
410
fi
419
- # avoid portage warning due to missing soname links in manifest
420
- [[ ${m[0]} =~ ^libnvidia-ngx.so ]] &&
421
- dosym ${m[0]} ${into} /${m[0]% .so* } .so.1
411
+ [[ ${m[0]} =~ ^libnvidia-ngx.so| ^libnvidia-egl-gbm.so ]] &&
412
+ dosym ${m[0]} ${into} /${m[0]% .so* } .so.1 # soname not in .manifest
422
413
423
414
printf -v m[1] %o $(( m[1 ] | 0200 )) # 444->644
424
415
insopts -m${m[1]}
@@ -432,13 +423,10 @@ documentation that is installed alongside this README."
432
423
exeinto " ${_# " ${EPREFIX} " } "
433
424
doexe systemd/system-sleep/nvidia
434
425
dobin systemd/nvidia-sleep.sh
435
- systemd_dounit systemd/system/nvidia-{hibernate,resume,suspend,suspend-then-hibernate }.service
426
+ systemd_dounit systemd/system/nvidia-{hibernate,resume,suspend}.service
436
427
437
428
dobin nvidia-bug-report.sh
438
429
439
- insinto /usr/share/nvidia/files.d
440
- doins sandboxutils-filelist.json
441
-
442
430
# MODULE:powerd extras
443
431
if use powerd; then
444
432
newinitd " ${FILESDIR} " /nvidia-powerd.initd nvidia-powerd # 923117
@@ -457,8 +445,6 @@ documentation that is installed alongside this README."
457
445
dosym {" ${unitdir} " ,/etc/systemd/system/systemd-hibernate.service.wants}/nvidia-resume.service
458
446
dosym {" ${unitdir} " ,/etc/systemd/system/systemd-suspend.service.wants}/nvidia-suspend.service
459
447
dosym {" ${unitdir} " ,/etc/systemd/system/systemd-suspend.service.wants}/nvidia-resume.service
460
- dosym {" ${unitdir} " ,/etc/systemd/system/systemd-suspend-then-hibernate.service.wants}/nvidia-suspend-then-hibernate.service
461
- dosym {" ${unitdir} " ,/etc/systemd/system/systemd-suspend-then-hibernate.service.wants}/nvidia-resume.service
462
448
# also add a custom elogind hook to do the equivalent of the above
463
449
exeinto /usr/lib/elogind/system-sleep
464
450
newexe " ${FILESDIR} " /system-sleep.elogind nvidia
@@ -489,12 +475,12 @@ documentation that is installed alongside this README."
489
475
# don't attempt to strip firmware files (silences errors)
490
476
dostrip -x ${paths[FIRMWARE]}
491
477
492
- # sandbox issues with /dev/nvidiactl and others ( bug #904292,#921578 )
478
+ # sandbox issues with /dev/nvidiactl ( and /dev/char wrt bug #904292)
493
479
# are widespread and sometime affect revdeps of packages built with
494
480
# USE=opencl/cuda making it hard to manage in ebuilds (minimal set,
495
481
# ebuilds should handle manually if need others or addwrite)
496
482
insinto /etc/sandbox.d
497
- newins - 20nvidia <<< ' SANDBOX_PREDICT="/dev/nvidiactl:/dev/nvidia-caps:/dev/ char"'
483
+ newins - 20nvidia <<< ' SANDBOX_PREDICT="/dev/nvidiactl:/dev/char"'
498
484
499
485
# dracut does not use /etc/modprobe.d if hostonly=no, but want to make sure
500
486
# our settings are used for bug 932781#c8 and nouveau blacklist if either
@@ -506,7 +492,6 @@ documentation that is installed alongside this README."
506
492
}
507
493
508
494
pkg_preinst () {
509
- has_version " ${CATEGORY} /${PN} [kernel-open]" && NV_HAD_KERNEL_OPEN=
510
495
has_version " ${CATEGORY} /${PN} [wayland]" && NV_HAD_WAYLAND=
511
496
512
497
use modules || return
@@ -571,17 +556,20 @@ pkg_postinst() {
571
556
ewarn " [2] https://wiki.gentoo.org/wiki/Nouveau"
572
557
fi
573
558
574
- if use kernel-open && [[ ! -v NV_HAD_KERNEL_OPEN ]] ; then
559
+ if use kernel-open; then
575
560
ewarn
576
- ewarn " Open source variant of ${PN} was selected, note that it requires "
577
- ewarn " Turing/Ampere+ GPUs (aka GTX 1650+). Try disabling if run into issues."
578
- ewarn " Also see: ${EROOT} /usr/share/doc/${PF} /html/kernel_open.html"
561
+ ewarn " Open source variant of ${PN} was selected, be warned it is experimental "
562
+ ewarn " and only for modern GPUs (e.g. GTX 1650+). Try to disable if run into issues."
563
+ ewarn " Please also see: ${EROOT} /usr/share/doc/${PF} /html/kernel_open.html"
579
564
fi
580
565
581
566
if use wayland && use modules && [[ ! -v NV_HAD_WAYLAND ]]; then
582
567
elog
583
- elog " Note that with USE=wayland, nvidia-drm.modeset=1 will be enabled"
584
- elog " in '${EROOT} /etc/modprobe.d/nvidia.conf'. *If* experience issues,"
585
- elog " either disable wayland or edit nvidia.conf."
568
+ elog " With USE=wayland, this version of ${PN} sets nvidia-drm.modeset=1"
569
+ elog " in '${EROOT} /etc/modprobe.d/nvidia.conf'. This feature is considered"
570
+ elog " experimental but is required for wayland."
571
+ elog
572
+ elog " If you experience issues, either disable wayland or edit nvidia.conf."
573
+ elog " Of note, may possibly cause issues with SLI and Reverse PRIME."
586
574
fi
587
575
}
0 commit comments