diff options
Diffstat (limited to 'x11-drivers')
19 files changed, 1510 insertions, 777 deletions
diff --git a/x11-drivers/nvidia-drivers/Manifest b/x11-drivers/nvidia-drivers/Manifest index 33271e77..db739604 100644 --- a/x11-drivers/nvidia-drivers/Manifest +++ b/x11-drivers/nvidia-drivers/Manifest @@ -1,3 +1,15 @@ DIST NVIDIA-Linux-x86_64-390.157.run 85835541 BLAKE2B 44b855cd11f3b2f231f9fb90492ae2e67a67ea3ea83c413e7c90956d38c9730a8bd0321281ae03c6afce633d102f5b499aed25622b9bfd31bdd2c98f0717e95b SHA512 4780503a4cff0180b1b1f37d20a6ba3438dd78b51fa7f69b98d35521835e5d61099129746929d51d63afa2d47b672b3e145e1e1897584dc3799e7f822c5b3a0a -DIST NVIDIA-Linux-x86_64-470.239.06.run 272849102 BLAKE2B 556c8f7058b83d8c4c7ccb2f62619ac001f7c3868b80ee091e2949fb7b35e136fec83c15efcf4dd4c99d312f8c36f83c76e250d18d091e053355396b8347af11 SHA512 92bdfb11db405071cd58deed2a0853448932657e256258e0a0bda5069f00485e2b6e49b4a0eeff499a4991be4f884273f3564c164110b1ed1f5d924506f13e2d -DIST NVIDIA-Linux-x86_64-535.171.04.run 341705434 BLAKE2B 2d5dc19e8f80710a3a4324555ccabbf262552ebd71454a60541d9a726ace74697f37d112f8c38999bd5eb577dbf96cbd8c6c835a17c72140ad8deb96036a8a0a SHA512 5db0f8bedb0667d08beb56592cb1f1d3510906dd9b931899dabac289a73f26ff35d68ede8523af4e3226421fb5c18b86106c8f1cb4ad635a53cd037c46e8762f +DIST NVIDIA-Linux-x86_64-470.256.02.run 272850014 BLAKE2B 0fdc867f92b82b2a60810c3b43751cad7ac2c39928c92c6c343c0c6044f4d7d923d93b8599db3f7c999c0ee7d16940e65d991a61cbb30e1d9e49c5639ac6bdc8 SHA512 a837946dd24d7945c1962a695f1f31965f3ceb6927f52cd08fd51b8db138b7a888bbeab69243f5c8468a7bd7ccd47f5dbdb48a1ca81264866c1ebb7d88628f88 +DIST NVIDIA-Linux-x86_64-550.127.05.run 307139930 BLAKE2B 6c6bfbc4383a3a9b61e73a4bc54062d29f6cc48b209263f772bca64301f04a2f692a55f6f493762a0770d88873f8231e29c6b73d3d68263624c7daf304008afe SHA512 b67364c0911aa4908192846ed855571312c9e29c47cae8c83300caf71a9c8c7277f2a0591f0c0dd669f34464e04cf420a16ec83f5db4875a32c00a678db80d06 +DIST nvidia-installer-390.157.tar.bz2 150323 BLAKE2B 8058ca87a6dea956d564af9f7eab9b1fc82b1f2382bd5cb2f6d97cbe2e19292533522d5f8f2eacbeb16520372715fcb72f8f9b0998962af5d4e75522c8d74524 SHA512 93a7ece648602157496c8e27a88864ede341a100f5328a4c1a25faf8f0b94d252060e5e2f71d0c302fd0566c10773c30b76b3b5f431d8039b71c90a7969f7d7e +DIST nvidia-installer-470.256.02.tar.bz2 146269 BLAKE2B 4402e725c8fd0157eb84d4ec140a33f97e873014577487ef1e32fb8921cabe79c60ff46532e5bfaabb2b6ac894f7c80086dbab19e61906e2e27346fb85f98829 SHA512 c962dc17d9696256d1ebedcaeb3010994f2ce3895aedc47987599ebfec132a9b9a249d2ece6502b15bd4a93f9b0106aa13487a7da5f64199c274ce11eba27cfd +DIST nvidia-installer-550.127.05.tar.bz2 155613 BLAKE2B 6731d9d70b436202d1c92c026cef46bf03ed025b3032583b27e5eeb98440285516b6a097fe41a18ffb44a63260c4450db2fe419c758ded4f9e90a30cf95cd27a SHA512 e0a271365df8a4f1c0ff7116b5353ec407d305d1783a9834b0cbaa935e75d3b3960ef595c9ef24ad6c8b936fcff5dd43fcace102a0fb0e2cd7d844ada6c44aaa +DIST nvidia-modprobe-390.157.tar.bz2 35306 BLAKE2B 80d202b39c2f95ec0f909712c2e101483af50124092c32efb33bd98ff58ddfb97b737ff07f1ddc941f688c1b4c26a15f392566d522e18506771f10422fcd571c SHA512 109bbe24a3758b568ea65fe1e9d78f69fae6108ec0497b796c885a3912825fe04ffd7389a3e22987f1a10a2926bf6eaa384faabc59478aa3ee244dd3ac91c6d3 +DIST nvidia-modprobe-470.256.02.tar.bz2 38769 BLAKE2B 0db444b09b0b6d24c04877fae95249e781d82b3141f90eb05d869b64d2b6e65ad00bf44c4e427c64dbd4765fa99a8699f80a1d95b00c66137a54dc878d7ea298 SHA512 c1cbfa6c8e188e5a5eb5d390b9a903406cbff103d212fc30e611e4023be3fde896ad84e8bb45b030beb5d1bcd8155c9e55a8f9636c45ce1e2a5c03f672989a31 +DIST nvidia-modprobe-550.127.05.tar.bz2 41498 BLAKE2B 387945fe05f244350ec2982b6a723ba34ed8c726865ed95c2a33702233db3eb6e1937673f3eee72632bb0db6de6cc6c0dbc07abe909491187e8da6ebd2582840 SHA512 c229d3018589d9f52f17baa4d8eee966a198051058019f577d0455b67d0189c586b8ed64273859e4cf7d4a37cd6f6fb21aa53a8e2fe4cd926de34106e87bae6a +DIST nvidia-persistenced-390.157.tar.bz2 48654 BLAKE2B 2cf6c92da90acff55e8c180a06b0c6a29d48be9fd8ca3c541202fd14f0697220fba6b66452942aa7ae7cc8821f5c5eb9fa8f7a31d2248624e5f9141d83a176b8 SHA512 70f0707ed6f2b877e69ef90cf782f66cbc9d2071db53ca09ceb7b89427b0fe176708517340621fa251539b7d481b238adeeb60261674eed74de1f62db6dbb72e +DIST nvidia-persistenced-470.256.02.tar.bz2 46567 BLAKE2B 8f837322a3b88412fd2f6acf38721b49a6cb444fbd842d652519e5596f2e545d8f06bbdf017f46a22301ce87455f96147fab2829ca5fbf26131ec3e4a772e282 SHA512 4fd19258649b7d39945fb5c8578bf11ab118617dd14f3d11cdf15cb3fe77daf7b4719e4ae57af59031b1b809d02f4e8e8afed0ec60b9d0aed4d2488bd3013cd9 +DIST nvidia-persistenced-550.127.05.tar.bz2 61307 BLAKE2B 5e6f8d6734062b45782b71ebc8a3d17eb9cd56bef532f89ba27e4828c3f51b1c3ad94323f3e8d331cfa9b225f406f58d13ac36dc0976f0a7de955a35fd3acb38 SHA512 00d1a0436afdc9c3abe3abd68f29cec20c4ef38e8f96b8b36bd5428636ad085b42109591438b4d3a776f1f9b6efdef0e97dc964bd0e2b95c740b50d821e9311d +DIST nvidia-xconfig-390.157.tar.bz2 107399 BLAKE2B 0cbb3b1ba508ddc3ba4a161c290b31bf7a67f67880bdbd01171a962c5fa97ca945b1ef17932403f8589309380743f1da632c728d8accb6d4e56dbd895e7486bb SHA512 50b390811c9bf091b14add41f886925b17496b41006b7d3981d2398caa65cf5db8a579c8cebed78278384bf3acc629befb07b54339c61abcc75852c0dcb8b8ca +DIST nvidia-xconfig-470.256.02.tar.bz2 108698 BLAKE2B e468574e4bc57e7279d4120e2b08a201671b50d408be0c530eabe5da7d45daaf21cbf5c7fa31410d0d732fe8ea1551cbfb21d1ae193c1b3f5b5c50c764c9e236 SHA512 9dcec1e0c2b56b4d38a5f2c76086302f8bc0860cc15012cce29c3a5062f801a48b6a2bb78344361b07a2717b58502783441a2daf402d9973a17526175b1f15ca +DIST nvidia-xconfig-550.127.05.tar.bz2 111217 BLAKE2B a687e3e1d9e77cb5153a9732beade8c007d11fdada22cdd0a9debe464d9ac5125b435c95565f66c8cf895a9656e66ae37384b11a43e2f0785daf509746b57d62 SHA512 ff1a151663621320c32df1593c13e70d17d06f9d9633ea6c57463c0dd73873f8afc73676c393fdca82d7aa5085000e6b3af420228712e4c226b7b24220c454ec diff --git a/x11-drivers/nvidia-drivers/files/nouveau.conf b/x11-drivers/nvidia-drivers/files/nouveau.conf deleted file mode 100644 index 00c6f588..00000000 --- a/x11-drivers/nvidia-drivers/files/nouveau.conf +++ /dev/null @@ -1,3 +0,0 @@ -blacklist nouveau -options nouveau modeset=0 -alias nouveau off diff --git a/x11-drivers/nvidia-drivers/files/nvidia-390.conf b/x11-drivers/nvidia-drivers/files/nvidia-390.conf new file mode 100644 index 00000000..6cfc0e6a --- /dev/null +++ b/x11-drivers/nvidia-drivers/files/nvidia-390.conf @@ -0,0 +1,23 @@ +# NVIDIA drivers options +# See /usr/share/doc/nvidia-drivers-*/README.txt* for more information. + +# nvidia-drivers and nouveau cannot be used at same time. +# Comment out the following line if you wish to allow nouveau. +blacklist nouveau +options nouveau modeset=0 +alias nouveau off + +# !!! Security Warning !!! +# Do not change the DeviceFile options unless you know what you are doing. +# Only add trusted users to the 'video' group, these users may be able to +# crash, compromise, or irreparably damage the machine. +options nvidia \ + NVreg_DeviceFileGID=@VIDEOGID@ \ + NVreg_DeviceFileMode=432 \ + NVreg_DeviceFileUID=0 \ + NVreg_ModifyDeviceFiles=1 + +# Should be no need to touch anything below. +alias char-major-195 nvidia +alias /dev/nvidiactl char-major-195 +remove nvidia modprobe -r --ignore-remove nvidia-drm nvidia-modeset nvidia-uvm nvidia diff --git a/x11-drivers/nvidia-drivers/files/nvidia-470.conf b/x11-drivers/nvidia-drivers/files/nvidia-470.conf new file mode 100644 index 00000000..1ba489dd --- /dev/null +++ b/x11-drivers/nvidia-drivers/files/nvidia-470.conf @@ -0,0 +1,35 @@ +# NVIDIA drivers options +# See /usr/share/doc/nvidia-drivers-*/README.txt* for more information. + +# nvidia-drivers and nouveau cannot be used at same time. +# Comment out the following line if you wish to allow nouveau. +blacklist nouveau +options nouveau modeset=0 +alias nouveau off + +# Kernel Mode Setting (needed for wayland but is hardly usable with legacy 470) +# Enabling may possibly cause issues with SLI and Reverse PRIME. +#options nvidia-drm modeset=1 + +# Suspend options. Note that Allocations=1 requires suspend hooks currently +# only used when either systemd or elogind is used to suspend. If using +# neither or have issues, try Allocations=0 (revert if it does not help +# as =0 is not recommended). +options nvidia \ + NVreg_PreserveVideoMemoryAllocations=1 \ + NVreg_TemporaryFilePath=/var/tmp + +# !!! Security Warning !!! +# Do not change the DeviceFile options unless you know what you are doing. +# Only add trusted users to the 'video' group, these users may be able to +# crash, compromise, or irreparably damage the machine. +options nvidia \ + NVreg_DeviceFileGID=@VIDEOGID@ \ + NVreg_DeviceFileMode=432 \ + NVreg_DeviceFileUID=0 \ + NVreg_ModifyDeviceFiles=1 + +# Should be no need to touch anything below. +alias char-major-195 nvidia +alias /dev/nvidiactl char-major-195 +remove nvidia modprobe -r --ignore-remove nvidia-drm nvidia-modeset nvidia-uvm nvidia diff --git a/x11-drivers/nvidia-drivers/files/nvidia-545.conf b/x11-drivers/nvidia-drivers/files/nvidia-545.conf new file mode 100644 index 00000000..e8ca7805 --- /dev/null +++ b/x11-drivers/nvidia-drivers/files/nvidia-545.conf @@ -0,0 +1,40 @@ +# NVIDIA drivers options +# See /usr/share/doc/nvidia-drivers-*/README.txt* for more information. + +# nvidia-drivers and nouveau cannot be used at same time. +# Comment out the following line if you wish to allow nouveau. +blacklist nouveau +options nouveau modeset=0 +alias nouveau off + +# Kernel Mode Setting (notably needed for fbdev and wayland). +# Enabling may possibly cause issues with SLI and Reverse PRIME. +#options nvidia-drm modeset=1 + +# Enable experimental framebuffer console support (requires modeset=1 above). +# Replaces efifb, simpledrm, or similar once loaded (emphasis on being +# experimental, "may" cause issues X mode switching, sleep, or more). +#options nvidia-drm fbdev=1 + +# Suspend options. Note that Allocations=1 requires suspend hooks currently +# only used when either systemd or elogind is used to suspend. If using +# neither or have issues, try Allocations=0 (revert if it does not help +# as =0 is not recommended). +options nvidia \ + NVreg_PreserveVideoMemoryAllocations=1 \ + NVreg_TemporaryFilePath=/var/tmp + +# !!! Security Warning !!! +# Do not change the DeviceFile options unless you know what you are doing. +# Only add trusted users to the 'video' group, these users may be able to +# crash, compromise, or irreparably damage the machine. +options nvidia \ + NVreg_DeviceFileGID=@VIDEOGID@ \ + NVreg_DeviceFileMode=432 \ + NVreg_DeviceFileUID=0 \ + NVreg_ModifyDeviceFiles=1 + +# Should be no need to touch anything below. +alias char-major-195 nvidia +alias /dev/nvidiactl char-major-195 +remove nvidia modprobe -r --ignore-remove nvidia-drm nvidia-modeset nvidia-uvm nvidia diff --git a/x11-drivers/nvidia-drivers/files/nvidia-drivers-390.154-clang15.patch b/x11-drivers/nvidia-drivers/files/nvidia-drivers-390.154-clang15.patch new file mode 100644 index 00000000..b08f3589 --- /dev/null +++ b/x11-drivers/nvidia-drivers/files/nvidia-drivers-390.154-clang15.patch @@ -0,0 +1,84 @@ +Kernel's makefiles pass -Werror=strict-prototypes which +can trigger errors depending on compiler defaults. +https://bugs.gentoo.org/870238 +https://github.com/NVIDIA/open-gpu-kernel-modules/issues/377 +--- a/kernel/nvidia/nvlink_linux.c ++++ b/kernel/nvidia/nvlink_linux.c +@@ -639 +639 @@ +-void * NVLINK_API_CALL nvlink_allocLock() ++void * NVLINK_API_CALL nvlink_allocLock(void) +--- a/kernel/nvidia/os-interface.c ++++ b/kernel/nvidia/os-interface.c +@@ -879 +879 @@ +-NV_STATUS NV_API_CALL os_flush_cpu_cache() ++NV_STATUS NV_API_CALL os_flush_cpu_cache(void) +@@ -886 +886 @@ +-NV_STATUS NV_API_CALL os_flush_cpu_cache_all() ++NV_STATUS NV_API_CALL os_flush_cpu_cache_all(void) +@@ -944 +944 @@ +-void NV_API_CALL os_flush_cpu_write_combine_buffer() ++void NV_API_CALL os_flush_cpu_write_combine_buffer(void) +@@ -1073 +1073 @@ +-NvU32 NV_API_CALL os_get_cpu_number() ++NvU32 NV_API_CALL os_get_cpu_number(void) +@@ -1080 +1080 @@ +-NvU32 NV_API_CALL os_get_cpu_count() ++NvU32 NV_API_CALL os_get_cpu_count(void) +@@ -1155 +1155 @@ +-void NV_API_CALL os_dump_stack() ++void NV_API_CALL os_dump_stack(void) +--- a/kernel/nvidia-uvm/uvm8_lock.c ++++ b/kernel/nvidia-uvm/uvm8_lock.c +@@ -312 +312 @@ +-bool __uvm_thread_check_all_unlocked() ++bool __uvm_thread_check_all_unlocked(void) +--- a/kernel/nvidia-uvm/uvm8_perf_heuristics.c ++++ b/kernel/nvidia-uvm/uvm8_perf_heuristics.c +@@ -29 +29 @@ +-NV_STATUS uvm_perf_heuristics_init() ++NV_STATUS uvm_perf_heuristics_init(void) +@@ -44 +44 @@ +-void uvm_perf_heuristics_exit() ++void uvm_perf_heuristics_exit(void) +--- a/kernel/nvidia-uvm/uvm8_perf_prefetch.c ++++ b/kernel/nvidia-uvm/uvm8_perf_prefetch.c +@@ -462 +462 @@ +-NV_STATUS uvm_perf_prefetch_init() ++NV_STATUS uvm_perf_prefetch_init(void) +@@ -500 +500 @@ +-void uvm_perf_prefetch_exit() ++void uvm_perf_prefetch_exit(void) +--- a/kernel/nvidia-uvm/uvm8_perf_thrashing.c ++++ b/kernel/nvidia-uvm/uvm8_perf_thrashing.c +@@ -1324 +1324 @@ +-NV_STATUS uvm_perf_thrashing_init() ++NV_STATUS uvm_perf_thrashing_init(void) +@@ -1401 +1401 @@ +-void uvm_perf_thrashing_exit() ++void uvm_perf_thrashing_exit(void) +--- a/kernel/nvidia-uvm/uvm8_procfs.c ++++ b/kernel/nvidia-uvm/uvm8_procfs.c +@@ -61 +61 @@ +-NV_STATUS uvm_procfs_init() ++NV_STATUS uvm_procfs_init(void) +@@ -77 +77 @@ +-void uvm_procfs_exit() ++void uvm_procfs_exit(void) +@@ -106 +106 @@ +-struct proc_dir_entry *uvm_procfs_get_gpu_base_dir() ++struct proc_dir_entry *uvm_procfs_get_gpu_base_dir(void) +--- a/kernel/nvidia-uvm/uvm8_push.c ++++ b/kernel/nvidia-uvm/uvm8_push.c +@@ -103 +103 @@ +-bool uvm_push_info_is_tracking_descriptions() ++bool uvm_push_info_is_tracking_descriptions(void) +--- a/kernel/nvidia-uvm/uvm8_tools.c ++++ b/kernel/nvidia-uvm/uvm8_tools.c +@@ -2041 +2041 @@ +-void uvm_tools_flush_events() ++void uvm_tools_flush_events(void) +--- a/kernel/nvidia-uvm/uvm_common.c ++++ b/kernel/nvidia-uvm/uvm_common.c +@@ -63 +63 @@ +-bool uvm_debug_prints_enabled() ++bool uvm_debug_prints_enabled(void) diff --git a/x11-drivers/nvidia-drivers/files/nvidia-drivers-470.141.03-clang15.patch b/x11-drivers/nvidia-drivers/files/nvidia-drivers-470.141.03-clang15.patch new file mode 100644 index 00000000..334f0d1c --- /dev/null +++ b/x11-drivers/nvidia-drivers/files/nvidia-drivers-470.141.03-clang15.patch @@ -0,0 +1,110 @@ +Kernel's makefiles pass -Werror=strict-prototypes which +can trigger errors depending on compiler defaults. +https://bugs.gentoo.org/870238 +https://github.com/NVIDIA/open-gpu-kernel-modules/issues/377 +--- a/kernel/nvidia/nvlink_linux.c ++++ b/kernel/nvidia/nvlink_linux.c +@@ -571 +571 @@ +-void * nvlink_allocLock() ++void * nvlink_allocLock(void) +--- a/kernel/nvidia/os-interface.c ++++ b/kernel/nvidia/os-interface.c +@@ -1076 +1076 @@ +-NvU32 NV_API_CALL os_get_cpu_number() ++NvU32 NV_API_CALL os_get_cpu_number(void) +@@ -1083 +1083 @@ +-NvU32 NV_API_CALL os_get_cpu_count() ++NvU32 NV_API_CALL os_get_cpu_count(void) +@@ -1136 +1136 @@ +-void NV_API_CALL os_dump_stack() ++void NV_API_CALL os_dump_stack(void) +--- a/kernel/nvidia-uvm/uvm_common.c ++++ b/kernel/nvidia-uvm/uvm_common.c +@@ -37 +37 @@ +-bool uvm_debug_prints_enabled() ++bool uvm_debug_prints_enabled(void) +--- a/kernel/nvidia-uvm/uvm_gpu_access_counters.c ++++ b/kernel/nvidia-uvm/uvm_gpu_access_counters.c +@@ -1527 +1527 @@ +-NV_STATUS uvm_perf_access_counters_init() ++NV_STATUS uvm_perf_access_counters_init(void) +@@ -1538 +1538 @@ +-void uvm_perf_access_counters_exit() ++void uvm_perf_access_counters_exit(void) +--- a/kernel/nvidia-uvm/uvm_lock.c ++++ b/kernel/nvidia-uvm/uvm_lock.c +@@ -337 +337 @@ +-bool __uvm_thread_check_all_unlocked() ++bool __uvm_thread_check_all_unlocked(void) +--- a/kernel/nvidia-uvm/uvm_migrate.c ++++ b/kernel/nvidia-uvm/uvm_migrate.c +@@ -795 +795 @@ +-NV_STATUS uvm_migrate_init() ++NV_STATUS uvm_migrate_init(void) +@@ -821 +821 @@ +-void uvm_migrate_exit() ++void uvm_migrate_exit(void) +--- a/kernel/nvidia-uvm/uvm_migrate_pageable.c ++++ b/kernel/nvidia-uvm/uvm_migrate_pageable.c +@@ -979 +979 @@ +-NV_STATUS uvm_migrate_pageable_init() ++NV_STATUS uvm_migrate_pageable_init(void) +@@ -988 +988 @@ +-void uvm_migrate_pageable_exit() ++void uvm_migrate_pageable_exit(void) +--- a/kernel/nvidia-uvm/uvm_perf_heuristics.c ++++ b/kernel/nvidia-uvm/uvm_perf_heuristics.c +@@ -31 +31 @@ +-NV_STATUS uvm_perf_heuristics_init() ++NV_STATUS uvm_perf_heuristics_init(void) +@@ -50 +50 @@ +-void uvm_perf_heuristics_exit() ++void uvm_perf_heuristics_exit(void) +--- a/kernel/nvidia-uvm/uvm_perf_prefetch.c ++++ b/kernel/nvidia-uvm/uvm_perf_prefetch.c +@@ -463 +463 @@ +-NV_STATUS uvm_perf_prefetch_init() ++NV_STATUS uvm_perf_prefetch_init(void) +@@ -501 +501 @@ +-void uvm_perf_prefetch_exit() ++void uvm_perf_prefetch_exit(void) +--- a/kernel/nvidia-uvm/uvm_perf_thrashing.c ++++ b/kernel/nvidia-uvm/uvm_perf_thrashing.c +@@ -1955 +1955 @@ +-NV_STATUS uvm_perf_thrashing_init() ++NV_STATUS uvm_perf_thrashing_init(void) +@@ -2014 +2014 @@ +-void uvm_perf_thrashing_exit() ++void uvm_perf_thrashing_exit(void) +--- a/kernel/nvidia-uvm/uvm_procfs.c ++++ b/kernel/nvidia-uvm/uvm_procfs.c +@@ -49 +49 @@ +-NV_STATUS uvm_procfs_init() ++NV_STATUS uvm_procfs_init(void) +@@ -69 +69 @@ +-void uvm_procfs_exit() ++void uvm_procfs_exit(void) +@@ -98 +98 @@ +-struct proc_dir_entry *uvm_procfs_get_gpu_base_dir() ++struct proc_dir_entry *uvm_procfs_get_gpu_base_dir(void) +@@ -103 +103 @@ +-struct proc_dir_entry *uvm_procfs_get_cpu_base_dir() ++struct proc_dir_entry *uvm_procfs_get_cpu_base_dir(void) +--- a/kernel/nvidia-uvm/uvm_push.c ++++ b/kernel/nvidia-uvm/uvm_push.c +@@ -245 +245 @@ +-bool uvm_push_info_is_tracking_descriptions() ++bool uvm_push_info_is_tracking_descriptions(void) +@@ -250 +250 @@ +-bool uvm_push_info_is_tracking_acquires() ++bool uvm_push_info_is_tracking_acquires(void) +--- a/kernel/nvidia-uvm/uvm_thread_context.c ++++ b/kernel/nvidia-uvm/uvm_thread_context.c +@@ -104 +104 @@ +-bool uvm_thread_context_wrapper_is_used() ++bool uvm_thread_context_wrapper_is_used(void) +--- a/kernel/nvidia-uvm/uvm_tools.c ++++ b/kernel/nvidia-uvm/uvm_tools.c +@@ -2144 +2144 @@ +-void uvm_tools_flush_events() ++void uvm_tools_flush_events(void) diff --git a/x11-drivers/nvidia-drivers/files/nvidia-drm-outputclass-390.conf b/x11-drivers/nvidia-drivers/files/nvidia-drm-outputclass-390.conf new file mode 100644 index 00000000..f459c69d --- /dev/null +++ b/x11-drivers/nvidia-drivers/files/nvidia-drm-outputclass-390.conf @@ -0,0 +1,7 @@ +Section "OutputClass" + Identifier "nvidia" + MatchDriver "nvidia-drm" + Driver "nvidia" + Option "AllowEmptyInitialConfiguration" + ModulePath "@LIBDIR@/extensions/nvidia" +EndSection diff --git a/x11-drivers/nvidia-drivers/files/nvidia-modprobe-390.141-uvm-perms.patch b/x11-drivers/nvidia-drivers/files/nvidia-modprobe-390.141-uvm-perms.patch new file mode 100644 index 00000000..6ffd42ff --- /dev/null +++ b/x11-drivers/nvidia-drivers/files/nvidia-modprobe-390.141-uvm-perms.patch @@ -0,0 +1,12 @@ +Create /dev/nvidia-uvm* by respecting nvidia.conf's permissions. +--- a/nvidia-modprobe/modprobe-utils/nvidia-modprobe-utils.c ++++ b/nvidia-modprobe/modprobe-utils/nvidia-modprobe-utils.c +@@ -742,6 +742,6 @@ + } + +- return mknod_helper(major, base_minor, NV_UVM_DEVICE_NAME, NULL) && +- mknod_helper(major, base_minor + 1, NV_UVM_TOOLS_DEVICE_NAME, NULL); ++ return mknod_helper(major, base_minor, NV_UVM_DEVICE_NAME, NV_PROC_REGISTRY_PATH) && ++ mknod_helper(major, base_minor + 1, NV_UVM_TOOLS_DEVICE_NAME, NV_PROC_REGISTRY_PATH); + } + diff --git a/x11-drivers/nvidia-drivers/files/nvidia-persistenced.confd b/x11-drivers/nvidia-drivers/files/nvidia-persistenced.confd new file mode 100644 index 00000000..e06d53c0 --- /dev/null +++ b/x11-drivers/nvidia-drivers/files/nvidia-persistenced.confd @@ -0,0 +1,7 @@ +# configuration file for /etc/init.d/nvidia-persistenced + +# NVPD_USER: user to run as, needs access to /dev/nvidia* (video group) +NVPD_USER="nvpd" + +# ARGS: additional arguments, see nvidia-persistenced(1) +ARGS="" diff --git a/x11-drivers/nvidia-drivers/files/nvidia-persistenced.initd b/x11-drivers/nvidia-drivers/files/nvidia-persistenced.initd new file mode 100644 index 00000000..27d8bb37 --- /dev/null +++ b/x11-drivers/nvidia-drivers/files/nvidia-persistenced.initd @@ -0,0 +1,11 @@ +#!/sbin/openrc-run +# SPDX-License-Identifier: MIT + +description="Maintain persistent software state in the NVIDIA driver" +command="nvidia-persistenced" +command_args="${NVPD_USER:+--user ${NVPD_USER}} ${ARGS}" +pidfile="/var/run/nvidia-persistenced/nvidia-persistenced.pid" + +stop_post() { + rmdir "${pidfile%/*}" 2>/dev/null || true +} diff --git a/x11-drivers/nvidia-drivers/files/nvidia-powerd.initd b/x11-drivers/nvidia-drivers/files/nvidia-powerd.initd new file mode 100644 index 00000000..5132a20c --- /dev/null +++ b/x11-drivers/nvidia-drivers/files/nvidia-powerd.initd @@ -0,0 +1,11 @@ +#!/sbin/openrc-run +# SPDX-License-Identifier: MIT + +description="Support for NVIDIA Dynamic Boost (only for use with specific laptops)" +command="nvidia-powerd" +command_background=true +pidfile="/var/run/nvidia-powerd.pid" + +depend() { + need dbus +} diff --git a/x11-drivers/nvidia-drivers/files/system-sleep.elogind b/x11-drivers/nvidia-drivers/files/system-sleep.elogind new file mode 100644 index 00000000..d36e2697 --- /dev/null +++ b/x11-drivers/nvidia-drivers/files/system-sleep.elogind @@ -0,0 +1,7 @@ +#!/bin/sh +case ${1-} in + pre) nvidia-sleep.sh suspend;; + # run in background given resume is flaky if elogind did not finish + post) nvidia-sleep.sh resume &;; + *) exit 1;; +esac diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-390.157-r11.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-390.157-r11.ebuild new file mode 100644 index 00000000..be15e1fb --- /dev/null +++ b/x11-drivers/nvidia-drivers/nvidia-drivers-390.157-r11.ebuild @@ -0,0 +1,355 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit desktop flag-o-matic multilib readme.gentoo-r1 +inherit systemd toolchain-funcs unpacker user-info + +NV_URI="https://download.nvidia.com/XFree86/" + +DESCRIPTION="NVIDIA Accelerated Graphics Driver" +HOMEPAGE="https://www.nvidia.com/download/index.aspx" +SRC_URI=" + ${NV_URI}Linux-x86_64/${PV}/NVIDIA-Linux-x86_64-${PV}.run + $(printf "${NV_URI}%s/%s-${PV}.tar.bz2 " \ + nvidia-{installer,modprobe,persistenced,xconfig}{,}) +" +# nvidia-installer is unused but here for GPL-2's "distribute sources" +S=${WORKDIR} + +LICENSE="NVIDIA-r2 BSD BSD-2 GPL-2 MIT" +SLOT="3" +KEYWORDS="-* amd64" +IUSE="abi_x86_32 abi_x86_64 +acpi +dkms +persistenced +tools +X" +RESTRICT="strip" + +COMMON_DEPEND=" + acct-group/video + persistenced? ( + acct-user/nvpd + net-libs/libtirpc:= + ) +" +RDEPEND=" + ${COMMON_DEPEND} + sys-libs/glibc + !!x11-drivers/nvidia-drivers:4 + !!x11-drivers/nvidia-drivers:5 + acpi? ( sys-power/acpid ) + dkms? ( ~sys-kernel/${PN}-dkms-${PV}:${SLOT} ) + X? ( + media-libs/libglvnd[X,abi_x86_32(-)?] + x11-libs/libX11[abi_x86_32(-)?] + x11-libs/libXext[abi_x86_32(-)?] + ) +" +DEPEND=" + ${COMMON_DEPEND} + x11-base/xorg-proto + x11-libs/libX11 + x11-libs/libXext +" +BDEPEND=" + sys-devel/m4 + virtual/pkgconfig +" +PDEPEND=" + tools? ( x11-misc/nvidia-settings:${SLOT} ) +" + +QA_PREBUILT="opt/bin/* usr/lib*" + +PATCHES=( + # note: no plans to add patches for newer kernels here, when the last + # working 6.1.x LTS is EOL then 390 will simply be removed from the tree + "${FILESDIR}"/nvidia-modprobe-390.141-uvm-perms.patch +) + +pkg_setup() { + local CONFIG_CHECK=" + PROC_FS + ~DRM_KMS_HELPER + ~SYSVIPC + ~!AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT + ~!LOCKDEP + ~!X86_KERNEL_IBT + !DEBUG_MUTEXES + " + + local ERROR_DRM_KMS_HELPER="CONFIG_DRM_KMS_HELPER: is not set but needed for Xorg auto-detection + of drivers (no custom config), and optional nvidia-drm.modeset=1. + With 390.xx drivers, also used by a GLX workaround needed for OpenGL. + Cannot be directly selected in the kernel's menuconfig, and may need + selection of a DRM device even if unused, e.g. CONFIG_DRM_AMDGPU=m or + DRM_I915=y, DRM_NOUVEAU=m also acceptable if a module and not built-in." + + local ERROR_X86_KERNEL_IBT="CONFIG_X86_KERNEL_IBT: is set and, if the CPU supports the feature, + this will likely lead to modules load failure with ENDBR errors. + Please ignore if not having issues, but otherwise try to unset or + pass ibt=off to the kernel's command line." #911142 + + CONFIG_CHECK+=" X86_PAT" #817764 +} + +src_prepare() { + # make patches usable across versions + rm nvidia-modprobe && mv nvidia-modprobe{-${PV},} || die + rm nvidia-persistenced && mv nvidia-persistenced{-${PV},} || die + rm nvidia-xconfig && mv nvidia-xconfig{-${PV},} || die + + eapply "${FILESDIR}"/nvidia-drivers-390.154-clang15.patch + + default + + # prevent detection of incomplete kernel DRM support (bug #603818) + sed 's/defined(CONFIG_DRM/defined(CONFIG_DRM_KMS_HELPER/g' \ + -i kernel/conftest.sh || die + + sed 's/__USER__/nvpd/' \ + nvidia-persistenced/init/systemd/nvidia-persistenced.service.template \ + > "${T}"/nvidia-persistenced.service || die + + # use alternative vulkan icd option if USE=-X (bug #909181) + sed "s/__NV_VK_ICD__/lib$(usex X GLX EGL)_nvidia.so.0/" \ + nvidia_icd.json.template > nvidia_icd.json || die + + # 390 has legacy glx needing a modified .conf (bug #713546) + # directory is not quite right, but kept for any existing custom xorg.conf + sed "s|@LIBDIR@|${EPREFIX}/usr/$(get_libdir)|" \ + "${FILESDIR}"/nvidia-drm-outputclass-390.conf > nvidia-drm-outputclass.conf || die +} + +src_compile() { + tc-export AR CC CXX LD OBJCOPY OBJDUMP PKG_CONFIG + local -x RAW_LDFLAGS="$(get_abi_LDFLAGS) $(raw-ldflags)" # raw-ldflags.patch + + # latest branches has proper fixes, but legacy have more issues and are + # not worth the trouble, so doing the lame "fix" for gcc14 (bug #921370) + local noerr=( + -Wno-error=implicit-function-declaration + -Wno-error=incompatible-pointer-types + ) + # not *FLAGS to ensure it's used everywhere including conftest.sh + CC+=" $(test-flags-CC "${noerr[@]}")" + + NV_ARGS=( + PREFIX="${EPREFIX}"/usr + HOST_CC="$(tc-getBUILD_CC)" + HOST_LD="$(tc-getBUILD_LD)" + NV_USE_BUNDLED_LIBJANSSON=0 + NV_VERBOSE=1 DO_STRIP= MANPAGE_GZIP= OUTPUTDIR=out + ) + + if use persistenced; then + # 390.xx persistenced does not auto-detect libtirpc + LIBS=$(${PKG_CONFIG} --libs libtirpc || die) \ + common_cflags=$(${PKG_CONFIG} --cflags libtirpc || die) \ + emake "${NV_ARGS[@]}" -C nvidia-persistenced + fi + + emake "${NV_ARGS[@]}" -C nvidia-modprobe + use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig +} + +src_install() { + local libdir=$(get_libdir) libdir32=$(ABI=x86 get_libdir) + + NV_ARGS+=( DESTDIR="${D}" LIBDIR="${ED}"/usr/${libdir} ) + + local -A paths=( + [APPLICATION_PROFILE]=/usr/share/nvidia + [CUDA_ICD]=/etc/OpenCL/vendors + [EGL_EXTERNAL_PLATFORM_JSON]=/usr/share/egl/egl_external_platform.d + [GLVND_EGL_ICD_JSON]=/usr/share/glvnd/egl_vendor.d + [VULKAN_ICD_JSON]=/usr/share/vulkan/icd.d + [XORG_OUTPUTCLASS_CONFIG]=/usr/share/X11/xorg.conf.d + + [GLX_MODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules/extensions + [GLX_MODULE_SYMLINK]=/usr/${libdir}/extensions/nvidia + [XMODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules + [XMODULE_SYMLINK]=/usr/${libdir}/xorg/modules + ) + + local skip_files=( + $(usev !X "libGLX_nvidia libglx libnvidia-ifr") + libGLX_indirect # non-glvnd unused fallback + libnvidia-gtk nvidia-{settings,xconfig} # built from source + libnvidia-egl-wayland 10_nvidia_wayland # gui-libs/egl-wayland + ) + local skip_modules=( + $(usev !X "nvfbc vdpau xdriver") + installer nvpd # handled separately / built from source + ) + local skip_types=( + GLVND_LIB GLVND_SYMLINK EGL_CLIENT.\* GLX_CLIENT.\* # media-libs/libglvnd + OPENCL_WRAPPER.\* # virtual/opencl + DOCUMENTATION DOT_DESKTOP # handled separately + XMODULE_NEWSYM # use xorg's libwfb.so, nvidia also keeps it if it exists + .\*_SRC DKMS_CONF LIBGL_LA OPENGL_HEADER # unused + ) + + local DOCS=( + README.txt NVIDIA_Changelog + ) + local HTML_DOCS=( html/. ) + einstalldocs + + local DISABLE_AUTOFORMATTING=yes + local DOC_CONTENTS="\ +Trusted users should be in the 'video' group to use NVIDIA devices. +You can add yourself by using: gpasswd -a my-user video\ + +390.xx libglvnd support is partial and requires different Xorg modules +for working OpenGL/GLX. If using the default Xorg configuration these +should be used automatically, otherwise manually add the ModulePath +from: '${EPREFIX}/${paths[XORG_OUTPUTCLASS_CONFIG]#/}/nvidia-drm-outputclass.conf'\ + +Note that NVIDIA is no longer offering support for the unified memory +module (nvidia-uvm) on x86 (32bit), as such the module is missing. +This means OpenCL/CUDA (and related, like nvenc) cannot be used. +Other functions, like OpenGL, will continue to work. + +Support from NVIDIA for 390.xx will end in December 2022, how long +Gentoo will be able to reasonably support it beyond that is unknown. +If wish to continue using this hardware, should consider switching +to the Nouveau open source driver. +https://nvidia.custhelp.com/app/answers/detail/a_id/3142/ + +For additional information or for troubleshooting issues, please see +https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers and NVIDIA's own +documentation that is installed alongside this README." + readme.gentoo_create_doc + + insinto /etc/modprobe.d + newins "${FILESDIR}"/nvidia-390.conf nvidia.conf + + emake "${NV_ARGS[@]}" -C nvidia-modprobe install + fowners :video /usr/bin/nvidia-modprobe #505092 + fperms 4710 /usr/bin/nvidia-modprobe + + if use persistenced; then + emake "${NV_ARGS[@]}" -C nvidia-persistenced install + newconfd "${FILESDIR}"/nvidia-persistenced.confd nvidia-persistenced + newinitd "${FILESDIR}"/nvidia-persistenced.initd nvidia-persistenced + systemd_dounit "${T}"/nvidia-persistenced.service + fi + + use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig install + + # mimic nvidia-installer by reading .manifest to install files + # 0:file 1:perms 2:type 3+:subtype/arguments -:module + local m into + while IFS=' ' read -ra m; do + ! [[ ${#m[@]} -ge 2 && ${m[-1]} =~ MODULE: ]] || + [[ " ${m[0]##*/}" =~ ^(\ ${skip_files[*]/%/.*|\\} )$ ]] || + [[ " ${m[2]}" =~ ^(\ ${skip_types[*]/%/|\\} )$ ]] || + has ${m[-1]#MODULE:} "${skip_modules[@]}" && continue + + case ${m[2]} in + MANPAGE) + gzip -dc ${m[0]} | newman - ${m[0]%.gz}; assert + continue + ;; + GLX_MODULE_SYMLINK|XMODULE_NEWSYM) + # messy symlinks for non-glvnd xorg modules overrides put + # in a different directory to avoid collisions (390-only) + m[4]=../../xorg/modules/${m[3]#/}${m[4]} + m[3]=/ + ;; + TLS_LIB) [[ ${m[4]} == CLASSIC ]] && continue;; # segfaults (bug #785289) + VDPAU_SYMLINK) m[4]=vdpau/; m[5]=${m[5]#vdpau/};; # .so to vdpau/ + VULKAN_ICD_JSON) m[0]=${m[0]%.template};; + esac + + if [[ -v 'paths[${m[2]}]' ]]; then + into=${paths[${m[2]}]} + elif [[ ${m[2]} == *_BINARY ]]; then + into=/opt/bin + elif [[ ${m[3]} == COMPAT32 ]]; then + use abi_x86_32 || continue + into=/usr/${libdir32} + elif [[ ${m[2]} == *_@(LIB|SYMLINK) ]]; then + into=/usr/${libdir} + else + die "No known installation path for ${m[0]}" + fi + [[ ${m[3]: -2} == ?/ ]] && into+=/${m[3]%/} + [[ ${m[4]: -2} == ?/ ]] && into+=/${m[4]%/} + + if [[ ${m[2]} =~ _SYMLINK$|_NEWSYM$ ]]; then + [[ ${m[4]: -1} == / ]] && m[4]=${m[5]} + dosym ${m[4]} ${into}/${m[0]} + continue + fi + + printf -v m[1] %o $((m[1] | 0200)) # 444->644 + insopts -m${m[1]} + insinto ${into} + doins ${m[0]} + done < .manifest || die + insopts -m0644 # reset + + # MODULE:installer non-skipped extras + dolib.so libnvidia-cfg.so.${PV} + dosym libnvidia-cfg.so.${PV} /usr/${libdir}/libnvidia-cfg.so.1 + dosym libnvidia-cfg.so.${PV} /usr/${libdir}/libnvidia-cfg.so + + dobin nvidia-bug-report.sh + + # symlink non-versioned so nvidia-settings can use it even if misdetected + dosym nvidia-application-profiles-${PV}-key-documentation \ + ${paths[APPLICATION_PROFILE]}/nvidia-application-profiles-key-documentation + + # sandbox issues with /dev/nvidiactl are widespread and sometime + # affect revdeps of packages built with USE=opencl/cuda making it + # hard to manage in ebuilds (minimal set, ebuilds should handle + # manually if need others or addwrite) + insinto /etc/sandbox.d + newins - 20nvidia <<<'SANDBOX_PREDICT="/dev/nvidiactl"' + + # Dracut does not include /etc/modprobe.d if hostonly=no, but we do need this + # to ensure that the nouveau blacklist is applied + # https://github.com/dracut-ng/dracut-ng/issues/674 + # https://bugs.gentoo.org/932781 + if use dkms; then + echo "install_items+=\" ${EPREFIX}/etc/modprobe.d/nvidia.conf \"" >> \ + "${ED}/usr/lib/dracut/dracut.conf.d/10-${PN}.conf" || die + fi +} + +_dracut_initramfs_regen() { + if [ -x $(which dracut) ]; then + dracut -N -f --no-hostonly-cmdline + fi +} + +pkg_preinst() { + # set video group id based on live system (bug #491414) + local g=$(egetent group video | cut -d: -f3) + [[ ${g} =~ ^[0-9]+$ ]] || die "Failed to determine video group id (got '${g}')" + sed -i "s/@VIDEOGID@/${g}/" "${ED}"/etc/modprobe.d/nvidia.conf || die +} + +pkg_postinst() { + if [ $(stat -c %d:%i /) == $(stat -c %d:%i /proc/1/root/.) ]; then + _dracut_initramfs_regen + fi + + readme.gentoo_print_elog + ewarn + ewarn "Be warned/reminded that the 390.xx branch reached end-of-life and" + ewarn "NVIDIA is no longer fixing issues (including security). Free to keep" + ewarn "using (for now) but it is recommended to either switch to nouveau or" + ewarn "replace hardware. Will be kept in-tree while possible, but expect it" + ewarn "to be removed likely in early 2027 or earlier if major issues arise." + ewarn + ewarn "Note that there is no plans to patch in support for kernels branches" + ewarn "newer than 6.1.x which will be supported upstream until December 2026." +} + +pkg_postrm() { + if [ $(stat -c %d:%i /) == $(stat -c %d:%i /proc/1/root/.) ]; then + _dracut_initramfs_regen + fi +} diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-390.157-r8.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-390.157-r8.ebuild deleted file mode 100644 index 1124cfd1..00000000 --- a/x11-drivers/nvidia-drivers/nvidia-drivers-390.157-r8.ebuild +++ /dev/null @@ -1,254 +0,0 @@ -# Copyright 1999-2017 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -EAPI=6 -inherit flag-o-matic multilib-minimal portability toolchain-funcs - -NV_URI="http://http.download.nvidia.com/XFree86/" -AMD64_NV_PACKAGE="NVIDIA-Linux-x86_64-${PV}" - -DESCRIPTION="NVIDIA Accelerated Graphics Driver" -HOMEPAGE="http://www.nvidia.com/ http://www.nvidia.com/Download/Find.aspx" -SRC_URI="amd64? ( ${NV_URI}Linux-x86_64/${PV}/${AMD64_NV_PACKAGE}.run )" - -LICENSE="GPL-2 NVIDIA-r2" -SLOT="3" -KEYWORDS="-* ~amd64" -RESTRICT="bindist mirror strip" -EMULTILIB_PKG="true" - -IUSE="acpi +dkms multilib +tools wayland +X" - -COMMON=" - acct-group/video - acct-user/nvpd - net-libs/libtirpc - X? ( - >=x11-libs/libvdpau-1.0[${MULTILIB_USEDEP}] - media-libs/libglvnd[X,${MULTILIB_USEDEP}] - )" -DEPEND="${COMMON}" -PDEPEND=" - tools? ( x11-misc/nvidia-settings:${SLOT} ) -" -RDEPEND=" - ${COMMON} - >=virtual/opencl-3 - !!x11-drivers/nvidia-drivers:4 - !!x11-drivers/nvidia-drivers:5 - acpi? ( sys-power/acpid ) - dkms? ( ~sys-kernel/${PN}-dkms-${PV}:${SLOT} ) - wayland? ( dev-libs/wayland[${MULTILIB_USEDEP}] ) - X? ( - >=x11-libs/libX11-1.6.2[${MULTILIB_USEDEP}] - >=x11-libs/libXext-1.3.2[${MULTILIB_USEDEP}] - sys-libs/zlib[${MULTILIB_USEDEP}] - ) -" - -QA_PREBUILT="opt/* usr/lib*" - -S=${WORKDIR}/ - -pkg_setup() { - export DISTCC_DISABLE=1 - export CCACHE_DISABLE=1 - - NV_DOC="${S}" - NV_OBJ="${S}" - NV_SRC="${S}/kernel" - NV_MAN="${S}" - NV_X11="${S}" - NV_SOVER=${PV} -} - -src_prepare() { - default - local man_file - for man_file in "${NV_MAN}"/*1.gz; do - gunzip $man_file || die - done - - if ! [ -f nvidia_icd.json ]; then - cp nvidia_icd.json.template nvidia_icd.json || die - sed -i -e 's:__NV_VK_ICD__:libGLX_nvidia.so.0:g' nvidia_icd.json || die - fi -} - -donvidia() { - nv_LIB="${1}" - nv_SOVER="$(scanelf -qF'%S#F' ${nv_LIB})" - nv_DEST="${2}" - nv_LIBNAME=$(basename "${nv_LIB}") - - if [[ "${nv_DEST}" ]]; then - exeinto ${nv_DEST} - action="doexe" - else - nv_DEST="/usr/$(get_libdir)" - action="dolib.so" - fi - - ${action} ${nv_LIB} || die "failed to install ${nv_LIBNAME}" - - if [[ ${nv_SOVER} ]] && ! [[ "${nv_SOVER}" = "${nv_LIBNAME}" ]]; then - dosym ${nv_LIBNAME} ${nv_DEST}/${nv_SOVER} - fi - - dosym ${nv_LIBNAME} ${nv_DEST}/${nv_LIBNAME/.so*/.so} -} - -src_install-libs() { - local inslibdir=$(get_libdir) - local GL_ROOT="/usr/$(get_libdir)" - local CL_ROOT="/usr/$(get_libdir)/OpenCL/vendors/nvidia" - local nv_libdir="${NV_OBJ}" - - if has_multilib_profile && [[ ${ABI} == "x86" ]]; then - nv_libdir="${NV_OBJ}"/32 - fi - - if use X; then - NV_GLX_LIBRARIES=( - "libEGL_nvidia.so.${NV_SOVER} ${GL_ROOT}" - "libGLESv1_CM_nvidia.so.${NV_SOVER} ${GL_ROOT}" - "libGLESv2_nvidia.so.${NV_SOVER} ${GL_ROOT}" - "libGLX_nvidia.so.${NV_SOVER} ${GL_ROOT}" - "libOpenCL.so.1.0.0 ${CL_ROOT}" - "libcuda.so.${NV_SOVER}" - "libnvcuvid.so.${NV_SOVER}" - "libnvidia-compiler.so.${NV_SOVER}" - "libnvidia-eglcore.so.${NV_SOVER}" - "libnvidia-encode.so.${NV_SOVER}" - "libnvidia-fatbinaryloader.so.${NV_SOVER}" - "libnvidia-fbc.so.${NV_SOVER}" - "libnvidia-glcore.so.${NV_SOVER}" - "libnvidia-glsi.so.${NV_SOVER}" - "libnvidia-ifr.so.${NV_SOVER}" - "libnvidia-opencl.so.${NV_SOVER}" - "libnvidia-ptxjitcompiler.so.${NV_SOVER}" - "libvdpau_nvidia.so.${NV_SOVER}" - "libnvidia-ml.so.${NV_SOVER}" - "tls/libnvidia-tls.so.${NV_SOVER}" - ) - - if use wayland && has_multilib_profile && [[ ${ABI} == "amd64" ]]; - then - NV_GLX_LIBRARIES+=( - "libnvidia-egl-wayland.so.1.0.2" - ) - fi - - if has_multilib_profile && [[ ${ABI} == "amd64" ]]; - then - NV_GLX_LIBRARIES+=( - "libnvidia-wfb.so.${NV_SOVER}" - ) - fi - - for NV_LIB in "${NV_GLX_LIBRARIES[@]}"; do - donvidia "${nv_libdir}"/${NV_LIB} - done - fi -} - -src_install() { - donvidia ${NV_OBJ}/libnvidia-cfg.so.${NV_SOVER} - donvidia ${NV_OBJ}/libnvidia-fbc.so.${NV_SOVER} - donvidia ${NV_OBJ}/libnvcuvid.so.${NV_SOVER} - donvidia ${NV_OBJ}/libnvidia-encode.so.${NV_SOVER} - - if has_multilib_profile && use multilib; then - local OABI=${ABI} - for ABI in $(get_install_abis); do - src_install-libs - done - ABI=${OABI} - unset OABI - else - src_install-libs - fi - - is_final_abi || die "failed to iterate through all ABIs" - - if use X; then - insinto /usr/$(get_libdir)/xorg/modules/drivers - doins ${NV_X11}/nvidia_drv.so - - donvidia ${NV_X11}/libglx.so.${NV_SOVER} /usr/$(get_libdir)/nvidia/xorg - - insinto /usr/share/X11/xorg.conf.d - newins "${FILESDIR}"/nvidia-drm-outputclass.conf 50-nvidia-drm-outputclass.conf - - insinto /usr/share/glvnd/egl_vendor.d - doins ${NV_X11}/10_nvidia.json - - insinto /etc/vulkan/icd.d - doins ${NV_X11}/nvidia_icd.json - - exeinto /opt/bin - doexe ${NV_OBJ}/nvidia-xconfig - - doman "${NV_MAN}"/nvidia-xconfig.1 - fi - - if use wayland; then - insinto /usr/share/egl/egl_external_platform.d - doins ${NV_X11}/10_nvidia_wayland.json - fi - - insinto /etc/modprobe.d - doins "${FILESDIR}"/nouveau.conf - - insinto /etc/OpenCL/vendors - doins ${NV_OBJ}/nvidia.icd - - exeinto /opt/bin/ - doexe ${NV_OBJ}/nvidia-cuda-mps-control - doexe ${NV_OBJ}/nvidia-cuda-mps-server - doexe ${NV_OBJ}/nvidia-debugdump - doexe ${NV_OBJ}/nvidia-persistenced - doexe ${NV_OBJ}/nvidia-smi - doexe ${NV_OBJ}/nvidia-modprobe - - fowners root:video /opt/bin/nvidia-modprobe - fperms 4710 /opt/bin/nvidia-modprobe - dosym /{opt,usr}/bin/nvidia-modprobe - - newinitd "${FILESDIR}/nvidia-smi.init" nvidia-smi - newconfd "${FILESDIR}/nvidia-persistenced.conf" nvidia-persistenced - newinitd "${FILESDIR}/nvidia-persistenced.init" nvidia-persistenced - - doman "${NV_MAN}"/nvidia-smi.1 - doman "${NV_MAN}"/nvidia-cuda-mps-control.1 - doman "${NV_MAN}"/nvidia-modprobe.1 - doman "${NV_MAN}"/nvidia-persistenced.1 -} - -_dracut_initramfs_regen() { - if [ -x $(which dracut) ]; then - dracut -N -f --no-hostonly-cmdline - fi -} - -pkg_preinst() { - if [ -d "${ROOT}"/usr/lib/opengl/nvidia ]; then - rm -rf "${ROOT}"/usr/lib/opengl/nvidia/* - fi - - if [ -e "${ROOT}"/etc/env.d/09nvidia ]; then - rm -f "${ROOT}"/etc/env.d/09nvidia - fi -} - -pkg_postinst() { - if [ $(stat -c %d:%i /) == $(stat -c %d:%i /proc/1/root/.) ]; then - _dracut_initramfs_regen - fi -} - -pkg_postrm() { - if [ $(stat -c %d:%i /) == $(stat -c %d:%i /proc/1/root/.) ]; then - _dracut_initramfs_regen - fi -} diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-470.239.06-r1.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-470.239.06-r1.ebuild deleted file mode 100644 index 8b3ae7f7..00000000 --- a/x11-drivers/nvidia-drivers/nvidia-drivers-470.239.06-r1.ebuild +++ /dev/null @@ -1,259 +0,0 @@ -# Copyright 1999-2020 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=6 -inherit flag-o-matic multilib-minimal portability toolchain-funcs - -NV_URI="https://us.download.nvidia.com/XFree86/" -AMD64_NV_PACKAGE="NVIDIA-Linux-x86_64-${PV}" -DESCRIPTION="NVIDIA Accelerated Graphics Driver" - -SRC_URI="amd64? ( ${NV_URI}Linux-x86_64/${PV}/${AMD64_NV_PACKAGE}.run )" - -EMULTILIB_PKG="true" -RESTRICT="bindist mirror strip" -KEYWORDS="-* ~amd64" -LICENSE="GPL-2 NVIDIA-r2" -SLOT="4" - -IUSE="acpi +dkms multilib +tools wayland +X" -REQUIRED_USE="tools? ( X )" - -COMMON=" - acct-group/video - acct-user/nvpd - net-libs/libtirpc - X? ( - >=x11-libs/libvdpau-1.0[${MULTILIB_USEDEP}] - media-libs/libglvnd[X,${MULTILIB_USEDEP}] - ) -" - -DEPEND="${COMMON}" - -RDEPEND=" - ${COMMON} - >=virtual/opencl-3 - !!x11-drivers/nvidia-drivers:3 - !!x11-drivers/nvidia-drivers:5 - acpi? ( sys-power/acpid ) - dkms? ( ~sys-kernel/${PN}-dkms-${PV}:${SLOT} ) - wayland? ( - ~gui-libs/egl-wayland-1.1.7 - ) - X? ( - >=x11-libs/libX11-1.6.2[${MULTILIB_USEDEP}] - >=x11-libs/libXext-1.3.2[${MULTILIB_USEDEP}] - sys-libs/zlib[${MULTILIB_USEDEP}] - ) -" -PDEPEND="tools? ( x11-misc/nvidia-settings:${SLOT} ) -" - -QA_PREBUILT="opt/* usr/lib*" -S=${WORKDIR}/ -PATCHES=( - "${FILESDIR}"/locale.patch -) - -pkg_setup() { - export DISTCC_DISABLE=1 - export CCACHE_DISABLE=1 - - NV_DOC="${S}" - NV_OBJ="${S}" - NV_SRC="${S}/kernel" - NV_MAN="${S}" - NV_X11="${S}" - NV_SOVER=${PV} -} - -src_prepare() { - default - local man_file - for man_file in "${NV_MAN}"/*1.gz; do - gunzip $man_file || die - done - - if ! [ -f nvidia_icd.json ]; then - cp nvidia_icd.json.template nvidia_icd.json || die - sed -i -e 's:__NV_VK_ICD__:libGLX_nvidia.so.0:g' nvidia_icd.json || die - fi -} - -donvidia() { - nv_LIB="${1}" - nv_SOVER="$(scanelf -qF'%S#F' ${nv_LIB})" - nv_DEST="${2}" - nv_LIBNAME=$(basename "${nv_LIB}") - - if [[ "${nv_DEST}" ]]; then - exeinto ${nv_DEST} - action="doexe" - else - nv_DEST="/usr/$(get_libdir)" - action="dolib.so" - fi - - ${action} ${nv_LIB} || die "failed to install ${nv_LIBNAME}" - - if [[ ${nv_SOVER} ]] && ! [[ "${nv_SOVER}" = "${nv_LIBNAME}" ]]; then - dosym ${nv_LIBNAME} ${nv_DEST}/${nv_SOVER} - fi - - dosym ${nv_LIBNAME} ${nv_DEST}/${nv_LIBNAME/.so*/.so} -} - -src_install-libs() { - local inslibdir=$(get_libdir) - local GL_ROOT="/usr/$(get_libdir)" - local CL_ROOT="/usr/$(get_libdir)/OpenCL/vendors/nvidia" - local nv_libdir="${NV_OBJ}" - - if has_multilib_profile && [[ ${ABI} == "x86" ]]; then - nv_libdir="${NV_OBJ}"/32 - fi - - if use X; then - NV_GLX_LIBRARIES=( - "libEGL_nvidia.so.${NV_SOVER} ${GL_ROOT}" - "libGLESv1_CM_nvidia.so.${NV_SOVER} ${GL_ROOT}" - "libGLESv2_nvidia.so.${NV_SOVER} ${GL_ROOT}" - "libGLX_nvidia.so.${NV_SOVER} ${GL_ROOT}" - "libOpenCL.so.1.0.0 ${CL_ROOT}" - "libcuda.so.${NV_SOVER}" - "libnvcuvid.so.${NV_SOVER}" - "libnvidia-compiler.so.${NV_SOVER}" - "libnvidia-allocator.so.${NV_SOVER}" - "libnvidia-eglcore.so.${NV_SOVER}" - "libnvidia-encode.so.${NV_SOVER}" - "libnvidia-glcore.so.${NV_SOVER}" - "libnvidia-glsi.so.${NV_SOVER}" - "libnvidia-glvkspirv.so.${NV_SOVER}" - "libnvidia-ifr.so.${NV_SOVER}" - "libnvidia-opencl.so.${NV_SOVER}" - "libnvidia-ptxjitcompiler.so.${NV_SOVER}" - "libnvidia-opticalflow.so.${NV_SOVER}" - "libvdpau_nvidia.so.${NV_SOVER}" - "libnvidia-ml.so.${NV_SOVER}" - "libnvidia-tls.so.${NV_SOVER}" - ) - - if has_multilib_profile && [[ ${ABI} == "amd64" ]]; then - NV_GLX_LIBRARIES+=( - "libnvidia-cbl.so.${NV_SOVER}" - "libnvidia-ngx.so.${NV_SOVER}" - "libnvidia-rtcore.so.${NV_SOVER}" - "libnvoptix.so.${NV_SOVER}" - ) - fi - - for NV_LIB in "${NV_GLX_LIBRARIES[@]}"; do - donvidia "${nv_libdir}"/${NV_LIB} - done - fi -} - -src_install() { - donvidia ${NV_OBJ}/libnvidia-cfg.so.${NV_SOVER} - donvidia ${NV_OBJ}/libnvidia-fbc.so.${NV_SOVER} - donvidia ${NV_OBJ}/libnvcuvid.so.${NV_SOVER} - donvidia ${NV_OBJ}/libnvidia-encode.so.${NV_SOVER} - - if has_multilib_profile && use multilib; then - local OABI=${ABI} - for ABI in $(multilib_get_enabled_abis); do - src_install-libs - done - ABI=${OABI} - unset OABI - else - src_install-libs - fi - - is_final_abi || die "failed to iterate through all ABIs" - - if use X; then - donvidia ${NV_X11}/libglxserver_nvidia.so.${NV_SOVER} /usr/$(get_libdir)/nvidia/xorg - - insinto /usr/$(get_libdir)/xorg/modules/drivers - doins ${NV_X11}/nvidia_drv.so - - insinto /usr/share/X11/xorg.conf.d - newins ${FILESDIR}/nvidia-drm-outputclass.conf 50-nvidia-drm-outputclass.conf - - insinto /usr/share/glvnd/egl_vendor.d - doins ${NV_X11}/10_nvidia.json - - exeinto /opt/bin - doexe ${NV_OBJ}/nvidia-xconfig - - doman "${NV_MAN}"/nvidia-xconfig.1 - fi - - insinto /etc/modprobe.d - doins "${FILESDIR}"/nouveau.conf - - insinto /etc/vulkan/icd.d - doins nvidia_icd.json - - insinto /etc/vulkan/implicit_layer.d - doins nvidia_layers.json - - insinto /etc/OpenCL/vendors - doins ${NV_OBJ}/nvidia.icd - - exeinto /opt/bin/ - doexe ${NV_OBJ}/nvidia-cuda-mps-control - doexe ${NV_OBJ}/nvidia-cuda-mps-server - doexe ${NV_OBJ}/nvidia-debugdump - doexe ${NV_OBJ}/nvidia-persistenced - doexe ${NV_OBJ}/nvidia-smi - doexe ${NV_OBJ}/nvidia-modprobe - - fowners root:video /opt/bin/nvidia-modprobe - fperms 4710 /opt/bin/nvidia-modprobe - dosym /{opt,usr}/bin/nvidia-modprobe - - newinitd "${FILESDIR}/nvidia-smi.init" nvidia-smi - newconfd "${FILESDIR}/nvidia-persistenced.conf" nvidia-persistenced - newinitd "${FILESDIR}/nvidia-persistenced.init" nvidia-persistenced - - newdoc "${NV_DOC}/README.txt" README - dodoc "${NV_DOC}/NVIDIA_Changelog" - doman "${NV_MAN}"/nvidia-smi.1 - doman "${NV_MAN}"/nvidia-cuda-mps-control.1 - doman "${NV_MAN}"/nvidia-modprobe.1 - doman "${NV_MAN}"/nvidia-persistenced.1 - - docinto html - dodoc -r ${NV_DOC}/html/* -} - -_dracut_initramfs_regen() { - if [ -x $(which dracut) ]; then - dracut -N -f --no-hostonly-cmdline - fi -} - -pkg_preinst() { - if [ -d "${ROOT}"/usr/lib/opengl/nvidia ]; then - rm -rf "${ROOT}"/usr/lib/opengl/nvidia/* - fi - - if [ -e "${ROOT}"/etc/env.d/09nvidia ]; then - rm -f "${ROOT}"/etc/env.d/09nvidia - fi -} - -pkg_postinst() { - if [ $(stat -c %d:%i /) == $(stat -c %d:%i /proc/1/root/.) ]; then - _dracut_initramfs_regen - fi -} - -pkg_postrm() { - if [ $(stat -c %d:%i /) == $(stat -c %d:%i /proc/1/root/.) ]; then - _dracut_initramfs_regen - fi -} diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-470.256.02-r3.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-470.256.02-r3.ebuild new file mode 100644 index 00000000..db4c9dcb --- /dev/null +++ b/x11-drivers/nvidia-drivers/nvidia-drivers-470.256.02-r3.ebuild @@ -0,0 +1,387 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit desktop flag-o-matic multilib readme.gentoo-r1 +inherit systemd toolchain-funcs unpacker user-info + +NV_URI="https://download.nvidia.com/XFree86/" + +DESCRIPTION="NVIDIA Accelerated Graphics Driver" +HOMEPAGE="https://www.nvidia.com/download/index.aspx" +SRC_URI=" + ${NV_URI}Linux-x86_64/${PV}/NVIDIA-Linux-x86_64-${PV}.run + $(printf "${NV_URI}%s/%s-${PV}.tar.bz2 " \ + nvidia-{installer,modprobe,persistenced,xconfig}{,}) +" +# nvidia-installer is unused but here for GPL-2's "distribute sources" +S=${WORKDIR} + +LICENSE="NVIDIA-r2 BSD BSD-2 GPL-2 MIT ZLIB curl openssl" +SLOT="4" +KEYWORDS="-* amd64" +IUSE="abi_x86_32 abi_x86_64 +acpi +dkms +persistenced +tools +X" +RESTRICT="strip" + +COMMON_DEPEND=" + acct-group/video + persistenced? ( + acct-user/nvpd + net-libs/libtirpc:= + ) +" +RDEPEND=" + ${COMMON_DEPEND} + sys-libs/glibc + !!x11-drivers/nvidia-drivers:3 + !!x11-drivers/nvidia-drivers:5 + acpi? ( sys-power/acpid ) + dkms? ( ~sys-kernel/${PN}-dkms-${PV}:${SLOT} ) + X? ( + media-libs/libglvnd[X,abi_x86_32(-)?] + x11-libs/libX11[abi_x86_32(-)?] + x11-libs/libXext[abi_x86_32(-)?] + ) +" +DEPEND=" + ${COMMON_DEPEND} + x11-base/xorg-proto + x11-libs/libX11 + x11-libs/libXext +" +BDEPEND=" + sys-devel/m4 + virtual/pkgconfig +" +PDEPEND=" + tools? ( x11-misc/nvidia-settings:${SLOT} ) +" + +QA_PREBUILT="lib/firmware/* opt/bin/* usr/lib*" + +PATCHES=( + "${FILESDIR}"/nvidia-drivers-470.141.03-clang15.patch + "${FILESDIR}"/nvidia-modprobe-390.141-uvm-perms.patch +) + +pkg_setup() { + local CONFIG_CHECK=" + PROC_FS + ~DRM_KMS_HELPER + ~SYSVIPC + ~!AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT + ~!LOCKDEP + ~!SLUB_DEBUG_ON + ~!X86_KERNEL_IBT + !DEBUG_MUTEXES + " + + local ERROR_DRM_KMS_HELPER="CONFIG_DRM_KMS_HELPER: is not set but needed for Xorg auto-detection + of drivers (no custom config), and for nvidia-drm.modeset=1 if used. + Cannot be directly selected in the kernel's menuconfig, and may need + selection of a DRM device even if unused, e.g. CONFIG_DRM_AMDGPU=m or + DRM_I915=y, DRM_NOUVEAU=m also acceptable if a module and not built-in." + + local ERROR_X86_KERNEL_IBT="CONFIG_X86_KERNEL_IBT: is set and, if the CPU supports the feature, + this *could* lead to modules load failure with ENDBR errors, or to + broken CUDA/NVENC. Please ignore if not having issues, but otherwise + try to unset or pass ibt=off to the kernel's command line." #911142 + + CONFIG_CHECK+=" X86_PAT" #817764 +} + +src_prepare() { + # make patches usable across versions + rm nvidia-modprobe && mv nvidia-modprobe{-${PV},} || die + rm nvidia-persistenced && mv nvidia-persistenced{-${PV},} || die + rm nvidia-xconfig && mv nvidia-xconfig{-${PV},} || die + + default + + # prevent detection of incomplete kernel DRM support (bug #603818) + sed 's/defined(CONFIG_DRM/defined(CONFIG_DRM_KMS_HELPER/g' \ + -i kernel/conftest.sh || die + + sed 's/__USER__/nvpd/' \ + nvidia-persistenced/init/systemd/nvidia-persistenced.service.template \ + > "${T}"/nvidia-persistenced.service || die +} + +src_compile() { + tc-export AR CC CXX LD OBJCOPY OBJDUMP PKG_CONFIG + local -x RAW_LDFLAGS="$(get_abi_LDFLAGS) $(raw-ldflags)" # raw-ldflags.patch + + # latest branches has proper fixes, but legacy have more issues and are + # not worth the trouble, so doing the lame "fix" for gcc14 (bug #921370) + # TODO: check if still needed on bumps given this branch is supported, + # and reminder to cleanup the CC="${KERNEL_CC}" in modargs if removing + local noerr=( + -Wno-error=implicit-function-declaration + -Wno-error=incompatible-pointer-types + ) + # not *FLAGS to ensure it's used everywhere including conftest.sh + CC+=" $(test-flags-CC "${noerr[@]}")" + + local xnvflags=-fPIC #840389 + # lto static libraries tend to cause problems without fat objects + tc-is-lto && xnvflags+=" $(test-flags-CC -ffat-lto-objects)" + + NV_ARGS=( + PREFIX="${EPREFIX}"/usr + HOST_CC="$(tc-getBUILD_CC)" + HOST_LD="$(tc-getBUILD_LD)" + NV_USE_BUNDLED_LIBJANSSON=0 + NV_VERBOSE=1 DO_STRIP= MANPAGE_GZIP= OUTPUTDIR=out + XNVCTRL_CFLAGS="${xnvflags}" + ) + + use persistenced && emake "${NV_ARGS[@]}" -C nvidia-persistenced + + emake "${NV_ARGS[@]}" -C nvidia-modprobe + use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig +} + +src_install() { + local libdir=$(get_libdir) libdir32=$(ABI=x86 get_libdir) + + NV_ARGS+=( DESTDIR="${D}" LIBDIR="${ED}"/usr/${libdir} ) + + local -A paths=( + [APPLICATION_PROFILE]=/usr/share/nvidia + [CUDA_ICD]=/etc/OpenCL/vendors + [EGL_EXTERNAL_PLATFORM_JSON]=/usr/share/egl/egl_external_platform.d + [FIRMWARE]=/lib/firmware/nvidia/${PV} + [GLVND_EGL_ICD_JSON]=/usr/share/glvnd/egl_vendor.d + [VULKAN_ICD_JSON]=/usr/share/vulkan + [WINE_LIB]=/usr/${libdir}/nvidia/wine + [XORG_OUTPUTCLASS_CONFIG]=/usr/share/X11/xorg.conf.d + + [GLX_MODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules/extensions + [GLX_MODULE_SYMLINK]=/usr/${libdir}/xorg/modules + [XMODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules + ) + + local skip_files=( + $(usev !X "libGLX_nvidia libglxserver_nvidia libnvidia-ifr") + libGLX_indirect # non-glvnd unused fallback + libnvidia-gtk nvidia-{settings,xconfig} # built from source + # skip wayland-related files, largely broken with 470 at this point + libnvidia-egl-wayland 10_nvidia_wayland libnvidia-vulkan-producer + ) + local skip_modules=( + $(usev !X "nvfbc vdpau xdriver") + $(usev !dkms gsp) + installer nvpd # handled separately / built from source + ) + local skip_types=( + GLVND_LIB GLVND_SYMLINK EGL_CLIENT.\* GLX_CLIENT.\* # media-libs/libglvnd + OPENCL_WRAPPER.\* # virtual/opencl + DOCUMENTATION DOT_DESKTOP .\*_SRC DKMS_CONF # handled separately / unused + ) + + local DOCS=( + README.txt NVIDIA_Changelog supported-gpus/supported-gpus.json + ) + local HTML_DOCS=( html/. ) + einstalldocs + + local DISABLE_AUTOFORMATTING=yes + local DOC_CONTENTS="\ +Trusted users should be in the 'video' group to use NVIDIA devices. +You can add yourself by using: gpasswd -a my-user video\ + +See '${EPREFIX}/etc/modprobe.d/nvidia.conf' for modules options.\ + +Note that without USE=abi_x86_32 on ${PN}, 32bit applications +(typically using wine / steam) will not be able to use GPU acceleration.\ + +For additional information or for troubleshooting issues, please see +https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers and NVIDIA's own +documentation that is installed alongside this README." + readme.gentoo_create_doc + + insinto /etc/modprobe.d + newins "${FILESDIR}"/nvidia-470.conf nvidia.conf + + emake "${NV_ARGS[@]}" -C nvidia-modprobe install + fowners :video /usr/bin/nvidia-modprobe #505092 + fperms 4710 /usr/bin/nvidia-modprobe + + if use persistenced; then + emake "${NV_ARGS[@]}" -C nvidia-persistenced install + newconfd "${FILESDIR}"/nvidia-persistenced.confd nvidia-persistenced + newinitd "${FILESDIR}"/nvidia-persistenced.initd nvidia-persistenced + systemd_dounit "${T}"/nvidia-persistenced.service + fi + + use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig install + + # mimic nvidia-installer by reading .manifest to install files + # 0:file 1:perms 2:type 3+:subtype/arguments -:module + local m into + while IFS=' ' read -ra m; do + ! [[ ${#m[@]} -ge 2 && ${m[-1]} =~ MODULE: ]] || + [[ " ${m[0]##*/}" =~ ^(\ ${skip_files[*]/%/.*|\\} )$ ]] || + [[ " ${m[2]}" =~ ^(\ ${skip_types[*]/%/|\\} )$ ]] || + has ${m[-1]#MODULE:} "${skip_modules[@]}" && continue + + case ${m[2]} in + MANPAGE) + gzip -dc ${m[0]} | newman - ${m[0]%.gz}; assert + continue + ;; + VDPAU_SYMLINK) m[4]=vdpau/; m[5]=${m[5]#vdpau/};; # .so to vdpau/ + esac + + if [[ -v 'paths[${m[2]}]' ]]; then + into=${paths[${m[2]}]} + elif [[ ${m[2]} == *_BINARY ]]; then + into=/opt/bin + elif [[ ${m[3]} == COMPAT32 ]]; then + use abi_x86_32 || continue + into=/usr/${libdir32} + elif [[ ${m[2]} == *_@(LIB|SYMLINK) ]]; then + into=/usr/${libdir} + else + die "No known installation path for ${m[0]}" + fi + [[ ${m[3]: -2} == ?/ ]] && into+=/${m[3]%/} + [[ ${m[4]: -2} == ?/ ]] && into+=/${m[4]%/} + + if [[ ${m[2]} =~ _SYMLINK$ ]]; then + [[ ${m[4]: -1} == / ]] && m[4]=${m[5]} + dosym ${m[4]} ${into}/${m[0]} + continue + fi + [[ ${m[0]} =~ ^libnvidia-ngx.so ]] && + dosym ${m[0]} ${into}/${m[0]%.so*}.so.1 # soname not in .manifest + + printf -v m[1] %o $((m[1] | 0200)) # 444->644 + insopts -m${m[1]} + insinto ${into} + doins ${m[0]} + done < .manifest || die + insopts -m0644 # reset + + # MODULE:installer non-skipped extras + : "$(systemd_get_sleepdir)" + exeinto "${_#"${EPREFIX}"}" + doexe systemd/system-sleep/nvidia + dobin systemd/nvidia-sleep.sh + systemd_dounit systemd/system/nvidia-{hibernate,resume,suspend}.service + + dobin nvidia-bug-report.sh + + # enabling is needed for sleep to work properly and little reason not to do + # it unconditionally for a better user experience + : "$(systemd_get_systemunitdir)" + local unitdir=${_#"${EPREFIX}"} + # not using relative symlinks to match systemd's own links + dosym {"${unitdir}",/etc/systemd/system/systemd-hibernate.service.wants}/nvidia-hibernate.service + dosym {"${unitdir}",/etc/systemd/system/systemd-hibernate.service.wants}/nvidia-resume.service + dosym {"${unitdir}",/etc/systemd/system/systemd-suspend.service.wants}/nvidia-suspend.service + dosym {"${unitdir}",/etc/systemd/system/systemd-suspend.service.wants}/nvidia-resume.service + # also add a custom elogind hook to do the equivalent of the above + exeinto /usr/lib/elogind/system-sleep + newexe "${FILESDIR}"/system-sleep.elogind nvidia + # <elogind-255.5 used a different path (bug #939216), keep a compat symlink + # TODO: cleanup after 255.5 been stable for a few months + dosym {/usr/lib,/"${libdir}"}/elogind/system-sleep/nvidia + + # symlink non-versioned so nvidia-settings can use it even if misdetected + dosym nvidia-application-profiles-${PV}-key-documentation \ + ${paths[APPLICATION_PROFILE]}/nvidia-application-profiles-key-documentation + + # don't attempt to strip firmware files (silences errors) + dostrip -x ${paths[FIRMWARE]} + + # sandbox issues with /dev/nvidiactl (and /dev/char wrt bug #904292) + # are widespread and sometime affect revdeps of packages built with + # USE=opencl/cuda making it hard to manage in ebuilds (minimal set, + # ebuilds should handle manually if need others or addwrite) + insinto /etc/sandbox.d + newins - 20nvidia <<<'SANDBOX_PREDICT="/dev/nvidiactl:/dev/char"' + + # Dracut does not include /etc/modprobe.d if hostonly=no, but we do need this + # to ensure that the nouveau blacklist is applied + # https://github.com/dracut-ng/dracut-ng/issues/674 + # https://bugs.gentoo.org/932781 + if use dkms; then + echo "install_items+=\" ${EPREFIX}/etc/modprobe.d/nvidia.conf \"" >> \ + "${ED}/usr/lib/dracut/dracut.conf.d/10-${PN}.conf" || die + fi +} + +_dracut_initramfs_regen() { + if [ -x $(which dracut) ]; then + dracut -N -f --no-hostonly-cmdline + fi +} + +pkg_preinst() { + # set video group id based on live system (bug #491414) + local g=$(egetent group video | cut -d: -f3) + [[ ${g} =~ ^[0-9]+$ ]] || die "Failed to determine video group id (got '${g}')" + sed -i "s/@VIDEOGID@/${g}/" "${ED}"/etc/modprobe.d/nvidia.conf || die +} + +pkg_postinst() { + if [ $(stat -c %d:%i /) == $(stat -c %d:%i /proc/1/root/.) ]; then + _dracut_initramfs_regen + fi + + readme.gentoo_print_elog + + if [[ $(</proc/cmdline) == *slub_debug=[!-]* ]]; then + ewarn "Detected that the current kernel command line is using 'slub_debug='," + ewarn "this may lead to system instability/freezes with this version of" + ewarn "${PN}. Bug: https://bugs.gentoo.org/796329" + fi + + # these can be removed after some time, only to help the transition + # given users are unlikely to do further custom solutions if it works + # (see also https://github.com/elogind/elogind/issues/272) + if grep -riq "^[^#]*HandleNvidiaSleep=yes" "${EROOT}"/etc/elogind/sleep.conf.d/ 2>/dev/null + then + ewarn + ewarn "!!! WARNING !!!" + ewarn "Detected HandleNvidiaSleep=yes in ${EROOT}/etc/elogind/sleep.conf.d/." + ewarn "This 'could' cause issues if used in combination with the new hook" + ewarn "installed by the ebuild to handle sleep using the official upstream" + ewarn "script. It is recommended to disable the option." + fi + if [[ $(realpath "${EROOT}"{/etc,{/usr,}/lib*}/elogind/system-sleep | sort | uniq | \ + xargs -d'\n' grep -Ril nvidia 2>/dev/null | wc -l) -gt 2 ]] + then + ewarn + ewarn "!!! WARNING !!!" + ewarn "Detected a custom script at ${EROOT}{/etc,{/usr,}/lib*}/elogind/system-sleep" + ewarn "referencing NVIDIA. This version of ${PN} has installed its own" + ewarn "hook at ${EROOT}/usr/lib/elogind/system-sleep/nvidia and it is recommended" + ewarn "to remove the custom one to avoid potential issues." + ewarn + ewarn "Feel free to ignore this warning if you know the other NVIDIA-related" + ewarn "scripts can be used together. The warning will be removed in the future." + fi + if [[ ${REPLACING_VERSIONS##* } ]] && + ver_test ${REPLACING_VERSIONS##* } -lt 470.256.02-r1 # may get repeated + then + elog + elog "For suspend/sleep, 'NVreg_PreserveVideoMemoryAllocations=1' is now default" + elog "with this version of ${PN}. This is recommended (or required) by" + elog "major DEs especially with wayland but, *if* experience regressions with" + elog "suspend, try reverting to =0 in '${EROOT}/etc/modprobe.d/nvidia.conf'." + elog + elog "May notably be an issue when using neither systemd nor elogind to suspend." + elog + elog "Also, the systemd suspend/hibernate/resume services are now enabled by" + elog "default, and for openrc+elogind a similar hook has been installed." + fi +} + +pkg_postrm() { + if [ $(stat -c %d:%i /) == $(stat -c %d:%i /proc/1/root/.) ]; then + _dracut_initramfs_regen + fi +} diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-535.171.04-r1.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-535.171.04-r1.ebuild deleted file mode 100644 index 8b1db030..00000000 --- a/x11-drivers/nvidia-drivers/nvidia-drivers-535.171.04-r1.ebuild +++ /dev/null @@ -1,259 +0,0 @@ -# Copyright 1999-2020 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=6 -inherit flag-o-matic multilib-minimal portability toolchain-funcs - -NV_URI="https://us.download.nvidia.com/XFree86/" -AMD64_NV_PACKAGE="NVIDIA-Linux-x86_64-${PV}" -DESCRIPTION="NVIDIA Accelerated Graphics Driver" - -SRC_URI="amd64? ( ${NV_URI}Linux-x86_64/${PV}/${AMD64_NV_PACKAGE}.run )" - -EMULTILIB_PKG="true" -KEYWORDS="-* ~amd64" -RESTRICT="bindist mirror strip" -LICENSE="GPL-2 NVIDIA-r2" -SLOT="5" - -IUSE="acpi +dkms multilib +tools wayland +X" -REQUIRED_USE="tools? ( X )" - -COMMON=" - acct-group/video - acct-user/nvpd - net-libs/libtirpc - X? ( - >=x11-libs/libvdpau-1.0[${MULTILIB_USEDEP}] - media-libs/libglvnd[X,${MULTILIB_USEDEP}] - ) -" - -DEPEND="${COMMON}" - -RDEPEND=" - ${COMMON} - >=virtual/opencl-3 - !!x11-drivers/nvidia-drivers:3 - !!x11-drivers/nvidia-drivers:4 - acpi? ( sys-power/acpid ) - dkms? ( ~sys-kernel/${PN}-dkms-${PV}:${SLOT} ) - wayland? ( - gui-libs/egl-gbm - >=gui-libs/egl-wayland-1.1.10 - ) - X? ( - >=x11-libs/libX11-1.6.2[${MULTILIB_USEDEP}] - >=x11-libs/libXext-1.3.2[${MULTILIB_USEDEP}] - sys-libs/zlib[${MULTILIB_USEDEP}] - ) -" -PDEPEND="tools? ( x11-misc/nvidia-settings:${SLOT} ) -" - -QA_PREBUILT="opt/* usr/lib*" -S=${WORKDIR}/ -PATCHES=( - "${FILESDIR}"/locale.patch -) - -pkg_setup() { - export DISTCC_DISABLE=1 - export CCACHE_DISABLE=1 - - NV_DOC="${S}" - NV_OBJ="${S}" - NV_SRC="${S}/kernel" - NV_MAN="${S}" - NV_X11="${S}" - NV_SOVER=${PV} -} - -src_prepare() { - default - local man_file - for man_file in "${NV_MAN}"/*1.gz; do - gunzip $man_file || die - done - - if ! [ -f nvidia_icd.json ]; then - cp nvidia_icd.json.template nvidia_icd.json || die - sed -i -e 's:__NV_VK_ICD__:libGLX_nvidia.so.0:g' nvidia_icd.json || die - fi -} - -donvidia() { - nv_LIB="${1}" - nv_SOVER="$(scanelf -qF'%S#F' ${nv_LIB})" - nv_DEST="${2}" - nv_LIBNAME=$(basename "${nv_LIB}") - - if [[ "${nv_DEST}" ]]; then - exeinto ${nv_DEST} - action="doexe" - else - nv_DEST="/usr/$(get_libdir)" - action="dolib.so" - fi - - ${action} ${nv_LIB} || die "failed to install ${nv_LIBNAME}" - - if [[ ${nv_SOVER} ]] && ! [[ "${nv_SOVER}" = "${nv_LIBNAME}" ]]; then - dosym ${nv_LIBNAME} ${nv_DEST}/${nv_SOVER} - fi - - dosym ${nv_LIBNAME} ${nv_DEST}/${nv_LIBNAME/.so*/.so} -} - -src_install-libs() { - local inslibdir=$(get_libdir) - local GL_ROOT="/usr/$(get_libdir)" - local CL_ROOT="/usr/$(get_libdir)/OpenCL/vendors/nvidia" - local nv_libdir="${NV_OBJ}" - - if has_multilib_profile && [[ ${ABI} == "x86" ]]; then - nv_libdir="${NV_OBJ}"/32 - fi - - if use X; then - NV_GLX_LIBRARIES=( - "libEGL_nvidia.so.${NV_SOVER} ${GL_ROOT}" - "libGLESv1_CM_nvidia.so.${NV_SOVER} ${GL_ROOT}" - "libGLESv2_nvidia.so.${NV_SOVER} ${GL_ROOT}" - "libGLX_nvidia.so.${NV_SOVER} ${GL_ROOT}" - "libOpenCL.so.1.0.0 ${CL_ROOT}" - "libcuda.so.${NV_SOVER}" - "libnvcuvid.so.${NV_SOVER}" - "libnvidia-allocator.so.${NV_SOVER}" - "libnvidia-eglcore.so.${NV_SOVER}" - "libnvidia-encode.so.${NV_SOVER}" - "libnvidia-glcore.so.${NV_SOVER}" - "libnvidia-glsi.so.${NV_SOVER}" - "libnvidia-glvkspirv.so.${NV_SOVER}" - "libnvidia-opencl.so.${NV_SOVER}" - "libnvidia-ptxjitcompiler.so.${NV_SOVER}" - "libnvidia-opticalflow.so.${NV_SOVER}" - "libvdpau_nvidia.so.${NV_SOVER}" - "libnvidia-ml.so.${NV_SOVER}" - "libnvidia-tls.so.${NV_SOVER}" - ) - - if has_multilib_profile && [[ ${ABI} == "amd64" ]]; then - NV_GLX_LIBRARIES+=( - "libnvidia-ngx.so.${NV_SOVER}" - "libnvidia-rtcore.so.${NV_SOVER}" - "libnvoptix.so.${NV_SOVER}" - ) - fi - - for NV_LIB in "${NV_GLX_LIBRARIES[@]}"; do - donvidia "${nv_libdir}"/${NV_LIB} - done - fi -} - -src_install() { - donvidia ${NV_OBJ}/libnvidia-cfg.so.${NV_SOVER} - donvidia ${NV_OBJ}/libnvidia-fbc.so.${NV_SOVER} - donvidia ${NV_OBJ}/libnvidia-nvvm.so.${NV_SOVER} - donvidia ${NV_OBJ}/libnvidia-vulkan-producer.so.${NV_SOVER} - donvidia ${NV_OBJ}/libnvcuvid.so.${NV_SOVER} - donvidia ${NV_OBJ}/libnvidia-encode.so.${NV_SOVER} - - if has_multilib_profile && use multilib; then - local OABI=${ABI} - for ABI in $(multilib_get_enabled_abis); do - src_install-libs - done - ABI=${OABI} - unset OABI - else - src_install-libs - fi - - is_final_abi || die "failed to iterate through all ABIs" - - if use X; then - donvidia ${NV_X11}/libglxserver_nvidia.so.${NV_SOVER} /usr/$(get_libdir)/nvidia/xorg - - insinto /usr/$(get_libdir)/xorg/modules/drivers - doins ${NV_X11}/nvidia_drv.so - - insinto /usr/share/X11/xorg.conf.d - newins ${FILESDIR}/nvidia-drm-outputclass.conf 50-nvidia-drm-outputclass.conf - - insinto /usr/share/glvnd/egl_vendor.d - doins ${NV_X11}/10_nvidia.json - - exeinto /opt/bin - doexe ${NV_OBJ}/nvidia-xconfig - - doman "${NV_MAN}"/nvidia-xconfig.1 - fi - - insinto /etc/modprobe.d - doins "${FILESDIR}"/nouveau.conf - - insinto /etc/vulkan/icd.d - doins nvidia_icd.json - - insinto /etc/vulkan/implicit_layer.d - doins nvidia_layers.json - - insinto /etc/OpenCL/vendors - doins ${NV_OBJ}/nvidia.icd - - exeinto /opt/bin/ - doexe ${NV_OBJ}/nvidia-cuda-mps-control - doexe ${NV_OBJ}/nvidia-cuda-mps-server - doexe ${NV_OBJ}/nvidia-debugdump - doexe ${NV_OBJ}/nvidia-persistenced - doexe ${NV_OBJ}/nvidia-smi - doexe ${NV_OBJ}/nvidia-modprobe - - fowners root:video /opt/bin/nvidia-modprobe - fperms 4710 /opt/bin/nvidia-modprobe - dosym /{opt,usr}/bin/nvidia-modprobe - - newinitd "${FILESDIR}/nvidia-smi.init" nvidia-smi - newconfd "${FILESDIR}/nvidia-persistenced.conf" nvidia-persistenced - newinitd "${FILESDIR}/nvidia-persistenced.init" nvidia-persistenced - - newdoc "${NV_DOC}/README.txt" README - dodoc "${NV_DOC}/NVIDIA_Changelog" - doman "${NV_MAN}"/nvidia-smi.1 - doman "${NV_MAN}"/nvidia-cuda-mps-control.1 - doman "${NV_MAN}"/nvidia-modprobe.1 - doman "${NV_MAN}"/nvidia-persistenced.1 - - docinto html - dodoc -r ${NV_DOC}/html/* -} - -_dracut_initramfs_regen() { - if [ -x $(which dracut) ]; then - dracut -N -f --no-hostonly-cmdline - fi -} - -pkg_preinst() { - if [ -d "${ROOT}"/usr/lib/opengl/nvidia ]; then - rm -rf "${ROOT}"/usr/lib/opengl/nvidia/* - fi - - if [ -e "${ROOT}"/etc/env.d/09nvidia ]; then - rm -f "${ROOT}"/etc/env.d/09nvidia - fi -} - -pkg_postinst() { - if [ $(stat -c %d:%i /) == $(stat -c %d:%i /proc/1/root/.) ]; then - _dracut_initramfs_regen - fi -} - -pkg_postrm() { - if [ $(stat -c %d:%i /) == $(stat -c %d:%i /proc/1/root/.) ]; then - _dracut_initramfs_regen - fi -} diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-550.127.05.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-550.127.05.ebuild new file mode 100644 index 00000000..f86871e4 --- /dev/null +++ b/x11-drivers/nvidia-drivers/nvidia-drivers-550.127.05.ebuild @@ -0,0 +1,407 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit desktop flag-o-matic readme.gentoo-r1 +inherit systemd toolchain-funcs unpacker user-info + +NV_URI="https://download.nvidia.com/XFree86/" + +DESCRIPTION="NVIDIA Accelerated Graphics Driver" +HOMEPAGE="https://www.nvidia.com/download/index.aspx" +SRC_URI=" + ${NV_URI}Linux-x86_64/${PV}/NVIDIA-Linux-x86_64-${PV}.run + $(printf "${NV_URI}%s/%s-${PV}.tar.bz2 " \ + nvidia-{installer,modprobe,persistenced,xconfig}{,}) +" +# nvidia-installer is unused but here for GPL-2's "distribute sources" +S=${WORKDIR} + +LICENSE="NVIDIA-r2 Apache-2.0 BSD BSD-2 GPL-2 MIT ZLIB curl openssl" +SLOT="5" +KEYWORDS="-* amd64" +IUSE="abi_x86_32 abi_x86_64 +acpi +dkms +persistenced +powerd +tools +wayland +X" +RESTRICT="strip" + +COMMON_DEPEND=" + acct-group/video + X? ( x11-libs/libpciaccess ) + persistenced? ( + acct-user/nvpd + net-libs/libtirpc:= + ) +" +RDEPEND=" + ${COMMON_DEPEND} + dev-libs/openssl:0/3 + sys-libs/glibc + !!x11-drivers/nvidia-drivers:3 + !!x11-drivers/nvidia-drivers:4 + acpi? ( sys-power/acpid ) + dkms? ( ~sys-kernel/${PN}-dkms-${PV}:${SLOT} ) + X? ( + media-libs/libglvnd[X,abi_x86_32(-)?] + x11-libs/libX11[abi_x86_32(-)?] + x11-libs/libXext[abi_x86_32(-)?] + ) + powerd? ( sys-apps/dbus[abi_x86_32(-)?] ) + wayland? ( + gui-libs/egl-gbm + >=gui-libs/egl-wayland-1.1.10 + ) +" +DEPEND=" + ${COMMON_DEPEND} + x11-base/xorg-proto + x11-libs/libX11 + x11-libs/libXext +" +BDEPEND=" + sys-devel/m4 + virtual/pkgconfig +" +PDEPEND=" + tools? ( x11-misc/nvidia-settings:${SLOT} ) +" + +QA_PREBUILT="lib/firmware/* opt/bin/* usr/lib*" + +PATCHES=( + "${FILESDIR}"/nvidia-modprobe-390.141-uvm-perms.patch +) + +pkg_setup() { + local CONFIG_CHECK=" + PROC_FS + ~DRM_KMS_HELPER + ~SYSVIPC + ~!LOCKDEP + ~!SLUB_DEBUG_ON + !DEBUG_MUTEXES + $(usev powerd '~CPU_FREQ') + " + + local ERROR_DRM_KMS_HELPER="CONFIG_DRM_KMS_HELPER: is not set but required + for drivers (no custom config), and for wayland / nvidia-drm.modeset=1. + Cannot be directly selected in the kernel's menuconfig, and may need + selection of a DRM device even if unused, e.g. CONFIG_DRM_AMDGPU=m or + DRM_I915=y, DRM_NOUVEAU=m also acceptable if a module and not built-in." + + CONFIG_CHECK+=" X86_PAT" #817764 + + CONFIG_CHECK+=" MMU_NOTIFIER" #843827 + local ERROR_MMU_NOTIFIER="CONFIG_MMU_NOTIFIER: is not set but required. + Cannot be directly selected in the kernel's menuconfig, and may need + selection of another option that requires it such as CONFIG_KVM." +} + +src_prepare() { + # make patches usable across versions + rm nvidia-modprobe && mv nvidia-modprobe{-${PV},} || die + rm nvidia-persistenced && mv nvidia-persistenced{-${PV},} || die + rm nvidia-xconfig && mv nvidia-xconfig{-${PV},} || die + + default + + # prevent detection of incomplete kernel DRM support (bug #603818) + sed 's/defined(CONFIG_DRM/defined(CONFIG_DRM_KMS_HELPER/g' \ + -i kernel/conftest.sh || die + + # adjust service files + sed 's/__USER__/nvpd/' \ + nvidia-persistenced/init/systemd/nvidia-persistenced.service.template \ + > "${T}"/nvidia-persistenced.service || die + sed -i "s|/usr|${EPREFIX}/opt|" systemd/system/nvidia-powerd.service || die + + # use alternative vulkan icd option if USE=-X (bug #909181) + use X || sed -i 's/"libGLX/"libEGL/' nvidia_{layers,icd}.json || die + + # enable nvidia-drm.modeset=1 by default with USE=wayland + cp "${FILESDIR}"/nvidia-545.conf "${T}"/nvidia.conf || die + use !wayland || sed -i '/^#.*modeset=1$/s/^#//' "${T}"/nvidia.conf || die +} + +src_compile() { + tc-export AR CC CXX LD OBJCOPY OBJDUMP PKG_CONFIG + + local xnvflags=-fPIC #840389 + # lto static libraries tend to cause problems without fat objects + tc-is-lto && xnvflags+=" $(test-flags-CC -ffat-lto-objects)" + + NV_ARGS=( + PREFIX="${EPREFIX}"/usr + HOST_CC="$(tc-getBUILD_CC)" + HOST_LD="$(tc-getBUILD_LD)" + BUILD_GTK2LIB= + NV_USE_BUNDLED_LIBJANSSON=0 + NV_VERBOSE=1 DO_STRIP= MANPAGE_GZIP= OUTPUTDIR=out + WAYLAND_AVAILABLE=$(usex wayland 1 0) + XNVCTRL_CFLAGS="${xnvflags}" + ) + + use persistenced && emake "${NV_ARGS[@]}" -C nvidia-persistenced + + emake "${NV_ARGS[@]}" -C nvidia-modprobe + use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig +} + +src_install() { + local libdir=$(get_libdir) libdir32=$(ABI=x86 get_libdir) + + NV_ARGS+=( DESTDIR="${D}" LIBDIR="${ED}"/usr/${libdir} ) + + local -A paths=( + [APPLICATION_PROFILE]=/usr/share/nvidia + [CUDA_ICD]=/etc/OpenCL/vendors + [EGL_EXTERNAL_PLATFORM_JSON]=/usr/share/egl/egl_external_platform.d + [FIRMWARE]=/lib/firmware/nvidia/${PV} + [GBM_BACKEND_LIB_SYMLINK]=/usr/${libdir}/gbm + [GLVND_EGL_ICD_JSON]=/usr/share/glvnd/egl_vendor.d + [OPENGL_DATA]=/usr/share/nvidia + [VULKAN_ICD_JSON]=/usr/share/vulkan + [WINE_LIB]=/usr/${libdir}/nvidia/wine + [XORG_OUTPUTCLASS_CONFIG]=/usr/share/X11/xorg.conf.d + + [GLX_MODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules/extensions + [GLX_MODULE_SYMLINK]=/usr/${libdir}/xorg/modules + [XMODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules + ) + + local skip_files=( + $(usev !X "libGLX_nvidia libglxserver_nvidia") + libGLX_indirect # non-glvnd unused fallback + libnvidia-{gtk,wayland-client} nvidia-{settings,xconfig} # from source + libnvidia-egl-gbm 15_nvidia_gbm # gui-libs/egl-gbm + libnvidia-egl-wayland 10_nvidia_wayland # gui-libs/egl-wayland + libnvidia-pkcs11.so # using the openssl3 version instead + ) + local skip_modules=( + $(usev !X "nvfbc vdpau xdriver") + $(usev !dkms gsp) + $(usev !powerd powerd) + installer nvpd # handled separately / built from source + ) + local skip_types=( + GLVND_LIB GLVND_SYMLINK EGL_CLIENT.\* GLX_CLIENT.\* # media-libs/libglvnd + OPENCL_WRAPPER.\* # virtual/opencl + DOCUMENTATION DOT_DESKTOP .\*_SRC DKMS_CONF SYSTEMD_UNIT # handled separately / unused + ) + + local DOCS=( + README.txt NVIDIA_Changelog supported-gpus/supported-gpus.json + ) + local HTML_DOCS=( html/. ) + einstalldocs + + local DISABLE_AUTOFORMATTING=yes + local DOC_CONTENTS="\ +Trusted users should be in the 'video' group to use NVIDIA devices. +You can add yourself by using: gpasswd -a my-user video\ + +See '${EPREFIX}/etc/modprobe.d/nvidia.conf' for modules options.\ + +Note that without USE=abi_x86_32 on ${PN}, 32bit applications +(typically using wine / steam) will not be able to use GPU acceleration.\ + +For additional information or for troubleshooting issues, please see +https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers and NVIDIA's own +documentation that is installed alongside this README." + readme.gentoo_create_doc + + insinto /etc/modprobe.d + doins "${T}"/nvidia.conf + + emake "${NV_ARGS[@]}" -C nvidia-modprobe install + fowners :video /usr/bin/nvidia-modprobe #505092 + fperms 4710 /usr/bin/nvidia-modprobe + + if use persistenced; then + emake "${NV_ARGS[@]}" -C nvidia-persistenced install + newconfd "${FILESDIR}"/nvidia-persistenced.confd nvidia-persistenced + newinitd "${FILESDIR}"/nvidia-persistenced.initd nvidia-persistenced + systemd_dounit "${T}"/nvidia-persistenced.service + fi + + use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig install + + # mimic nvidia-installer by reading .manifest to install files + # 0:file 1:perms 2:type 3+:subtype/arguments -:module + local m into + while IFS=' ' read -ra m; do + ! [[ ${#m[@]} -ge 2 && ${m[-1]} =~ MODULE: ]] || + [[ " ${m[0]##*/}" =~ ^(\ ${skip_files[*]/%/.*|\\} )$ ]] || + [[ " ${m[2]}" =~ ^(\ ${skip_types[*]/%/|\\} )$ ]] || + has ${m[-1]#MODULE:} "${skip_modules[@]}" && continue + + case ${m[2]} in + MANPAGE) + gzip -dc ${m[0]} | newman - ${m[0]%.gz}; assert + continue + ;; + GBM_BACKEND_LIB_SYMLINK) m[4]=../${m[4]};; # missing ../ + VDPAU_SYMLINK) m[4]=vdpau/; m[5]=${m[5]#vdpau/};; # .so to vdpau/ + esac + + if [[ -v 'paths[${m[2]}]' ]]; then + into=${paths[${m[2]}]} + elif [[ ${m[2]} == EXPLICIT_PATH ]]; then + into=${m[3]} + elif [[ ${m[2]} == *_BINARY ]]; then + into=/opt/bin + elif [[ ${m[3]} == COMPAT32 ]]; then + use abi_x86_32 || continue + into=/usr/${libdir32} + elif [[ ${m[2]} == *_@(LIB|SYMLINK) ]]; then + into=/usr/${libdir} + else + die "No known installation path for ${m[0]}" + fi + [[ ${m[3]: -2} == ?/ ]] && into+=/${m[3]%/} + [[ ${m[4]: -2} == ?/ ]] && into+=/${m[4]%/} + + if [[ ${m[2]} =~ _SYMLINK$ ]]; then + [[ ${m[4]: -1} == / ]] && m[4]=${m[5]} + dosym ${m[4]} ${into}/${m[0]} + continue + fi + [[ ${m[0]} =~ ^libnvidia-ngx.so|^libnvidia-egl-gbm.so ]] && + dosym ${m[0]} ${into}/${m[0]%.so*}.so.1 # soname not in .manifest + + printf -v m[1] %o $((m[1] | 0200)) # 444->644 + insopts -m${m[1]} + insinto ${into} + doins ${m[0]} + done < .manifest || die + insopts -m0644 # reset + + # MODULE:installer non-skipped extras + : "$(systemd_get_sleepdir)" + exeinto "${_#"${EPREFIX}"}" + doexe systemd/system-sleep/nvidia + dobin systemd/nvidia-sleep.sh + systemd_dounit systemd/system/nvidia-{hibernate,resume,suspend}.service + + dobin nvidia-bug-report.sh + + # MODULE:powerd extras + if use powerd; then + newinitd "${FILESDIR}"/nvidia-powerd.initd nvidia-powerd #923117 + systemd_dounit systemd/system/nvidia-powerd.service + + insinto /usr/share/dbus-1/system.d + doins nvidia-dbus.conf + fi + + # enabling is needed for sleep to work properly and little reason not to do + # it unconditionally for a better user experience + : "$(systemd_get_systemunitdir)" + local unitdir=${_#"${EPREFIX}"} + # not using relative symlinks to match systemd's own links + dosym {"${unitdir}",/etc/systemd/system/systemd-hibernate.service.wants}/nvidia-hibernate.service + dosym {"${unitdir}",/etc/systemd/system/systemd-hibernate.service.wants}/nvidia-resume.service + dosym {"${unitdir}",/etc/systemd/system/systemd-suspend.service.wants}/nvidia-suspend.service + dosym {"${unitdir}",/etc/systemd/system/systemd-suspend.service.wants}/nvidia-resume.service + # also add a custom elogind hook to do the equivalent of the above + exeinto /usr/lib/elogind/system-sleep + newexe "${FILESDIR}"/system-sleep.elogind nvidia + # <elogind-255.5 used a different path (bug #939216), keep a compat symlink + # TODO: cleanup after 255.5 been stable for a few months + dosym {/usr/lib,/"${libdir}"}/elogind/system-sleep/nvidia + + # symlink non-versioned so nvidia-settings can use it even if misdetected + dosym nvidia-application-profiles-${PV}-key-documentation \ + ${paths[APPLICATION_PROFILE]}/nvidia-application-profiles-key-documentation + + # don't attempt to strip firmware files (silences errors) + dostrip -x ${paths[FIRMWARE]} + + # sandbox issues with /dev/nvidiactl others (bug #904292,#921578) + # are widespread and sometime affect revdeps of packages built with + # USE=opencl/cuda making it hard to manage in ebuilds (minimal set, + # ebuilds should handle manually if need others or addwrite) + insinto /etc/sandbox.d + newins - 20nvidia <<<'SANDBOX_PREDICT="/dev/nvidiactl:/dev/nvidia-caps:/dev/char"' + + # Dracut does not include /etc/modprobe.d if hostonly=no, but we do need this + # to ensure that the nouveau blacklist is applied + # https://github.com/dracut-ng/dracut-ng/issues/674 + # https://bugs.gentoo.org/932781 + if use dkms; then + echo "install_items+=\" ${EPREFIX}/etc/modprobe.d/nvidia.conf \"" >> \ + "${ED}/usr/lib/dracut/dracut.conf.d/10-${PN}.conf" || die + fi +} + +_dracut_initramfs_regen() { + if [ -x $(which dracut) ]; then + dracut -N -f --no-hostonly-cmdline + fi +} + +pkg_preinst() { + # set video group id based on live system (bug #491414) + local g=$(egetent group video | cut -d: -f3) + [[ ${g} =~ ^[0-9]+$ ]] || die "Failed to determine video group id (got '${g}')" + sed -i "s/@VIDEOGID@/${g}/" "${ED}"/etc/modprobe.d/nvidia.conf || die +} + +pkg_postinst() { + if [ $(stat -c %d:%i /) == $(stat -c %d:%i /proc/1/root/.) ]; then + _dracut_initramfs_regen + fi + + readme.gentoo_print_elog + + if [[ $(</proc/cmdline) == *slub_debug=[!-]* ]]; then + ewarn "Detected that the current kernel command line is using 'slub_debug='," + ewarn "this may lead to system instability/freezes with this version of" + ewarn "${PN}. Bug: https://bugs.gentoo.org/796329" + fi + + # these can be removed after some time, only to help the transition + # given users are unlikely to do further custom solutions if it works + # (see also https://github.com/elogind/elogind/issues/272) + if grep -riq "^[^#]*HandleNvidiaSleep=yes" "${EROOT}"/etc/elogind/sleep.conf.d/ 2>/dev/null + then + ewarn + ewarn "!!! WARNING !!!" + ewarn "Detected HandleNvidiaSleep=yes in ${EROOT}/etc/elogind/sleep.conf.d/." + ewarn "This 'could' cause issues if used in combination with the new hook" + ewarn "installed by the ebuild to handle sleep using the official upstream" + ewarn "script. It is recommended to disable the option." + fi + if [[ $(realpath "${EROOT}"{/etc,{/usr,}/lib*}/elogind/system-sleep | sort | uniq | \ + xargs -d'\n' grep -Ril nvidia 2>/dev/null | wc -l) -gt 2 ]] + then + ewarn + ewarn "!!! WARNING !!!" + ewarn "Detected a custom script at ${EROOT}{/etc,{/usr,}/lib*}/elogind/system-sleep" + ewarn "referencing NVIDIA. This version of ${PN} has installed its own" + ewarn "hook at ${EROOT}/usr/lib/elogind/system-sleep/nvidia and it is recommended" + ewarn "to remove the custom one to avoid potential issues." + ewarn + ewarn "Feel free to ignore this warning if you know the other NVIDIA-related" + ewarn "scripts can be used together. The warning will be removed in the future." + fi + if [[ ${REPLACING_VERSIONS##* } ]] && + ver_test ${REPLACING_VERSIONS##* } -lt 470.256.02-r1 # may get repeated + then + elog + elog "For suspend/sleep, 'NVreg_PreserveVideoMemoryAllocations=1' is now default" + elog "with this version of ${PN}. This is recommended (or required) by" + elog "major DEs especially with wayland but, *if* experience regressions with" + elog "suspend, try reverting to =0 in '${EROOT}/etc/modprobe.d/nvidia.conf'." + elog + elog "May notably be an issue when using neither systemd nor elogind to suspend." + elog + elog "Also, the systemd suspend/hibernate/resume services are now enabled by" + elog "default, and for openrc+elogind a similar hook has been installed." + fi +} + +pkg_postrm() { + if [ $(stat -c %d:%i /) == $(stat -c %d:%i /proc/1/root/.) ]; then + _dracut_initramfs_regen + fi +} |