tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
libnvidia-container: 1.9.0 -> 1.16.2
Moritz Sanft
1 year ago
60b56abc
fedeefb4
+113
-66
3 changed files
expand all
collapse all
unified
split
pkgs
by-name
li
libnvidia-container
fix-library-resolving.patch
modprobe.patch
package.nix
+47
-30
pkgs/by-name/li/libnvidia-container/libnvc-ldconfig-and-path-fixes.patch
pkgs/by-name/li/libnvidia-container/fix-library-resolving.patch
···
1
1
+
From 8799541f99785d2bd881561386676fb0985e939e Mon Sep 17 00:00:00 2001
2
2
+
From: Moritz Sanft <58110325+msanft@users.noreply.github.com>
3
3
+
Date: Thu, 10 Oct 2024 14:32:42 +0200
4
4
+
Subject: [PATCH] fix library resolving
5
5
+
6
6
+
Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>
7
7
+
---
8
8
+
src/ldcache.c | 46 +++++++++++++++++-----------------------------
9
9
+
src/ldcache.h | 2 +-
10
10
+
src/nvc_info.c | 10 +++-------
11
11
+
src/nvc_ldcache.c | 2 +-
12
12
+
4 files changed, 22 insertions(+), 38 deletions(-)
13
13
+
1
14
diff --git a/src/ldcache.c b/src/ldcache.c
2
2
-
index 38bab05..e1abc89 100644
15
15
+
index 38bab055..8cd30a0f 100644
3
16
--- a/src/ldcache.c
4
17
+++ b/src/ldcache.c
5
5
-
@@ -108,40 +108,27 @@ ldcache_close(struct ldcache *ctx)
6
6
-
18
18
+
@@ -108,40 +108,28 @@ ldcache_close(struct ldcache *ctx)
19
19
+
7
20
int
8
21
ldcache_resolve(struct ldcache *ctx, uint32_t arch, const char *root, const char * const libs[],
9
22
- char *paths[], size_t size, ldcache_select_fn select, void *select_ctx)
···
14
27
- int override;
15
28
+ char dir[PATH_MAX];
16
29
+ char lib[PATH_MAX];
17
17
-
30
30
+
18
31
- h = (struct header_libc6 *)ctx->ptr;
19
32
memset(paths, 0, size * sizeof(*paths));
20
20
-
33
33
+
21
34
- for (uint32_t i = 0; i < h->nlibs; ++i) {
22
35
- int32_t flags = h->libs[i].flags;
23
36
- char *key = (char *)ctx->ptr + h->libs[i].key;
24
37
- char *value = (char *)ctx->ptr + h->libs[i].value;
25
38
-
26
39
- if (!(flags & LD_ELF) || (flags & LD_ARCH_MASK) != arch)
27
27
-
+ for (size_t j = 0; j < size; ++j) {
28
28
-
+ snprintf(dir, 100, "/run/opengl-driver%s/lib",
29
29
-
+ arch == LD_I386_LIB32 ? "-32" : "");
30
30
-
+ if (!strncmp(libs[j], "libvdpau_nvidia.so", 100))
31
31
-
+ strcat(dir, "/vdpau");
32
32
-
+ snprintf(lib, 100, "%s/%s.%s", dir, libs[j], version);
33
33
-
+ if (path_resolve_full(ctx->err, path, "/", lib) < 0)
34
34
-
+ return (-1);
35
35
-
+ if (!file_exists(ctx->err, path))
36
36
-
continue;
40
40
+
- continue;
37
41
-
38
42
- for (size_t j = 0; j < size; ++j) {
39
43
- if (!str_has_prefix(key, libs[j]))
···
52
56
- }
53
57
- break;
54
58
- }
59
59
+
+ for (size_t j = 0; j < size; ++j) {
60
60
+
+ snprintf(dir, 100, "@driverLink@/lib");
61
61
+
+
62
62
+
+ if (!strncmp(libs[j], "libvdpau_nvidia.so", 100))
63
63
+
+ strcat(dir, "/vdpau");
64
64
+
+ snprintf(lib, 100, "%s/%s.%s", dir, libs[j], version);
65
65
+
+ if (path_resolve_full(ctx->err, path, "/", lib) < 0)
66
66
+
+ return (-1);
67
67
+
+ if (!file_exists(ctx->err, path))
68
68
+
+ continue;
69
69
+
+
55
70
+ paths[j] = xstrdup(ctx->err, path);
56
71
+ if (paths[j] == NULL)
57
72
+ return (-1);
···
59
74
return (0);
60
75
}
61
76
diff --git a/src/ldcache.h b/src/ldcache.h
62
62
-
index 33d78dd..2b087db 100644
77
77
+
index 33d78dd7..2b087dbc 100644
63
78
--- a/src/ldcache.h
64
79
+++ b/src/ldcache.h
65
80
@@ -50,6 +50,6 @@ void ldcache_init(struct ldcache *, struct error *, const char *);
···
68
83
int ldcache_resolve(struct ldcache *, uint32_t, const char *, const char * const [],
69
84
- char *[], size_t, ldcache_select_fn, void *);
70
85
+ char *[], size_t, const char*);
71
71
-
86
86
+
72
87
#endif /* HEADER_LDCACHE_H */
73
88
diff --git a/src/nvc_info.c b/src/nvc_info.c
74
74
-
index 30e3cfd..6d12a50 100644
89
89
+
index b7b8adfa..d42f2beb 100644
75
90
--- a/src/nvc_info.c
76
91
+++ b/src/nvc_info.c
77
77
-
@@ -167,15 +167,13 @@ find_library_paths(struct error *err, struct nvc_driver_info *info, const char *
92
92
+
@@ -217,15 +217,13 @@ find_library_paths(struct error *err, struct dxcore_context *dxcore, struct nvc_
78
93
if (path_resolve_full(err, path, root, ldcache) < 0)
79
94
return (-1);
80
95
ldcache_init(&ld, err, path);
81
96
- if (ldcache_open(&ld) < 0)
82
97
- return (-1);
83
83
-
98
98
+
84
99
info->nlibs = size;
85
100
info->libs = array_new(err, size);
86
101
if (info->libs == NULL)
···
89
104
- info->libs, info->nlibs, select_libraries_fn, info) < 0)
90
105
+ info->libs, info->nlibs, info->nvrm_version) < 0)
91
106
goto fail;
92
92
-
107
107
+
93
108
info->nlibs32 = size;
94
94
-
@@ -183,13 +181,11 @@ find_library_paths(struct error *err, struct nvc_driver_info *info, const char *
109
109
+
@@ -233,13 +231,11 @@ find_library_paths(struct error *err, struct dxcore_context *dxcore, struct nvc_
95
110
if (info->libs32 == NULL)
96
111
goto fail;
97
112
if (ldcache_resolve(&ld, LIB32_ARCH, root, libs,
···
99
114
+ info->libs32, info->nlibs32, info->nvrm_version) < 0)
100
115
goto fail;
101
116
rv = 0;
102
102
-
117
117
+
103
118
fail:
104
119
- if (ldcache_close(&ld) < 0)
105
120
- return (-1);
106
121
return (rv);
107
122
}
108
108
-
109
109
-
@@ -203,7 +199,7 @@ find_binary_paths(struct error *err, struct nvc_driver_info *info, const char *r
123
123
+
124
124
+
@@ -253,7 +249,7 @@ find_binary_paths(struct error *err, struct dxcore_context* dxcore, struct nvc_d
110
125
char path[PATH_MAX];
111
126
int rv = -1;
112
112
-
127
127
+
113
128
- if ((env = secure_getenv("PATH")) == NULL) {
114
129
+ if ((env = "/run/nvidia-docker/bin:/run/nvidia-docker/extras/bin") == NULL) {
115
130
error_setx(err, "environment variable PATH not found");
116
131
return (-1);
117
132
}
118
133
diff --git a/src/nvc_ldcache.c b/src/nvc_ldcache.c
119
119
-
index 6ff380f..cbe6a69 100644
134
134
+
index db3b2f69..ae5def43 100644
120
135
--- a/src/nvc_ldcache.c
121
136
+++ b/src/nvc_ldcache.c
122
122
-
@@ -340,7 +340,7 @@ nvc_ldcache_update(struct nvc_context *ctx, const struct nvc_container *cnt)
137
137
+
@@ -367,7 +367,7 @@ nvc_ldcache_update(struct nvc_context *ctx, const struct nvc_container *cnt)
123
138
if (validate_args(ctx, cnt != NULL) < 0)
124
139
return (-1);
125
125
-
126
126
-
- argv = (char * []){cnt->cfg.ldconfig, cnt->cfg.libs_dir, cnt->cfg.libs32_dir, NULL};
140
140
+
141
141
+
- argv = (char * []){cnt->cfg.ldconfig, "-f", "/etc/ld.so.conf", "-C", "/etc/ld.so.cache", cnt->cfg.libs_dir, cnt->cfg.libs32_dir, NULL};
127
142
+ argv = (char * []){cnt->cfg.ldconfig, "-f", "/tmp/ld.so.conf.nvidia-host", "-C", "/tmp/ld.so.cache.nvidia-host", cnt->cfg.libs_dir, cnt->cfg.libs32_dir, NULL};
128
143
if (*argv[0] == '@') {
129
144
/*
130
145
* We treat this path specially to be relative to the host filesystem.
146
146
+
--
147
147
+
2.46.0
+9
-8
pkgs/by-name/li/libnvidia-container/modprobe.patch
···
1
1
diff -ruN nvidia-modprobe-@modprobeVersion@/modprobe-utils/nvidia-modprobe-utils.c nvidia-modprobe-@modprobeVersion@/modprobe-utils/nvidia-modprobe-utils.c
2
2
-
--- nvidia-modprobe-@modprobeVersion@/modprobe-utils/nvidia-modprobe-utils.c 2020-07-09 17:06:05.000000000 +0000
3
3
-
+++ nvidia-modprobe-@modprobeVersion@/modprobe-utils/nvidia-modprobe-utils.c 2020-08-18 12:43:03.223871514 +0000
4
4
-
@@ -840,10 +840,10 @@
2
2
+
--- nvidia-modprobe-@modprobeVersion@/modprobe-utils/nvidia-modprobe-utils.c 2021-11-13 14:36:58.096684602 +0000
3
3
+
+++ nvidia-modprobe-@modprobeVersion@-patched/modprobe-utils/nvidia-modprobe-utils.c 2021-11-13 14:43:40.965146390 +0000
4
4
+
@@ -959,10 +959,10 @@
5
5
return mknod_helper(major, minor_num, vgpu_dev_name, NV_PROC_REGISTRY_PATH);
6
6
}
7
7
···
17
17
char field[32];
18
18
FILE *fp;
19
19
diff -ruN nvidia-modprobe-@modprobeVersion@/modprobe-utils/nvidia-modprobe-utils.h nvidia-modprobe-@modprobeVersion@/modprobe-utils/nvidia-modprobe-utils.h
20
20
-
--- nvidia-modprobe-@modprobeVersion@/modprobe-utils/nvidia-modprobe-utils.h 2020-07-09 17:06:05.000000000 +0000
21
21
-
+++ nvidia-modprobe-@modprobeVersion@/modprobe-utils/nvidia-modprobe-utils.h 2020-08-18 12:43:44.227745050 +0000
22
22
-
@@ -81,6 +81,7 @@
20
20
+
--- nvidia-modprobe-@modprobeVersion@/modprobe-utils/nvidia-modprobe-utils.h 2021-11-13 14:36:58.096684602 +0000
21
21
+
+++ nvidia-modprobe-@modprobeVersion@-patched/modprobe-utils/nvidia-modprobe-utils.h 2021-11-13 14:38:34.078700961 +0000
22
22
+
@@ -87,6 +87,7 @@
23
23
int nvidia_nvswitch_get_file_state(int minor);
24
24
int nvidia_cap_mknod(const char* cap_file_path, int *minor);
25
25
int nvidia_cap_get_file_state(const char* cap_file_path);
26
26
+int nvidia_cap_get_device_file_attrs(const char* cap_file_path, int *major, int *minor, char *name);
27
27
+
int nvidia_cap_imex_channel_mknod(int minor);
28
28
+
int nvidia_cap_imex_channel_file_state(int minor);
27
29
int nvidia_get_chardev_major(const char *name);
28
28
-
29
29
-
#endif /* NV_LINUX */
30
30
+
int nvidia_msr_modprobe(void);
+57
-28
pkgs/by-name/li/libnvidia-container/package.nix
···
1
1
-
{ stdenv
2
2
-
, lib
3
3
-
, addDriverRunpath
4
4
-
, fetchFromGitHub
5
5
-
, pkg-config
6
6
-
, elfutils
7
7
-
, libcap
8
8
-
, libseccomp
9
9
-
, rpcsvc-proto
10
10
-
, libtirpc
11
11
-
, makeWrapper
12
12
-
, substituteAll
13
13
-
, removeReferencesTo
14
14
-
, go
1
1
+
{
2
2
+
stdenv,
3
3
+
lib,
4
4
+
addDriverRunpath,
5
5
+
fetchFromGitHub,
6
6
+
pkg-config,
7
7
+
elfutils,
8
8
+
libcap,
9
9
+
libseccomp,
10
10
+
rpcsvc-proto,
11
11
+
libtirpc,
12
12
+
makeWrapper,
13
13
+
substituteAll,
14
14
+
removeReferencesTo,
15
15
+
replaceVars,
16
16
+
go,
15
17
}:
16
18
let
17
17
-
modprobeVersion = "495.44";
19
19
+
modprobeVersion = "550.54.14";
18
20
nvidia-modprobe = fetchFromGitHub {
19
21
owner = "NVIDIA";
20
22
repo = "nvidia-modprobe";
21
23
rev = modprobeVersion;
22
22
-
sha256 = "sha256-Y3ZOfge/EcmhqI19yWO7UfPqkvY1CHHvFC5l9vYyGuU=";
24
24
+
sha256 = "sha256-iBRMkvOXacs/llTtvc/ZC5i/q9gc8lMuUHxMbu8A+Kg=";
23
25
};
24
26
modprobePatch = substituteAll {
25
27
src = ./modprobe.patch;
···
28
30
in
29
31
stdenv.mkDerivation rec {
30
32
pname = "libnvidia-container";
31
31
-
version = "1.9.0";
33
33
+
version = "1.16.2";
32
34
33
35
src = fetchFromGitHub {
34
36
owner = "NVIDIA";
35
35
-
repo = pname;
37
37
+
repo = "libnvidia-container";
36
38
rev = "v${version}";
37
37
-
sha256 = "sha256-7OTawWwjeKU8wIa8I/+aSvAJli4kEua94nJSNyCajpE=";
39
39
+
sha256 = "sha256-hX+2B+0kHiAC2lyo6kwe7DctPLJWgRdbhlc316OO3r8=";
38
40
};
39
41
40
42
patches = [
41
41
-
# locations of nvidia-driver libraries are not resolved via ldconfig which
42
42
-
# doesn't get used on NixOS. Additional support binaries like nvidia-smi
43
43
+
# Locations of nvidia driver libraries are not resolved via ldconfig which
44
44
+
# doesn't get used on NixOS.
45
45
+
# TODO: The latter doesn't really apply anymore.
46
46
+
# Additional support binaries like nvidia-smi
43
47
# are not resolved via the environment PATH but via the derivation output
44
48
# path.
45
45
-
./libnvc-ldconfig-and-path-fixes.patch
49
49
+
(replaceVars ./fix-library-resolving.patch {
50
50
+
inherit (addDriverRunpath) driverLink;
51
51
+
})
46
52
47
53
# fix bogus struct declaration
48
54
./inline-c-struct.patch
···
53
59
-e 's/^REVISION ?=.*/REVISION = ${src.rev}/' \
54
60
-e 's/^COMPILER :=.*/COMPILER = $(CC)/' \
55
61
mk/common.mk
62
62
+
63
63
+
sed -i \
64
64
+
-e 's/^GIT_TAG ?=.*/GIT_TAG = ${version}/' \
65
65
+
-e 's/^GIT_COMMIT ?=.*/GIT_COMMIT = ${src.rev}/' \
66
66
+
versions.mk
56
67
57
68
mkdir -p deps/src/nvidia-modprobe-${modprobeVersion}
58
69
cp -r ${nvidia-modprobe}/* deps/src/nvidia-modprobe-${modprobeVersion}
···
84
95
HOME="$(mktemp -d)"
85
96
'';
86
97
87
87
-
env.NIX_CFLAGS_COMPILE = toString [ "-I${libtirpc.dev}/include/tirpc" ];
88
88
-
NIX_LDFLAGS = [ "-L${libtirpc.dev}/lib" "-ltirpc" ];
98
98
+
env.NIX_CFLAGS_COMPILE = toString [ "-I${lib.getInclude libtirpc}/include/tirpc" ];
99
99
+
NIX_LDFLAGS = [
100
100
+
"-L${lib.getLib libtirpc}/lib"
101
101
+
"-ltirpc"
102
102
+
];
89
103
90
90
-
nativeBuildInputs = [ pkg-config go rpcsvc-proto makeWrapper removeReferencesTo ];
104
104
+
nativeBuildInputs = [
105
105
+
pkg-config
106
106
+
go
107
107
+
rpcsvc-proto
108
108
+
makeWrapper
109
109
+
removeReferencesTo
110
110
+
];
91
111
92
92
-
buildInputs = [ elfutils libcap libseccomp libtirpc ];
112
112
+
buildInputs = [
113
113
+
elfutils
114
114
+
libcap
115
115
+
libseccomp
116
116
+
libtirpc
117
117
+
];
93
118
94
119
makeFlags = [
95
120
"WITH_LIBELF=yes"
···
103
128
postInstall =
104
129
let
105
130
inherit (addDriverRunpath) driverLink;
106
106
-
libraryPath = lib.makeLibraryPath [ "$out" driverLink "${driverLink}-32" ];
131
131
+
libraryPath = lib.makeLibraryPath [
132
132
+
"$out"
133
133
+
driverLink
134
134
+
"${driverLink}-32"
135
135
+
];
107
136
in
108
137
''
109
109
-
remove-references-to -t "${go}" $out/lib/libnvidia-container-go.so.1.9.0
138
138
+
remove-references-to -t "${go}" $out/lib/libnvidia-container-go.so.${version}
110
139
wrapProgram $out/bin/nvidia-container-cli --prefix LD_LIBRARY_PATH : ${libraryPath}
111
140
'';
112
141
disallowedReferences = [ go ];