commit:     4918bb4f7c45c9ff1d583a3f7f50998514f35064
Author:     David Seifert <soap <AT> gentoo <DOT> org>
AuthorDate: Mon Mar  3 09:35:20 2025 +0000
Commit:     David Seifert <soap <AT> gentoo <DOT> org>
CommitDate: Mon Mar  3 09:35:20 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4918bb4f

sys-libs/libnvidia-container: add patch for go 1.24

Signed-off-by: David Seifert <soap <AT> gentoo.org>

 .../files/libnvidia-container-1.17.4-go-1.24.patch | 48 ++++++++++++++++++++++
 .../libnvidia-container-1.17.4.ebuild              |  1 +
 2 files changed, 49 insertions(+)

diff --git 
a/sys-libs/libnvidia-container/files/libnvidia-container-1.17.4-go-1.24.patch 
b/sys-libs/libnvidia-container/files/libnvidia-container-1.17.4-go-1.24.patch
new file mode 100644
index 000000000000..e2439651dd04
--- /dev/null
+++ 
b/sys-libs/libnvidia-container/files/libnvidia-container-1.17.4-go-1.24.patch
@@ -0,0 +1,48 @@
+https://patch-diff.githubusercontent.com/raw/NVIDIA/libnvidia-container/pull/297.patch
+
+From 1c680195fdc85948d635286b72a6ad9f823b5987 Mon Sep 17 00:00:00 2001
+From: Dmitry Sharshakov <[email protected]>
+Date: Thu, 13 Feb 2025 10:18:59 +0100
+Subject: [PATCH] Fix building with Go 1.24
+
+Go 1.24 does not allow defining methods on C types anymore, so make convert a 
function, not a method.
+
+Fixes the following error when building with Go 1.24:
+`./main.go:35:10: cannot define new methods on non-local type CDeviceRule`
+
+Signed-off-by: Dmitry Sharshakov <[email protected]>
+---
+ src/nvcgo/main.go | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/nvcgo/main.go b/src/nvcgo/main.go
+index 1523a06d..ed43be8e 100644
+--- a/src/nvcgo/main.go
++++ b/src/nvcgo/main.go
+@@ -32,7 +32,7 @@ func main() {}
+ type CDeviceRule = C.struct_device_rule
+ 
+ // Convert a C-based DeviceRule to a Go-based cgroup.DeviceRule
+-func (r *CDeviceRule) convert() cgroup.DeviceRule {
++func convert(r *CDeviceRule) cgroup.DeviceRule {
+       return cgroup.DeviceRule{
+               Allow:  bool(r.allow),
+               Type:   C.GoString(r._type),
+@@ -67,7 +67,7 @@ func GetDeviceCGroupMountPath(version C.int, procRootPath 
*C.char, pid C.pid_t,
+               return -1
+       }
+       *cgroupMountPath = C.CString(p)
+-      *cgroupRootPrefix= C.CString(r)
++      *cgroupRootPrefix = C.CString(r)
+ 
+       return 0
+ }
+@@ -100,7 +100,7 @@ func AddDeviceRules(version C.int, cgroupPath *C.char, 
crules []CDeviceRule, rer
+ 
+       rules := make([]cgroup.DeviceRule, len(crules))
+       for i, cr := range crules {
+-              rules[i] = cr.convert()
++              rules[i] = convert(&cr)
+       }
+ 
+       err = api.AddDeviceRules(C.GoString(cgroupPath), rules)

diff --git a/sys-libs/libnvidia-container/libnvidia-container-1.17.4.ebuild 
b/sys-libs/libnvidia-container/libnvidia-container-1.17.4.ebuild
index 5d4b6cda8900..b1e9266e9b98 100644
--- a/sys-libs/libnvidia-container/libnvidia-container-1.17.4.ebuild
+++ b/sys-libs/libnvidia-container/libnvidia-container-1.17.4.ebuild
@@ -53,6 +53,7 @@ BDEPEND="
 
 PATCHES=(
        "${FILESDIR}/${PN}-1.17.0-fix-makefile-r1.patch"
+       "${FILESDIR}/${PN}-1.17.4-go-1.24.patch"
 )
 
 DOCS=( NOTICE README.md )

Reply via email to