mirror of
https://github.com/lingble/meta-tegra.git
synced 2025-10-28 11:02:28 +00:00
libnvidia-container: fix go build on 36.4.3
With backported patch at https://github.com/NVIDIA/libnvidia-container/pull/297 supporting go 1.24+ replacing the local patch from master. Signed-off-by: Dan Walkes <danwalkes@trellis-logic.com>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
From 1c680195fdc85948d635286b72a6ad9f823b5987 Mon Sep 17 00:00:00 2001
|
||||
From: Dmitry Sharshakov <dmitry.sharshakov@siderolabs.com>
|
||||
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`
|
||||
|
||||
Upstream-Status: Backport [https://github.com/NVIDIA/libnvidia-container/pull/297]
|
||||
|
||||
Signed-off-by: Dmitry Sharshakov <dmitry.sharshakov@siderolabs.com>
|
||||
Signed-off-by: Dan Walkes <dan.walkes@trellis-logic.com>
|
||||
|
||||
---
|
||||
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)
|
||||
@@ -1,43 +0,0 @@
|
||||
From d44307d59b60926e016b98f27aa87aadb050e4a6 Mon Sep 17 00:00:00 2001
|
||||
From: Matt Madison <matt@madison.systems>
|
||||
Date: Sun, 9 Mar 2025 07:34:57 -0700
|
||||
Subject: [PATCH] nvcgo: fix build with go 1.24
|
||||
|
||||
Go doesn't allow adding methods to types defined elsewhere,
|
||||
leading to this error:
|
||||
|
||||
/main.go:35:10: cannot define new methods on non-local type CDeviceRule
|
||||
|
||||
Change the locally-defined method to be an ordinary function instead.
|
||||
|
||||
Upstream-Status: Pending
|
||||
Signed-off-by: Matt Madison <matt@madison.systems>
|
||||
---
|
||||
src/nvcgo/main.go | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/nvcgo/main.go b/src/nvcgo/main.go
|
||||
index 1523a06d..380ebfb0 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),
|
||||
@@ -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)
|
||||
--
|
||||
2.43.0
|
||||
|
||||
@@ -42,7 +42,7 @@ NVIDIA_MODPROBE_SRCURI_DESTSUFFIX = "${@os.path.join(os.path.basename(d.getVar('
|
||||
SRC_URI = "git://github.com/NVIDIA/libnvidia-container.git;protocol=https;name=libnvidia;branch=main \
|
||||
git://github.com/NVIDIA/nvidia-modprobe.git;protocol=https;branch=main;name=modprobe;destsuffix=${NVIDIA_MODPROBE_SRCURI_DESTSUFFIX} \
|
||||
file://0001-OE-cross-build-fixups.patch \
|
||||
file://0003-nvcgo-fix-build-with-go-1.24.patch \
|
||||
file://0002-fix-building-with-go-1-24.patch \
|
||||
"
|
||||
|
||||
# tag: v1.16.2
|
||||
|
||||
Reference in New Issue
Block a user